skozlov-netzke_basepack 0.1.0
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/CHANGELOG +1 -0
- data/LICENSE +20 -0
- data/Manifest +64 -0
- data/README.mdown +18 -0
- data/Rakefile +11 -0
- data/generators/netzke_basepack/USAGE +8 -0
- data/generators/netzke_basepack/netzke_basepack_generator.rb +8 -0
- data/generators/netzke_basepack/netzke_grid_generator.rb +7 -0
- data/generators/netzke_basepack/templates/create_netzke_grid_columns.rb +21 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/javascripts/basepack.js +41 -0
- data/lib/app/models/netzke_grid_column.rb +23 -0
- data/lib/netzke/accordion.rb +11 -0
- data/lib/netzke/ar_ext.rb +163 -0
- data/lib/netzke/column.rb +43 -0
- data/lib/netzke/container.rb +81 -0
- data/lib/netzke/grid.rb +132 -0
- data/lib/netzke/grid_interface.rb +132 -0
- data/lib/netzke/grid_js_builder.rb +249 -0
- data/lib/netzke/preference_grid.rb +43 -0
- data/lib/netzke/properties_tool.rb +66 -0
- data/lib/netzke/property_grid.rb +60 -0
- data/lib/netzke_basepack.rb +14 -0
- data/netzke_basepack.gemspec +38 -0
- data/tasks/netzke_basepack_tasks.rake +4 -0
- data/test/app_root/app/controllers/application.rb +2 -0
- data/test/app_root/app/models/book.rb +9 -0
- data/test/app_root/app/models/category.rb +2 -0
- data/test/app_root/app/models/city.rb +3 -0
- data/test/app_root/app/models/continent.rb +2 -0
- data/test/app_root/app/models/country.rb +3 -0
- data/test/app_root/app/models/genre.rb +3 -0
- data/test/app_root/config/boot.rb +114 -0
- data/test/app_root/config/database.yml +21 -0
- data/test/app_root/config/environment.rb +13 -0
- data/test/app_root/config/environments/in_memory.rb +0 -0
- data/test/app_root/config/environments/mysql.rb +0 -0
- data/test/app_root/config/environments/postgresql.rb +0 -0
- data/test/app_root/config/environments/sqlite.rb +0 -0
- data/test/app_root/config/environments/sqlite3.rb +0 -0
- data/test/app_root/config/routes.rb +4 -0
- data/test/app_root/db/migrate/20081222033343_create_books.rb +15 -0
- data/test/app_root/db/migrate/20081222033440_create_genres.rb +14 -0
- data/test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb +18 -0
- data/test/app_root/db/migrate/20081223024935_create_categories.rb +13 -0
- data/test/app_root/db/migrate/20081223025635_create_countries.rb +14 -0
- data/test/app_root/db/migrate/20081223025653_create_continents.rb +13 -0
- data/test/app_root/db/migrate/20081223025732_create_cities.rb +15 -0
- data/test/app_root/script/console +7 -0
- data/test/ar_ext_test.rb +39 -0
- data/test/column_test.rb +27 -0
- data/test/console_with_fixtures.rb +4 -0
- data/test/fixtures/books.yml +9 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/cities.yml +21 -0
- data/test/fixtures/continents.yml +7 -0
- data/test/fixtures/countries.yml +9 -0
- data/test/fixtures/genres.yml +9 -0
- data/test/grid_test.rb +43 -0
- data/test/netzke_basepack_test.rb +8 -0
- data/test/schema.rb +10 -0
- data/test/test_helper.rb +20 -0
- data/uninstall.rb +1 -0
- metadata +159 -0
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            module Netzke
         | 
| 2 | 
            +
              # GUI for Preference class
         | 
| 3 | 
            +
              class PreferenceGrid < PropertyGrid
         | 
| 4 | 
            +
                def initialize(*args)
         | 
| 5 | 
            +
                  super
         | 
| 6 | 
            +
                  config[:default_properties] ||= []
         | 
| 7 | 
            +
                  NetzkePreference.custom_field = config[:host_widget_name]
         | 
| 8 | 
            +
                  
         | 
| 9 | 
            +
                  # Create default properties
         | 
| 10 | 
            +
                  config[:default_properties].each do |p|
         | 
