desert 0.1.1 → 0.2.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/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 0.2.0
2
+ - Works with edge Rails
3
+ - Removed Desert::Plugin#up_to_date?
4
+ - Removed Migrator#latest_version
5
+
1
6
  0.1.1
2
7
  - Works with edge Rails
3
8
  - Fixed double loading issue with not fully expanded load_paths.
data/README CHANGED
@@ -74,4 +74,16 @@ You can run your plugin tests/specs like so:
74
74
  rake desert:testspec:plugins PLUGIN=spiffy
75
75
 
76
76
  Leaving off the PLUGIN environment variable will cause it to run all the test/specs for
77
- all installed plugins, which may not be what you want.
77
+ all installed plugins, which may not be what you want.
78
+
79
+ == Running Desert tests
80
+
81
+ Desert is a library that heavily monkey patches Rails. To ensure that Desert works with
82
+ multiple versions of Rails, its tests are run against the supported versions of Rails.
83
+
84
+ To set up the different supported versions of Rails, run `rake install_dependencies`.
85
+
86
+ This will clone the Rails git repo and export the supported versions of rails into the
87
+ respective directories.
88
+
89
+ `rake update_dependencies` will update the clones repo on your machine.
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ task(:tag_release) do
26
26
  end
27
27
 
28
28
  PKG_NAME = "desert"
