Giter Site home page Giter Site logo

dm-is-remixable's People

Contributors

aq1018 avatar bernerdschaefer avatar coryodaniel avatar dkubb avatar gix avatar gugod avatar michaelklishin avatar myabc avatar namelessjon avatar paul avatar snusnu avatar solnic avatar somebee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dm-is-remixable's Issues

Not working for Float property

I'm receiving strange error when I have Float property in module.

module Comment
  include DataMapper::Resource
  is :remixable
   property :id, Serial
   property :vote, Floar
end

class Post
  include DataMapper::Resource
  ...
  remix 1, :comments
end

the stack trace is

/Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/property.rb:780:in `each': +options[:scale]+ should be Integer, but was NilClass (ArgumentError)
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/property.rb:780:in `assert_valid_options'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/property.rb:743:in `initialize'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/property/numeric.rb:16:in `initialize'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:55:in `new'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:55:in `property'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-validations-1.2.0/lib/dm-validations/auto_validate.rb:11:in `property'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@nutri/gems/dm-is-remixable-1.2.0/lib/dm-is-remixable/is/remixable.rb:385:in `block in generate_remixed_model'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/subject_set.rb:210:in `block in each'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `block in each'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `each'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `each'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/subject_set.rb:210:in `each'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@nutri/gems/dm-is-remixable-1.2.0/lib/dm-is-remixable/is/remixable.rb:384:in `generate_remixed_model'
    from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@nutri/gems/dm-is-remixable-1.2.0/lib/dm-is-remixable/is/remixable.rb:188:in `remix'

I'm using DM v 1.2.0

Any idea?

Thank you

The last `remix 1` is not working in the README example code.

Hi,

I try to run the example code in the README.rdoc and found it failed from dm-core:

/usr/local/Cellar/ruby-enterprise-edition/2010.02/lib/ruby/gems/1.8/gems/dm-core-1.0.2/lib/dm-core/associations/relationship.rb:173:in `target_model': Cannot find the child_model VideoCommentVotes for User in video_comment_votes (NameError)

The code actually used is here: http://gist.github.com/582753

If I change line 85 to remix n like:

remix n, :votes, :for => "User"

Then it worked. The migration is finished and the created tables seems to be correct for me.

I discovered this when I was playing with dm-is-remixable and remix 1 was never working in there. It was a direct, non-nested remix.

Remix 1

I believe that the ability to remix 1 should behave differently. According to the documentation from the remix 1, :addressables example found on the README the Location being remixed with 1 address does the following:

  • Creates a class called LocationAddress
  • Duplicates the properties of Addressable within LocationAddress
  • Creates a table called location_addresses
  • Creates Location#location_addresses accessor

However when inspecting the database it appears that multiple addresses can technically be applied to 1 location. I'm proposing the following behavior:

  • In the location_addresses table there should be a unique constraint placed on location_id
  • Instead of a Location#location_addresses accessor, it should be a singular Location#location_address or Location#address accessor

dm-is-remixable has a dependency on activesupport

If activesupport isn't present, dm-is-remixable fails with:

dm-is-remixable-1.0.2/lib/dm-is-remixable/is/remixable.rb:71:in is_remixable': uninitialized constant ActiveSupport::Inflector (NameError) from dm-core-1.0.2/lib/dm-core/model/is.rb:23:inis'
[...]

extlib (which is installed) seems to include an inflector, but dm-is-remixable doesn't bring it in like dm-core and dm-validations do?

dm-is-remixable fails with namespaced models

Here's a simple testcase:

require 'rubygems'
require 'dm-core'

#  See issue 8 for why I'm doing this
require 'extlib/inflection'
module ActiveSupport
  Inflector = ::Extlib::Inflection
end

require 'dm-is-remixable'

module Test

  module Foo
    include DataMapper::Resource
    is :remixable

    property :id, Serial
  end

  class WorkingFoo
    include DataMapper::Resource
    property :id, Serial
    property :bar_id, Integer
  end

  class Bar
    include DataMapper::Resource
    property :id, Serial
    has n, :working_foos  # Works
    remix n, :foos        # Doesn't work
  end
end

I get:
NameError: uninitialized constant Foo
from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:13:in full_const_get' from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:10:ineach'
from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:10:in full_const_get' from dm-is-remixable-1.0.2/lib/dm-is-remixable/is/remixable.rb:160:inremix'

It might actually be a bug in dm-core, I guess (since we're using full_const_get) - but the has n, :working_foos doesn't raise in the same manner.

dm-is-remixable does a non-standard method to lookup models.

I noticed that dm-is-remixable searches for models at the top-level first. This differs from how dm-core resolves models, which begins searching in the current namespace upward.

# lib/dm-is-remixable/is/remixable.rb:60
remixable_module = case remixable
  when Symbol then Object.full_const_get(ActiveSupport::Inflector.    classify(remixable))
  when String then Object.full_const_get(remixable)
  when Module then remixable
end

Table name FAIL

Given the following

class Person
  include DataMapper::Resource

  property :id,   Serial
  property :name, String

  remix n, :addresses
end

module Address
  include DataMapper::Resource

  is :remixable

  property :id,   Serial
  property :city, String
end

When I run

rake db:automigrate,

Then, instead of getting a table called person_addresses,

it's called person_addres, not at all what I expected.

Looks like a pluralization issue? So far its the only model I have with this problem.

Also no matter what I do (on any model), remix n ignores the :as key (by ignore I mean that the table names are not affected, I'm unsure if that's the intended behavior)

uninitialized constant Extlib::Inflection

Upgrading a new application to 3.1/1.2.0.rc1

This only appears when using dm-is-remixable is installed

rake db:automigrate --trace 
rake aborted!
uninitialized constant Extlib::Inflection
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in `const_missing'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/dm-is-remixable-0.10.0/lib/dm-is-remixable/is/remixable.rb:10:in `<top (required)>'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/dm-is-remixable-0.10.0/lib/dm-is-remixable.rb:1:in `require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/dm-is-remixable-0.10.0/lib/dm-is-remixable.rb:1:in `<top (required)>'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `block in require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
/media/essential/projects/1_current/thrisp/modules/+velicessegia/ticketenginealpha/config/application.rb:13:in `<top (required)>'
/home/qx/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/qx/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/media/essential/projects/1_current/thrisp/modules/+velicessegia/ticketenginealpha/Rakefile:5:in `<top (required)>'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/home/qx/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/home/qx/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'

remixed model repository remains :default

I've just started working with trying to create different repositories, and I haven't been able to get remixed models to inherit the repository, or change the repository from :default

Using this:

https://gist.github.com/1278627

I can specify a repository for the Ticket model, but TicketComments can not be changed from the methods I've tried. The expected behavior should be for remixed models to inherit the repository of the models remixed from, i.e. TicketComments should inherit the repository of Ticket, but this may be my opinion in this case and I can see where it might not always be the case.

I'm probably missing the obvious method, but going through several times from various directions resulted in no change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.