| 11 | 
            +
                    NetzkePreference[p[:name]] = p[:value] if NetzkePreference[p[:name]].nil?
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                def load_source(params = {})
         | 
| 16 | 
            +
                  # config[:data_class_name] = 'NetzkePreference'
         | 
| 17 | 
            +
                  config[:conditions] ||= {}
         | 
| 18 | 
            +
                  
         | 
| 19 | 
            +
                  data_class = NetzkePreference
         | 
| 20 | 
            +
                  records = data_class.find(:all, :conditions => {:custom_field => config[:host_widget_name]})
         | 
| 21 | 
            +
                  
         | 
| 22 | 
            +
                  NetzkePreference.custom_field = config[:host_widget_name]
         | 
| 23 | 
            +
                  
         | 
| 24 | 
            +
                  source = {}
         | 
| 25 | 
            +
                  records.each do |r|
         | 
| 26 | 
            +
                    source.merge!(r.name => NetzkePreference[r.name])
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
                  
         | 
| 29 | 
            +
                  {:source => source}
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
                
         | 
| 32 | 
            +
                def submit_source(params = {})
         | 
| 33 | 
            +
                  data = JSON.parse(params[:data])
         | 
| 34 | 
            +
                  NetzkePreference.custom_field = config[:host_widget_name]
         | 
| 35 | 
            +
                  data.each_pair do |k,v|
         | 
| 36 | 
            +
                    NetzkePreference[k.underscore] = v
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                  
         | 
| 39 | 
            +
                  {:success => true, :flash => @flash}
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
                
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            module Netzke
         | 
| 2 | 
            +
              #
         | 
| 3 | 
            +
              # Include this module into any widget if you want a "Properties" tool button in the top toolbar which will triggger a modal window, which will load the Accordion widgets, which in its turn will contain all the aggregatees specified in "property_widgets" method (*must* be defined)
         | 
| 4 | 
            +
              #
         | 
| 5 | 
            +
              module PropertiesTool
         | 
| 6 | 
            +
                def self.included(base)
         | 
| 7 | 
            +
                  base.class_eval do
         | 
| 8 | 
            +
                    [:js_extend_properties, :tools, :initial_aggregatees].each{ |m| alias_method_chain m, :properties }
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  # if you include PropertiesTool, you must define property_widgets method which will returns an array of arrgeratees that will be included in the property window (each in its own tab or accordion pane)
         | 
| 12 | 
            +
                  raise "property_widgets method undefined" unless base.instance_methods.include?("property_widgets")
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def initial_aggregatees_with_properties
         | 
| 16 | 
            +
                  res = initial_aggregatees_without_properties
         | 
| 17 | 
            +
                  # Add the accordion as aggregatee, with in its turn aggregates widgets from the property_widgets method
         | 
| 18 | 
            +
                  res.merge!(:properties => {:widget_class_name => 'Accordion', :items => property_widgets, :ext_config => {:title => false}, :no_caching => true, :late_aggregation => true}) if config[:ext_config][:properties]
         | 
| 19 | 
            +
                  res
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def tools_with_properties
         | 
| 23 | 
            +
                  tools = tools_without_properties
         | 
| 24 | 
            +
                  # Add the toolbutton
         | 
| 25 | 
            +
                  tools << {:id => 'gear', :on => {:click => "showConfig"}} if config[:ext_config][:properties]
         | 
| 26 | 
            +
                  tools
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              
         | 
| 29 | 
            +
                def js_extend_properties_with_properties
         | 
