toy-locomotive 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +2 -2
- data/lib/toy-locomotive/attributes/chain.rb +6 -1
- data/lib/toy-locomotive/auto_views/form.rb +22 -0
- data/lib/toy-locomotive/initializer.rb +5 -2
- data/lib/toy-locomotive/router/block.rb +11 -0
- data/lib/toy-locomotive/router/controller.rb +3 -3
- data/lib/toy-locomotive/version.rb +1 -1
- metadata +32 -11
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                toy-locomotive (0.0. | 
| 4 | 
            +
                toy-locomotive (0.0.9)
         | 
| 5 5 | 
             
                  rails
         | 
| 6 6 |  | 
| 7 7 | 
             
            GEM
         | 
| @@ -46,7 +46,7 @@ GEM | |
| 46 46 | 
             
                  i18n (>= 0.4.0)
         | 
| 47 47 | 
             
                  mime-types (~> 1.16)
         | 
| 48 48 | 
             
                  treetop (~> 1.4.8)
         | 
| 49 | 
            -
                mime-types (1. | 
| 49 | 
            +
                mime-types (1.19)
         | 
| 50 50 | 
             
                multi_json (1.3.4)
         | 
| 51 51 | 
             
                polyglot (0.3.3)
         | 
| 52 52 | 
             
                rack (1.4.1)
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            module ToyLocomotive::Attributes
         | 
| 2 2 | 
             
              class AttributeChain
         | 
| 3 3 |  | 
| 4 | 
            -
                attr_accessor :column, :parent, :_as, :_helper
         | 
| 4 | 
            +
                attr_accessor :column, :parent, :_as, :_helper, :_options
         | 
| 5 5 |  | 
| 6 6 | 
             
                def initialize column, parent
         | 
| 7 7 | 
             
                  @column = column
         | 
| @@ -15,6 +15,11 @@ module ToyLocomotive::Attributes | |
| 15 15 | 
             
                  self
         | 
| 16 16 | 
             
                end
         | 
| 17 17 |  | 
| 18 | 
            +
                def options *args
         | 
| 19 | 
            +
                  @_options = (args.any? && args.first.is_a?(Array)) ? args.first : args
         | 
| 20 | 
            +
                  self
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 18 23 | 
             
                def presence bool
         | 
| 19 24 | 
             
                  parent.send :validates_presence_of, column
         | 
| 20 25 | 
             
                  self
         | 
| @@ -1,5 +1,9 @@ | |
| 1 1 | 
             
            module ToyLocomotive::AutoViews
         | 
| 2 2 | 
             
              def auto_form_for args
         | 
| 3 | 
            +
                if block_given?
         | 
| 4 | 
            +
                  form = ToyLocomotive::AutoViews::AutoForm.new
         | 
| 5 | 
            +
                  yield(form)
         | 
| 6 | 
            +
                end
         | 
| 3 7 | 
             
                form_for args do |f|
         | 
| 4 8 | 
             
                  arg = args.class == Array ? args.last : args
         | 
| 5 9 | 
             
                  klass = arg.class
         | 
| @@ -13,6 +17,9 @@ module ToyLocomotive::AutoViews | |
| 13 17 | 
             
                      if attr.to_helper == :check_box
         | 
| 14 18 | 
             
                        html += f.send attr.to_helper, attr.to_table_column
         | 
| 15 19 | 
             
                        html += f.label attr.to_table_column
         | 
| 20 | 
            +
                      elsif attr.to_helper == :select
         | 
| 21 | 
            +
                        html += f.label attr.to_table_column
         | 
| 22 | 
            +
                        html += f.send attr.to_helper, attr.to_table_column, attr._options
         | 
| 16 23 | 
             
                      else
         | 
| 17 24 | 
             
                        html += f.label attr.to_table_column
         | 
| 18 25 | 
             
                        html += f.send attr.to_helper, attr.to_table_column
         | 
| @@ -21,6 +28,9 @@ module ToyLocomotive::AutoViews | |
| 21 28 | 
             
                    end
         | 
| 22 29 | 
             
                  end
         | 
| 23 30 | 
             
                  html += '<div class="actions">'
         | 
| 31 | 
            +
                  puts "+++++++++++++++++++"
         | 
| 32 | 
            +
                  puts form._actions if block_given?
         | 
| 33 | 
            +
                  puts "+++++++++++++++++++"
         | 
| 24 34 | 
             
                  html += f.submit
         | 
| 25 35 | 
             
                  html += link_to "Cancel", root_path
         | 
| 26 36 | 
             
                  html += '</div>'
         | 
| @@ -29,4 +39,16 @@ module ToyLocomotive::AutoViews | |
| 29 39 | 
             
              end
         | 
| 30 40 | 
             
            end
         | 
| 31 41 |  | 
| 42 | 
            +
            class ToyLocomotive::AutoViews::AutoForm
         | 
| 43 | 
            +
              attr_accessor :_actions
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              def actions &blk
         | 
| 46 | 
            +
                @_actions = blk
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              def _actions
         | 
| 50 | 
            +
                @_actions.call.to_s
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
            end
         | 
| 53 | 
            +
             | 
| 32 54 | 
             
            ActionView::Base.send :include, ToyLocomotive::AutoViews
         | 
| @@ -1,16 +1,19 @@ | |
| 1 1 | 
             
            module ToyLocomotive
         | 
| 2 2 | 
             
              class Engine < Rails::Engine
         | 
| 3 | 
            -
                initializer 'toy_locomotive.initialize', :after=> :disable_dependency_loading do |app|
         | 
| 3 | 
            +
                initializer 'toy_locomotive.initialize', :after => :disable_dependency_loading do |app|
         | 
| 4 4 | 
             
                  Dir["#{Rails.root}/app/models/*.rb"].each do |file|
         | 
| 5 5 | 
             
                    require file
         | 
| 6 6 | 
             
                    AttributeObserver.new file.split('/').last.split('.').first.classify.constantize
         | 
| 7 7 | 
             
                  end
         | 
| 8 | 
            +
                  controllers = []
         | 
| 8 9 | 
             
                  Dir["#{Rails.root}/app/controllers/*.rb"].each do |file|
         | 
| 9 10 | 
             
                    require file
         | 
| 10 | 
            -
                     | 
| 11 | 
            +
                    controllers << file.split('/').last.split('.').first.classify.constantize
         | 
| 12 | 
            +
                    controllers.last.append_filters!
         | 
| 11 13 | 
             
                  end
         | 
| 12 14 | 
             
                  Rails.application.class.routes.draw do
         | 
| 13 15 | 
             
                    ToyLocomotive.routes.each {|route| match route[:path] => "#{route[:controller]}##{route[:action]}", as: route[:as], via: route[:method]}
         | 
| 16 | 
            +
                  #  controllers.each {|controller| controller._route.call if controller._route}
         | 
| 14 17 | 
             
                  end
         | 
| 15 18 | 
             
                end
         | 
| 16 19 | 
             
              end
         | 
| @@ -91,7 +91,7 @@ module ToyLocomotive::Router::Controller | |
| 91 91 | 
             
              module InstanceMethods
         | 
| 92 92 |  | 
| 93 93 | 
             
                def extract_parent_vars
         | 
| 94 | 
            -
                  chain = self.class.belongs_chain.clone
         | 
| 94 | 
            +
                  chain = self.class.belongs_chain.reverse.clone
         | 
| 95 95 | 
             
                  vars = []
         | 
| 96 96 | 
             
                  if chain.any?
         | 
| 97 97 | 
             
                    root = chain.pop
         | 
| @@ -108,14 +108,14 @@ module ToyLocomotive::Router::Controller | |
| 108 108 | 
             
                end
         | 
| 109 109 |  | 
| 110 110 | 
             
                def extract_member_var
         | 
| 111 | 
            -
                  parent = self.class.belongs_chain.reverse.pop
         | 
| 111 | 
            +
                  parent = self.class.belongs_chain.pop#reverse.pop
         | 
| 112 112 | 
             
                  model = self.class.extract_model
         | 
| 113 113 | 
             
                  parent = parent ? instance_variable_get(parent.to_member_var) : nil
         | 
| 114 114 | 
             
                  instance_variable_set(model.to_member_var, (parent ? parent.send(model.to_s.underscore.pluralize) : model).find(params[model.to_params]))
         | 
| 115 115 | 
             
                end
         | 
| 116 116 |  | 
| 117 117 | 
             
                def extract_collection_var
         | 
| 118 | 
            -
                  parent = self.class.belongs_chain.reverse.pop
         | 
| 118 | 
            +
                  parent = self.class.belongs_chain.pop#reverse.pop
         | 
| 119 119 | 
             
                  model = self.class.extract_model
         | 
| 120 120 | 
             
                  parent = parent ? instance_variable_get(parent.to_member_var) : nil
         | 
| 121 121 | 
             
                  instance_variable_set(model.to_collection_var, (parent ? parent.send(model.to_s.underscore.pluralize) : model.all))
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: toy-locomotive
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.10
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012- | 
| 12 | 
            +
            date: 2012-07-28 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rails
         | 
| 16 | 
            -
              requirement:  | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ! '>='
         | 
| @@ -21,10 +21,15 @@ dependencies: | |
| 21 21 | 
             
                    version: '0'
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements:  | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '0'
         | 
| 25 30 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 31 | 
             
              name: rspec-rails
         | 
| 27 | 
            -
              requirement:  | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 28 33 | 
             
                none: false
         | 
| 29 34 | 
             
                requirements:
         | 
| 30 35 | 
             
                - - ! '>='
         | 
| @@ -32,10 +37,15 @@ dependencies: | |
| 32 37 | 
             
                    version: '0'
         | 
| 33 38 | 
             
              type: :development
         | 
| 34 39 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements:  | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ! '>='
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: '0'
         | 
| 36 46 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 47 | 
             
              name: sqlite3
         | 
| 38 | 
            -
              requirement:  | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 39 49 | 
             
                none: false
         | 
| 40 50 | 
             
                requirements:
         | 
| 41 51 | 
             
                - - ! '>='
         | 
| @@ -43,10 +53,15 @@ dependencies: | |
| 43 53 | 
             
                    version: '0'
         | 
| 44 54 | 
             
              type: :development
         | 
| 45 55 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements:  | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 47 62 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 63 | 
             
              name: shoulda
         | 
| 49 | 
            -
              requirement:  | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 65 | 
             
                none: false
         | 
| 51 66 | 
             
                requirements:
         | 
| 52 67 | 
             
                - - ! '>='
         | 
| @@ -54,7 +69,12 @@ dependencies: | |
| 54 69 | 
             
                    version: '0'
         | 
| 55 70 | 
             
              type: :development
         | 
| 56 71 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements:  | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ! '>='
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '0'
         | 
| 58 78 | 
             
            description: a Different aproach to Rails applications
         | 
| 59 79 | 
             
            email:
         | 
| 60 80 | 
             
            - mortaro@towsta.com
         | 
| @@ -74,6 +94,7 @@ files: | |
| 74 94 | 
             
            - lib/toy-locomotive/auto_views/show.rb
         | 
| 75 95 | 
             
            - lib/toy-locomotive/initializer.rb
         | 
| 76 96 | 
             
            - lib/toy-locomotive/resources/controller.rb
         | 
| 97 | 
            +
            - lib/toy-locomotive/router/block.rb
         | 
| 77 98 | 
             
            - lib/toy-locomotive/router/controller.rb
         | 
| 78 99 | 
             
            - lib/toy-locomotive/router/model.rb
         | 
| 79 100 | 
             
            - lib/toy-locomotive/version.rb
         | 
| @@ -110,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 110 131 | 
             
                  version: '0'
         | 
| 111 132 | 
             
            requirements: []
         | 
| 112 133 | 
             
            rubyforge_project: toy-locomotive
         | 
| 113 | 
            -
            rubygems_version: 1.8. | 
| 134 | 
            +
            rubygems_version: 1.8.24
         | 
| 114 135 | 
             
            signing_key: 
         | 
| 115 136 | 
             
            specification_version: 3
         | 
| 116 137 | 
             
            summary: a Toy Locomotive to run over Rails
         |