29
- PKG_VERSION = "0.1.1"
29
+ PKG_VERSION = "0.2.0"
30
30
  PKG_FILES = FileList[
31
31
  '[A-Z]*',
32
32
  '*.rb',
@@ -52,7 +52,6 @@ spec = Gem::Specification.new do |s|
52
52
 
53
53
  s.test_files = Dir.glob('spec/*_spec.rb')
54
54
  s.require_path = 'lib'
55
- s.autorequire = 'desert'
56
55
  s.author = "Pivotal Labs"
57
56
  s.email = "opensource@pivotallabs.com"
58
57
  s.homepage = "http://pivotallabs.com"
@@ -68,4 +67,27 @@ def tag_release
68
67
  dashed_version = PKG_VERSION.gsub('.', '-')
69
68
  svn_user = "#{ENV["SVN_USER"]}@" || ""
70
69
  `svn cp svn+ssh://#{svn_user}rubyforge.org/var/svn/pivotalrb/desert/trunk svn+ssh://#{svn_user}rubyforge.org/var/svn/pivotalrb/desert/tags/REL-#{dashed_version} -m 'Version #{PKG_VERSION}'`
71
- end
70
+ end
71
+
72
+ desc "Install dependencies to run the build. This task uses Git."
73
+ task(:install_dependencies) do
74
+ require "lib/desert/supported_rails_versions"
75
+ system("git clone git://github.com/rails/rails.git spec/rails_root/vendor/rails_versions/edge")
76
+ Dir.chdir("spec/rails_root/vendor/rails_versions/edge") do
77
+ begin
78
+ Desert::SUPPORTED_RAILS_VERSIONS.each do |version, data|
79
+ unless version == 'edge'
80
+ system("git checkout #{data['git_tag']}")
81
+ system("cp -R ../edge ../#{version}")
82
+ end
83
+ end
84
+ ensure
85
+ system("git checkout master")
86
+ end
87
+ end
88
+ end
89
+
90
+ desc "Updates the dependencies to run the build. This task uses Git."
91
+ task(:update_dependencies) do
92
+ system "cd spec/rails_root/vendor/edge_rails; git pull origin"
93
+ end
data/lib/desert.rb CHANGED
@@ -4,29 +4,11 @@ require "action_controller"
4
4
  require "action_mailer"
5
5
 
6
6
  dir = File.dirname(__FILE__)
7
+ require "#{dir}/desert/supported_rails_versions"
7
8
  require "#{dir}/desert/plugin"
8
9
  require "#{dir}/desert/manager"
9
10
  require "#{dir}/desert/version_checker"
10
-
11
- if Desert::VersionChecker.rails_version_is_below_1990?
12
- require "#{dir}/desert/rails/1.x/initializer"
13
- else
14
- require "#{dir}/desert/rails/2.x/plugin"
15
- end
16
- require "#{dir}/desert/rails/dependencies"
17
- require "#{dir}/desert/rails/migration"
18
- require "#{dir}/desert/rails/migrator"
19
- require "#{dir}/desert/ruby/object"
20
-
21
- require "#{dir}/desert/rails/route_set"
22
-
23
- require "#{dir}/desert/plugin_migrations/migrator"
24
- require "#{dir}/desert/plugin_migrations/extensions/schema_statements"
25
-
26
- require "#{dir}/desert/plugin_templates/action_controller"
27
- if Desert::VersionChecker.rails_version_is_below_rc2?
28
- require "#{dir}/desert/plugin_templates/1.x/action_mailer"
29
- else
30
- require "#{dir}/desert/plugin_templates/2.x/action_mailer"
31
- end
32
- require "#{dir}/desert/plugin_templates/action_view"
11
+ require "#{dir}/desert/rails"
12
+ require "#{dir}/desert/ruby"
13
+ require "#{dir}/desert/plugin_migrations"
14
+ require "#{dir}/desert/plugin_templates"
data/lib/desert/plugin.rb CHANGED
@@ -61,12 +61,6 @@ module Desert
61
61
  @migration ||= PluginAWeek::PluginMigrations::Migrator.new(:up, migration_path)
62
62
  end
63
63
 
64
- def up_to_date?
65
- with_current_plugin do
66
- migration.latest_version <= migration.current_version
67
- end
68
- end
69
-
70
64
  def with_current_plugin
71
65
  old_plugin = PluginAWeek::PluginMigrations::Migrator.current_plugin
72
66
  begin
@@ -0,0 +1,3 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/plugin_migrations/migrator"
3
+ require "#{dir}/plugin_migrations/extensions/schema_statements"
@@ -0,0 +1,34 @@
1
+ ActiveRecord::ConnectionAdapters::SchemaStatements.module_eval do
2
+ def initialize_schema_information_with_plugins
3
+ initialize_schema_information_without_plugins
4
+
5
+ begin
6
+ execute "CREATE TABLE #{PluginAWeek::PluginMigrations::Migrator.schema_info_table_name} (plugin_name #{type_to_sql(:string)}, version #{type_to_sql(:integer)})"
7
+ rescue ActiveRecord::StatementInvalid
8
+ # Schema has been initialized
9
+ end
10
+ end
11
+ alias_method_chain :initialize_schema_information, :plugins
12
+
13
+ def dump_schema_information_with_plugins
14
+ schema_information = []
15
+
16
+ dump = dump_schema_information_without_plugins
17
+ schema_information << dump if dump
18
+
19
+ begin
20
+ plugins = ActiveRecord::Base.connection.select_all("SELECT * FROM #{PluginAWeek::PluginMigrations::Migrator.schema_info_table_name}")
21
+ plugins.each do |plugin|
22
+ if (version = plugin['version'].to_i) > 0
23
+ plugin_name = ActiveRecord::Base.quote_value(plugin['plugin_name'])
24
+ schema_information << "INSERT INTO #{PluginAWeek::PluginMigrations::Migrator.schema_info_table_name} (plugin_name, version) VALUES (#{plugin_name}, #{version})"
25
+ end
26
+ end
27
+ rescue ActiveRecord::StatementInvalid
28
+ # No Schema Info
29
+ end
30
+
31
+ schema_information.join(";\n")
32
+ end
33
+ alias_method_chain :dump_schema_information, :plugins
34
+ end
@@ -0,0 +1,12 @@
1
+ ActiveRecord::ConnectionAdapters::SchemaStatements.module_eval do
2
+ def initialize_schema_migrations_table_with_plugins
3
+ initialize_schema_migrations_table_without_plugins
4
+
5
+ begin
6
+ execute "CREATE TABLE #{PluginAWeek::PluginMigrations::Migrator.schema_info_table_name} (plugin_name #{type_to_sql(:string)}, version #{type_to_sql(:integer)})"
7
+ rescue ActiveRecord::StatementInvalid
8
+ # Schema has been initialized
9
+ end
10
+ end
11
+ alias_method_chain :initialize_schema_migrations_table, :plugins
12
+ end
@@ -1,38 +1,6 @@
1
- module ActiveRecord #:nodoc:
2
- module ConnectionAdapters #:nodoc:
3
- module SchemaStatements #:nodoc:
4
- def initialize_schema_information_with_plugins
5
- initialize_schema_information_without_plugins
6
-
7
- begin
8
- execute "CREATE TABLE #{PluginAWeek::PluginMigrations::Migrator.schema_info_table_name} (plugin_name #{type_to_sql(:string)}, version #{type_to_sql(:integer)})"
9
- rescue ActiveRecord::StatementInvalid
10
- # Schema has been initialized
11
- end
12
- end
13
- alias_method_chain :initialize_schema_information, :plugins
14
-
15
- def dump_schema_information_with_plugins
16
- schema_information = []
17
-
18
- dump = dump_schema_information_without_plugins
19
- schema_information << dump if dump
20
-
21
- begin
22
- plugins = ActiveRecord::Base.connection.select_all("SELECT * FROM #{PluginAWeek::PluginMigrations::Migrator.schema_info_table_name}")
23
- plugins.each do |plugin|
24
- if (version = plugin['version'].to_i) > 0
25
- plugin_name = ActiveRecord::Base.quote_value(plugin['plugin_name'])
26
- schema_information << "INSERT INTO #{PluginAWeek::PluginMigrations::Migrator.schema_info_table_name} (plugin_name, version) VALUES (#{plugin_name}, #{version})"
27
- end
28
- end
29
- rescue ActiveRecord::StatementInvalid
30
- # No Schema Info
31
- end
32
-
33
- schema_information.join(";\n")
34
- end
35
- alias_method_chain :dump_schema_information, :plugins
36
- end
37
- end
1
+ dir = File.dirname(__FILE__)
2
+ if ActiveRecord::ConnectionAdapters::SchemaStatements.instance_methods.include?('initialize_schema_information')
3
+ require "#{dir}/1.0/schema_statements"
4
+ else
5
+ require "#{dir}/2.1/schema_statements"
38
6
  end
@@ -10,12 +10,16 @@ module PluginAWeek #:nodoc:
10
10
  # Runs the migrations from a plugin, up (or down) to the version given
11
11
  def migrate_plugin(plugin, version = nil)
12
12
  self.current_plugin = plugin
13
+ if ActiveRecord::Base.connection.respond_to?(:initialize_schema_migrations_table)
14
+ ActiveRecord::Base.connection.initialize_schema_migrations_table
15
+ end
13
16
  migrate(plugin.migration_path, version)
14
17
  end
15
18
 
16
19
  def schema_info_table_name #:nodoc:
17
20
  ActiveRecord::Base.table_name_prefix + 'plugin_schema_info' + ActiveRecord::Base.table_name_suffix
18
21
  end
22
+ alias_method :schema_migrations_table_name, :schema_info_table_name
19
23
 
20
24
  def current_version #:nodoc:
21
25
  result = ActiveRecord::Base.connection.select_one("SELECT version FROM #{schema_info_table_name} WHERE plugin_name = '#{current_plugin.name}'")
@@ -38,6 +42,7 @@ module PluginAWeek #:nodoc:
38
42
  ActiveRecord::Base.connection.update("UPDATE #{self.class.schema_info_table_name} SET version = #{version} WHERE plugin_name = '#{current_plugin.name}'")
39
43
  end
40
44
  end
45
+ alias_method :record_version_state_after_migrating, :set_schema_version
41
46
  end
42
47
  end
43
48
  end
@@ -0,0 +1,8 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/plugin_templates/action_controller"
3
+ if Desert::VersionChecker.rails_version_is_below_rc2?
4
+ require "#{dir}/plugin_templates/1.2.0/action_mailer"
5
+ else
6
+ require "#{dir}/plugin_templates/2.0.0/action_mailer"
7
+ end
8
+ require "#{dir}/plugin_templates/action_view"
@@ -0,0 +1,10 @@
1
+ dir = File.dirname(__FILE__)
2
+ if Desert::VersionChecker.rails_version_is_below_1990?
3
+ require "#{dir}/rails/1.2.0/initializer"
4
+ else
5
+ require "#{dir}/rails/2.0.0/plugin"
6
+ end
7
+ require "#{dir}/rails/dependencies"
8
+ require "#{dir}/rails/migration"
9
+
10
+ require "#{dir}/rails/route_set"
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/ruby/object"
@@ -0,0 +1,8 @@
1
+ module Desert
2
+ SUPPORTED_RAILS_VERSIONS = {
3
+ "1.2.5" => {'version' => '1.2.5', 'git_tag' => 'v1.2.5'},
4
+ "1.99.0" => {'version' => '1.99.0', 'git_tag' => 'v2.0.0_RC1'},
5
+ "2.0.2" => {'version' => '2.0.2', 'git_tag' => 'v2.0.2'},
6
+ "edge" => {'version' => 'edge', 'git_tag' => 'master'},
7
+ }
8
+ end
data/scratch.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "rubygems"
2
+ require "rr"
metadata CHANGED
@@ -1,79 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: desert
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2008-03-18 00:00:00 -07:00
8
- summary: Desert is a component framework for Rails that allows your plugins to be packaged as mini Rails apps.
9
- require_paths:
10
- - lib
11
- email: opensource@pivotallabs.com
12
- homepage: http://pivotallabs.com
13
- rubyforge_project: pivotalrb
14
- description: Desert is a component framework for Rails that allows your plugins to be packaged as mini Rails apps.
15
- autorequire: desert
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.2.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Pivotal Labs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-04-26 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Desert is a component framework for Rails that allows your plugins to be packaged as mini Rails apps.
17
+ email: opensource@pivotallabs.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGES
31
25
  files:
26
+ - Rakefile
32
27
  - CHANGES
33
28
  - MIT-LICENSE
34
29
  - README
35
- - Rakefile
30
+ - scratch.rb
36
31
  - init.rb
37
- - lib/desert.rb
38
- - lib/generators/desert_plugin/templates/routes.rb
39
- - lib/generators/desert_plugin/templates/spec_helper.rb
40
- - lib/generators/desert_plugin/templates/plugin_migration.rb
41
- - lib/generators/desert_plugin/desert_plugin_generator.rb
42
- - lib/desert/plugin_templates/1.x/action_mailer.rb
32
+ - lib/desert/manager.rb
33
+ - lib/desert/version_checker.rb
34
+ - lib/desert/plugin.rb
35
+ - lib/desert/plugin_templates/1.2.0/action_mailer.rb
43
36
  - lib/desert/plugin_templates/action_view.rb
44
- - lib/desert/plugin_templates/2.x/action_mailer.rb
37
+ - lib/desert/plugin_templates/2.0.0/action_mailer.rb
45
38
  - lib/desert/plugin_templates/action_controller.rb
46
- - lib/desert/manager.rb
47
- - lib/desert/rails/1.x/initializer.rb
48
- - lib/desert/rails/migration.rb
49
- - lib/desert/rails/migrator.rb
50
- - lib/desert/rails/2.x/plugin.rb
39
+ - lib/desert/rails.rb
40
+ - lib/desert/supported_rails_versions.rb
41
+ - lib/desert/plugin_migrations/migrator.rb
42
+ - lib/desert/plugin_migrations/extensions/2.1/schema_statements.rb
43
+ - lib/desert/plugin_migrations/extensions/1.0/schema_statements.rb
44
+ - lib/desert/plugin_migrations/extensions/schema_statements.rb
45
+ - lib/desert/rails/1.2.0/initializer.rb
46
+ - lib/desert/rails/2.0.0/plugin.rb
51
47
  - lib/desert/rails/route_set.rb
48
+ - lib/desert/rails/migration.rb
52
49
  - lib/desert/rails/dependencies.rb
53
- - lib/desert/version_checker.rb
50
+ - lib/desert/plugin_templates.rb
51
+ - lib/desert/plugin_migrations.rb
52
+ - lib/desert/ruby.rb
54
53
  - lib/desert/ruby/object.rb
55
- - lib/desert/plugin_migrations/migrator.rb
56
- - lib/desert/plugin_migrations/extensions/schema_statements.rb
57
- - lib/desert/plugin.rb
58
- - lib/generators/desert_plugin
59
- - lib/generators/desert_plugin/templates
60
- - lib/generators/desert_plugin/templates/empty_file
61
- - lib/generators/desert_plugin/USAGE
62
- test_files: []
63
-
54
+ - lib/desert.rb
55
+ has_rdoc: true
56
+ homepage: http://pivotallabs.com
57
+ post_install_message:
64
58
  rdoc_options:
65
59
  - --main
66
60
  - README
67
61
  - --inline-source
68
62
  - --line-numbers
69
- extra_rdoc_files:
70
- - README
71
- - CHANGES
72
- executables: []
73
-
74
- extensions: []
75
-
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
76
77
  requirements: []
77
78
 
78
- dependencies: []
79
+ rubyforge_project: pivotalrb
80
+ rubygems_version: 1.1.0
81
+ signing_key:
82
+ specification_version: 2
83
+ summary: Desert is a component framework for Rails that allows your plugins to be packaged as mini Rails apps.
84
+ test_files: []
79
85
 
@@ -1,14 +0,0 @@
1
- class ActiveRecord::Migrator
2
- module DesertMigrator
3
- def latest_version
4
- return 0 if migration_classes.empty?
5
- migration_classes.last.first
6
- end
7
-
8
- def migration_classes_with_caching
9
- @migration_classes ||= migration_classes_without_caching
10
- end
11
- end
12
- include DesertMigrator
13
- alias_method_chain :migration_classes, :caching
14
- end
@@ -1,14 +0,0 @@
1
- NAME
2
- desert_plugin - creates a directory structure and starter files for a new desert plugin
3
-
4
- SYNOPSIS
5
- desert_plugin [plugin name]
6
-
7
- DESCRIPTION
8
- |-- vendor
9
- `-- plugins
10
- `-- [plugin name]
11
-
12
- EXAMPLE
13
- ./script/generate desert_plugin spiffy
14
-
@@ -1,40 +0,0 @@
1
- class DesertPluginGenerator < Rails::Generator::NamedBase
2
- def manifest
3
- record do |m|
4
- m.directory "vendor/plugins/#{file_name}"
5
-
6
- m.directory "vendor/plugins/#{file_name}/app"
7
- m.directory "vendor/plugins/#{file_name}/app/controllers"
8
- m.directory "vendor/plugins/#{file_name}/app/helpers"
9
- m.directory "vendor/plugins/#{file_name}/app/models"
10
- m.directory "vendor/plugins/#{file_name}/app/views"
11
-
12
- m.directory "vendor/plugins/#{file_name}/config"
13
- m.template "routes.rb", "vendor/plugins/#{file_name}/config/routes.rb"
14
- map_route_from_plugin(m)
15
-
16
- m.directory "vendor/plugins/#{file_name}/db"
17
- m.directory "vendor/plugins/#{file_name}/db/migrate"
18
- m.template "plugin_migration.rb", "vendor/plugins/#{file_name}/db/migrate/001_init_#{file_name}_plugin.rb"
19
-
20
- m.directory "vendor/plugins/#{file_name}/lib"
21
-
22
- m.directory "vendor/plugins/#{file_name}/spec"
23
- m.directory "vendor/plugins/#{file_name}/spec/controllers"
24
- m.directory "vendor/plugins/#{file_name}/spec/fixtures"
25
- m.directory "vendor/plugins/#{file_name}/spec/models"
26
- m.directory "vendor/plugins/#{file_name}/spec/views"
27
- m.file "spec_helper.rb", "vendor/plugins/#{file_name}/spec/spec_helper.rb"
28
-
29
- m.file "empty_file", "vendor/plugins/#{file_name}/init.rb"
30
- end
31
- end
32
-
33
- def map_route_from_plugin(m)
34
- logger.route "adding map.routes_from_plugin(:#{file_name}) to top of routes.rb"
35
- sentinel = 'ActionController::Routing::Routes.draw do |map|'
36
- m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
37
- "#{match}\n map.routes_from_plugin(:#{file_name})\n"
38
- end
39
- end
40
- end
File without changes
@@ -1,11 +0,0 @@
1
- class Init<%= class_name %>Plugin < ActiveRecord::Migration
2
- def self.up
3
- create_table "<%= plural_name %>", :force => true do |t|
4
- t.column "some_<%= file_name %>_column", :string
5
- end
6
- end
7
-
8
- def self.down
9
- drop_table :<%= plural_name %>
10
- end
11
- end
@@ -1 +0,0 @@
1
- resources :<%= plural_name %>
@@ -1,8 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
3
- require 'spec'
4
- require 'spec/rails'
5
-
6
- Spec::Runner.configure do |config|
7
- config.fixture_path = "#{File.dirname(__FILE__)}/../spec/fixtures"
8
- end