| 30 | 
            +
                  js_extend_properties_without_properties.merge({
         | 
| 31 | 
            +
                    :show_config => <<-JS.l
         | 
| 32 | 
            +
                      function(){
         | 
| 33 | 
            +
                        var w = new Ext.Window({
         | 
| 34 | 
            +
                          title:'Config',
         | 
| 35 | 
            +
                          layout:'fit',
         | 
| 36 | 
            +
                  				modal:true,
         | 
| 37 | 
            +
                          width:window.innerWidth*.9,
         | 
| 38 | 
            +
                          height:window.innerHeight*.9,
         | 
| 39 | 
            +
                  	      closeAction:'destroy',
         | 
| 40 | 
            +
                  	      buttons:[{
         | 
| 41 | 
            +
                  	        text:'Submit',
         | 
| 42 | 
            +
                  	        handler:function(){this.ownerCt.closeRes = 'OK'; this.ownerCt.destroy()}
         | 
| 43 | 
            +
                  	      }]
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  			});
         | 
| 46 | 
            +
                      
         | 
| 47 | 
            +
                  			w.show(null, function(){
         | 
| 48 | 
            +
                          w.loadWidget(this.initialConfig.id+"__properties__get_widget");
         | 
| 49 | 
            +
                  			}, this);
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  			w.on('destroy', function(){
         | 
| 52 | 
            +
                  			  if (w.closeRes == 'OK'){
         | 
| 53 | 
            +
                            widget = this;
         | 
| 54 | 
            +
                  			    if (widget.ownerCt) {
         | 
| 55 | 
            +
                              widget.ownerCt.loadWidget(widget.initialConfig.interface.getWidget);
         | 
| 56 | 
            +
                            } else {
         | 
| 57 | 
            +
                              this.feedback('Reload current window') // no aggregation
         | 
| 58 | 
            +
                            }
         | 
| 59 | 
            +
                  			  }
         | 
| 60 | 
            +
                  			}, this)
         | 
| 61 | 
            +
                      }
         | 
| 62 | 
            +
                    JS
         | 
| 63 | 
            +
                  })
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
            end
         | 
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            module Netzke
         | 
| 2 | 
            +
              #
         | 
| 3 | 
            +
              # Ext.grid.PropertyGrid
         | 
| 4 | 
            +
              #
         | 
| 5 | 
            +
              class PropertyGrid < Base
         | 
| 6 | 
            +
                interface :load_source, :submit_source
         | 
| 7 | 
            +
                
         | 
| 8 | 
            +
                def initialize(*args)
         | 
| 9 | 
            +
                  super
         | 
| 10 | 
            +
                  @config = {:ext_config => {}}.merge(@config)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def js_base_class
         | 
| 14 | 
            +
                  "Ext.grid.PropertyGrid"
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def actions
         | 
| 18 | 
            +
                  [{
         | 
| 19 | 
            +
                    :text => 'Apply', :handler => 'submit'
         | 
| 20 | 
            +
                  }]
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def js_default_config
         | 
| 24 | 
            +
                  super.merge({
         | 
| 25 | 
            +
                    :bbar => "config.actions".l
         | 
| 26 | 
            +
                  })
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
                
         | 
| 29 | 
            +
                def js_extend_properties
         | 
| 30 | 
            +
                  {
         | 
| 31 | 
            +
                    :submit => <<-JS.l,
         | 
| 32 | 
            +
                    function() {
         | 
| 33 | 
            +
                      Ext.Ajax.request({
         | 
| 34 | 
            +
                        url:this.initialConfig.interface.submitSource,
         | 
| 35 | 
            +
                        params:{data:Ext.encode(this.getSource())},
         | 
| 36 | 
            +
                        scope:this
         | 
| 37 | 
            +
                      })
         | 
| 38 | 
            +
                    }
         | 
| 39 | 
            +
                    JS
         | 
| 40 | 
            +
                    :on_widget_load => <<-JS.l,
         | 
| 41 | 
            +
                    function(){
         | 
| 42 | 
            +
                      this.loadSource()
         | 
| 43 | 
            +
                    }
         | 
| 44 | 
            +
                    JS
         | 
| 45 | 
            +
                    :load_source => <<-JS.l,
         | 
| 46 | 
            +
                      function(){Ext.Ajax.request({
         | 
| 47 | 
            +
                        url:this.initialConfig.interface.loadSource,
         | 
| 48 | 
            +
                        success:function(r){
         | 
| 49 | 
            +
                          var m = Ext.decode(r.responseText);
         | 
| 50 | 
            +
                  				this.setSource(m.source);
         | 
| 51 | 
            +
                          // this.feedback(m.flash);
         | 
| 52 | 
            +
                        },
         | 
| 53 | 
            +
                        scope:this
         | 
| 54 | 
            +
                      })}
         | 
| 55 | 
            +
                    JS
         | 
| 56 | 
            +
                  }
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
                
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
            end
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            # External dependencies
         | 
| 2 | 
            +
            require 'netzke_core'
         | 
| 3 | 
            +
            require 'searchlogic'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'netzke/ar_ext'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            %w{ models }.each do |dir|
         | 
| 8 | 
            +
              path = File.join(File.dirname(__FILE__), 'app', dir)
         | 
| 9 | 
            +
              $LOAD_PATH << path
         | 
| 10 | 
            +
              ActiveSupport::Dependencies.load_paths << path
         | 
| 11 | 
            +
              ActiveSupport::Dependencies.load_once_paths.delete(path)
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            Netzke::Base.config[:javascripts] << "#{File.dirname(__FILE__)}/../javascripts/basepack.js"
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem::Specification.new do |s|
         | 
| 4 | 
            +
              s.name = %q{netzke_basepack}
         | 
| 5 | 
            +
              s.version = "0.1.0"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
         | 
| 8 | 
            +
              s.authors = ["Sergei Kozlov"]
         | 
| 9 | 
            +
              s.date = %q{2008-12-27}
         | 
| 10 | 
            +
              s.description = %q{Base Netzke widgets - grid, form, tree, and more}
         | 
| 11 | 
            +
              s.email = %q{sergei@writelesscode.com}
         | 
| 12 | 
            +
              s.extra_rdoc_files = ["CHANGELOG", "lib/app/models/netzke_grid_column.rb", "lib/netzke/accordion.rb", "lib/netzke/ar_ext.rb", "lib/netzke/column.rb", "lib/netzke/container.rb", "lib/netzke/grid.rb", "lib/netzke/grid_interface.rb", "lib/netzke/grid_js_builder.rb", "lib/netzke/preference_grid.rb", "lib/netzke/properties_tool.rb", "lib/netzke/property_grid.rb", "lib/netzke_basepack.rb", "LICENSE", "README.mdown", "tasks/netzke_basepack_tasks.rake"]
         | 
| 13 | 
            +
              s.files = ["CHANGELOG", "generators/netzke_basepack/netzke_basepack_generator.rb", "generators/netzke_basepack/netzke_grid_generator.rb", "generators/netzke_basepack/templates/create_netzke_grid_columns.rb", "generators/netzke_basepack/USAGE", "init.rb", "install.rb", "javascripts/basepack.js", "lib/app/models/netzke_grid_column.rb", "lib/netzke/accordion.rb", "lib/netzke/ar_ext.rb", "lib/netzke/column.rb", "lib/netzke/container.rb", "lib/netzke/grid.rb", "lib/netzke/grid_interface.rb", "lib/netzke/grid_js_builder.rb", "lib/netzke/preference_grid.rb", "lib/netzke/properties_tool.rb", "lib/netzke/property_grid.rb", "lib/netzke_basepack.rb", "LICENSE", "Manifest", "netzke_basepack.gemspec", "Rakefile", "README.mdown", "tasks/netzke_basepack_tasks.rake", "test/app_root/app/controllers/application.rb", "test/app_root/app/models/book.rb", "test/app_root/app/models/category.rb", "test/app_root/app/models/city.rb", "test/app_root/app/models/continent.rb", "test/app_root/app/models/country.rb", "test/app_root/app/models/genre.rb", "test/app_root/config/boot.rb", "test/app_root/config/database.yml", "test/app_root/config/environment.rb", "test/app_root/config/environments/in_memory.rb", "test/app_root/config/environments/mysql.rb", "test/app_root/config/environments/postgresql.rb", "test/app_root/config/environments/sqlite.rb", "test/app_root/config/environments/sqlite3.rb", "test/app_root/config/routes.rb", "test/app_root/db/migrate/20081222033343_create_books.rb", "test/app_root/db/migrate/20081222033440_create_genres.rb", "test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb", "test/app_root/db/migrate/20081223024935_create_categories.rb", "test/app_root/db/migrate/20081223025635_create_countries.rb", "test/app_root/db/migrate/20081223025653_create_continents.rb", "test/app_root/db/migrate/20081223025732_create_cities.rb", "test/app_root/script/console", "test/ar_ext_test.rb", "test/column_test.rb", "test/console_with_fixtures.rb", "test/fixtures/books.yml", "test/fixtures/categories.yml", "test/fixtures/cities.yml", "test/fixtures/continents.yml", "test/fixtures/countries.yml", "test/fixtures/genres.yml", "test/grid_test.rb", "test/netzke_basepack_test.rb", "test/schema.rb", "test/test_helper.rb", "uninstall.rb"]
         | 
| 14 | 
            +
              s.has_rdoc = true
         | 
| 15 | 
            +
              s.homepage = %q{http://writelesscode.com}
         | 
| 16 | 
            +
              s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Netzke_basepack", "--main", "README.mdown"]
         | 
| 17 | 
            +
              s.require_paths = ["lib"]
         | 
| 18 | 
            +
              s.rubyforge_project = %q{netzke_basepack}
         | 
| 19 | 
            +
              s.rubygems_version = %q{1.3.1}
         | 
| 20 | 
            +
              s.summary = %q{Base Netzke widgets - grid, form, tree, and more}
         | 
| 21 | 
            +
              s.test_files = ["test/ar_ext_test.rb", "test/column_test.rb", "test/grid_test.rb", "test/netzke_basepack_test.rb"]
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              if s.respond_to? :specification_version then
         | 
| 24 | 
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 25 | 
            +
                s.specification_version = 2
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         | 
| 28 | 
            +
                  s.add_runtime_dependency(%q<searchlogic>, [">= 1.6.2"])
         | 
| 29 | 
            +
                  s.add_runtime_dependency(%q<netzke_core>, [">= 0", "= 0.1.0"])
         | 
| 30 | 
            +
                else
         | 
| 31 | 
            +
                  s.add_dependency(%q<searchlogic>, [">= 1.6.2"])
         | 
| 32 | 
            +
                  s.add_dependency(%q<netzke_core>, [">= 0", "= 0.1.0"])
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              else
         | 
| 35 | 
            +
                s.add_dependency(%q<searchlogic>, [">= 1.6.2"])
         | 
| 36 | 
            +
                s.add_dependency(%q<netzke_core>, [">= 0", "= 0.1.0"])
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| @@ -0,0 +1,114 @@ | |
| 1 | 
            +
            # Allow customization of the rails framework path
         | 
| 2 | 
            +
            RAILS_FRAMEWORK_ROOT = (ENV['RAILS_FRAMEWORK_ROOT'] || "#{File.dirname(__FILE__)}/../../../../../../vendor/rails") unless defined?(RAILS_FRAMEWORK_ROOT) 
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            # Don't change this file!
         | 
| 5 | 
            +
            # Configure your app in config/environment.rb and config/environments/*.rb
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            module Rails
         | 
| 10 | 
            +
              class << self
         | 
| 11 | 
            +
                def boot!
         | 
| 12 | 
            +
                  unless booted?
         | 
| 13 | 
            +
                    preinitialize
         | 
| 14 | 
            +
                    pick_boot.run
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def booted?
         | 
| 19 | 
            +
                  defined? Rails::Initializer
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def pick_boot
         | 
| 23 | 
            +
                  (vendor_rails? ? VendorBoot : GemBoot).new
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def vendor_rails?
         | 
| 27 | 
            +
                  File.exist?(RAILS_FRAMEWORK_ROOT)
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def preinitialize
         | 
| 31 | 
            +
                  load(preinitializer_path) if File.exist?(preinitializer_path)
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def preinitializer_path
         | 
| 35 | 
            +
                  "#{RAILS_ROOT}/config/preinitializer.rb"
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              class Boot
         | 
| 40 | 
            +
                def run
         | 
| 41 | 
            +
                  load_initializer
         | 
| 42 | 
            +
                  Rails::Initializer.run(:set_load_path)
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              class VendorBoot < Boot
         | 
| 47 | 
            +
                def load_initializer
         | 
| 48 | 
            +
                  require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/initializer"
         | 
| 49 | 
            +
                  Rails::Initializer.run(:install_gem_spec_stubs)
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              class GemBoot < Boot
         | 
| 54 | 
            +
                def load_initializer
         | 
| 55 | 
            +
                  self.class.load_rubygems
         | 
| 56 | 
            +
                  load_rails_gem
         | 
| 57 | 
            +
                  require 'initializer'
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                def load_rails_gem
         | 
| 61 | 
            +
                  if version = self.class.gem_version
         | 
| 62 | 
            +
                    gem 'rails', version
         | 
| 63 | 
            +
                  else
         | 
| 64 | 
            +
                    gem 'rails'
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
                rescue Gem::LoadError => load_error
         | 
| 67 | 
            +
                  $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
         | 
| 68 | 
            +
                  exit 1
         | 
| 69 | 
            +
                end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                class << self
         | 
| 72 | 
            +
                  def rubygems_version
         | 
| 73 | 
            +
                    Gem::RubyGemsVersion rescue nil
         | 
| 74 | 
            +
                  end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  def gem_version
         | 
| 77 | 
            +
                    if defined? RAILS_GEM_VERSION
         | 
| 78 | 
            +
                      RAILS_GEM_VERSION
         | 
| 79 | 
            +
                    elsif ENV.include?('RAILS_GEM_VERSION')
         | 
| 80 | 
            +
                      ENV['RAILS_GEM_VERSION']
         | 
| 81 | 
            +
                    else
         | 
| 82 | 
            +
                      parse_gem_version(read_environment_rb)
         | 
| 83 | 
            +
                    end
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  def load_rubygems
         | 
| 87 | 
            +
                    require 'rubygems'
         | 
| 88 | 
            +
                    min_version = '1.1.1'
         | 
| 89 | 
            +
                    unless rubygems_version >= min_version
         | 
| 90 | 
            +
                      $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
         | 
| 91 | 
            +
                      exit 1
         | 
| 92 | 
            +
                    end
         | 
| 93 | 
            +
             
         | 
| 94 | 
            +
                  rescue LoadError
         | 
| 95 | 
            +
                    $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
         | 
| 96 | 
            +
                    exit 1
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  def parse_gem_version(text)
         | 
| 100 | 
            +
                    $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  private
         | 
| 104 | 
            +
                    def read_environment_rb
         | 
| 105 | 
            +
                      environment_rb = "#{RAILS_ROOT}/config/environment.rb"
         | 
| 106 | 
            +
                      environment_rb = "#{HELPER_RAILS_ROOT}/config/environment.rb" unless File.exists?(environment_rb)
         | 
| 107 | 
            +
                      File.read(environment_rb)
         | 
| 108 | 
            +
                    end
         | 
| 109 | 
            +
                end
         | 
| 110 | 
            +
              end
         | 
| 111 | 
            +
            end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            # All that for this:
         | 
| 114 | 
            +
            Rails.boot!
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            in_memory:
         | 
| 2 | 
            +
              adapter: sqlite3
         | 
| 3 | 
            +
              database: ":memory:"
         | 
| 4 | 
            +
              verbosity: quiet
         | 
| 5 | 
            +
            sqlite:
         | 
| 6 | 
            +
              adapter: sqlite
         | 
| 7 | 
            +
              dbfile: plugin_test.sqlite.db
         | 
| 8 | 
            +
            sqlite3:
         | 
| 9 | 
            +
              adapter: sqlite3
         | 
| 10 | 
            +
              dbfile: plugin_test.sqlite3.db
         | 
| 11 | 
            +
            postgresql:
         | 
| 12 | 
            +
              adapter: postgresql
         | 
| 13 | 
            +
              username: postgres
         | 
| 14 | 
            +
              password: postgres
         | 
| 15 | 
            +
              database: plugin_test
         | 
| 16 | 
            +
            mysql:
         | 
| 17 | 
            +
              adapter: mysql
         | 
| 18 | 
            +
              host: localhost
         | 
| 19 | 
            +
              username: root
         | 
| 20 | 
            +
              password:
         | 
| 21 | 
            +
              database: plugin_test
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require File.join(File.dirname(__FILE__), 'boot')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Rails::Initializer.run do |config|
         | 
| 4 | 
            +
              config.cache_classes = false
         | 
| 5 | 
            +
              config.whiny_nils = true
         | 
| 6 | 
            +
              config.plugin_locators.unshift(
         | 
| 7 | 
            +
                Class.new(Rails::Plugin::Locator) do
         | 
| 8 | 
            +
                  def plugins
         | 
| 9 | 
            +
                    [Rails::Plugin.new(File.expand_path('.'))]
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              ) unless defined?(PluginTestHelper::PluginLocator)
         | 
| 13 | 
            +
            end
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |