desert 0.3.2 → 0.3.3

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,10 @@
1
+ 0.3.3
2
+ - Fixed [#20770] Can't get specs to run for desert-based plugin bug (http://rubyforge.org/tracker/index.php?func=detail&aid=20770&group_id=6426&atid=24920)
3
+ - Fixed [#21564] Can't see desert rake tasks (http://rubyforge.org/tracker/index.php?func=detail&aid=21564&group_id=6426&atid=24920)
4
+ - Renamed plugin_schema_info to plugin_schema_migrations when using Rails >= 2.1
5
+ - Migrater#migrated are now properly implemented for plugin_schema_migrations for Rails >= 2.1.0
6
+
7
+ 0.3.2
1
8
  - Fixed exception in testspec.rake when rspec is not loaded
2
9
  - Fix template loading on Edge Rails and on Rails 2.1.0
3
10
 
@@ -26,4 +33,4 @@
26
33
 
27
34
  0.1.0
28
35
  - Fixed [#13346] ActionController::Base.helper raises error when helper is only in plugin
29
- - Desert does not require files that have been required before Desert was loaded
36
+ - Desert does not require files that have been required before Desert was loaded
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.3.2"
29
+ PKG_VERSION = "0.3.3"
30
30
  PKG_FILES = FileList[
31
31
  '[A-Z]*',
32
32
  '*.rb',
@@ -1,3 +1,11 @@
1
+ dir = File.dirname(__FILE__)
2
+
1
3
  dir = File.dirname(__FILE__)
2
4
  require "#{dir}/plugin_migrations/migrator"
3
- require "#{dir}/plugin_migrations/extensions/schema_statements"
5
+ if ActiveRecord::ConnectionAdapters::SchemaStatements.instance_methods.include?('initialize_schema_information')
6
+ require "#{dir}/plugin_migrations/1.2/migrator"
7
+ require "#{dir}/plugin_migrations/1.2/extensions/schema_statements"
8
+ else
9
+ require "#{dir}/plugin_migrations/2.1/migrator"
10
+ require "#{dir}/plugin_migrations/2.1/extensions/schema_statements"
11
+ end
@@ -0,0 +1,33 @@
1
+ module Desert #:nodoc:
2
+ module PluginMigrations
3
+ class Migrator < ActiveRecord::Migrator
4
+ class << self
5
+ def current_version #:nodoc:
6
+ result = ActiveRecord::Base.connection.select_one("SELECT version FROM #{schema_info_table_name} WHERE plugin_name = '#{current_plugin.name}'")
7
+ if result
8
+ result['version'].to_i
9
+ else
10
+ # There probably isn't an entry for this plugin in the migration info table.
11
+ 0
12
+ end
13
+ end
14
+ end
15
+
16
+ def set_schema_version(version)
17
+ version = down? ? version.to_i - 1 : version.to_i
18
+
19
+ if ActiveRecord::Base.connection.select_one("SELECT version FROM #{self.class.schema_info_table_name} WHERE plugin_name = '#{current_plugin.name}'").nil?
20
+ # We need to create the entry since it doesn't exist
21
+ ActiveRecord::Base.connection.execute("INSERT INTO #{self.class.schema_info_table_name} (version, plugin_name) VALUES (#{version},'#{current_plugin.name}')")
22
+ else
23
+ ActiveRecord::Base.connection.update("UPDATE #{self.class.schema_info_table_name} SET version = #{version} WHERE plugin_name = '#{current_plugin.name}'")
24
+ end
25
+ end
26
+
27
+ def migrated
28
+ current_plugin_version = self.class.current_version
29
+ (1..current_plugin_version).to_a
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
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 #{Desert::PluginMigrations::Migrator.schema_migrations_table_name} (plugin_name #{type_to_sql(:string)}, version #{type_to_sql(:string)})"
7
+ plugins_and_versions = select_all("SELECT plugin_name, version from #{Desert::PluginMigrations::Migrator.schema_info_table_name}")
8
+ plugins_and_versions.each do |plugin_data|
9
+ plugin_name, version = plugin_data["plugin_name"], plugin_data["version"]
10
+ plugin = Desert::Manager.find_plugin(plugin_name)
11
+ migration_versions = Dir["#{plugin.migration_path}/*.rb"].map do |path|
12
+ File.basename(path, ".rb")
13
+ end.select do |migration|
14
+ Integer(migration.split("_").first) <= Integer(version)
15
+ end
16
+ migration_versions.each do |migration_version|
17
+ insert_sql = ActiveRecord::Base.send(:sanitize_sql, [
18
+ "INSERT INTO #{Desert::PluginMigrations::Migrator.schema_migrations_table_name}(plugin_name, version) VALUES(?, ?)",
19
+ plugin_name,
20
+ Integer(migration_version.split("_").first)
21
+ ])
22
+ execute insert_sql
23
+ end
24
+ end
25
+ rescue ActiveRecord::StatementInvalid
26
+ # Schema has been initialized
27
+ end
28
+ end
29
+ alias_method_chain :initialize_schema_migrations_table, :plugins
30
+ end
@@ -0,0 +1,35 @@
1
+ module Desert #:nodoc:
2
+ module PluginMigrations
3
+ class Migrator < ActiveRecord::Migrator
4
+ class << self
5
+ def current_version #:nodoc:
6
+ result = ActiveRecord::Base.connection.select_one("SELECT version FROM #{schema_migrations_table_name} WHERE plugin_name = '#{current_plugin.name}' order by version desc")
7
+ if result
8
+ result['version'].to_i
9
+ else
10
+ # There probably isn't an entry for this plugin in the migration info table.
11
+ 0
12
+ end
13
+ end
14
+
15
+ def get_all_versions
16
+ ActiveRecord::Base.connection.select_values("SELECT version FROM #{schema_migrations_table_name} where plugin_name='#{current_plugin.name}'").map(&:to_i).sort
17
+ end
18
+ end
19
+
20
+ def record_version_state_after_migrating(version)
21
+ sm_table = self.class.schema_migrations_table_name
22
+
23
+ if down?
24
+ ActiveRecord::Base.connection.update("DELETE FROM #{sm_table} WHERE version = '#{version}' WHERE plugin_name = '#{current_plugin.name}'")
25
+ else
26
+ ActiveRecord::Base.connection.insert("INSERT INTO #{sm_table} (plugin_name, version) VALUES ('#{current_plugin.name}', '#{version}')")
27
+ end
28
+ end
29
+
30
+ def migrated
31
+ self.class.get_all_versions
32
+ end
33
+ end
34
+ end
35
+ end
@@ -19,36 +19,11 @@ module Desert #:nodoc:
19
19
  def schema_info_table_name #:nodoc:
20
20
  ActiveRecord::Base.table_name_prefix + 'plugin_schema_info' + ActiveRecord::Base.table_name_suffix
21
21
  end
22
- alias_method :schema_migrations_table_name, :schema_info_table_name
23
-
24
- def current_version #:nodoc:
25
- result = ActiveRecord::Base.connection.select_one("SELECT version FROM #{schema_info_table_name} WHERE plugin_name = '#{current_plugin.name}'")
26
- if result
27
- result['version'].to_i
28
- else
29
- # There probably isn't an entry for this plugin in the migration info table.
30
- 0
31
- end
22
+
23
+ def schema_migrations_table_name
24
+ ActiveRecord::Base.table_name_prefix + 'plugin_schema_migrations' + ActiveRecord::Base.table_name_suffix
32
25
  end
33
26
  end
34
-
35
- def set_schema_version(version)
36
- version = down? ? version.to_i - 1 : version.to_i
37
-
38
- if ActiveRecord::Base.connection.select_one("SELECT version FROM #{self.class.schema_info_table_name} WHERE plugin_name = '#{current_plugin.name}'").nil?
39
- # We need to create the entry since it doesn't exist
40
- ActiveRecord::Base.connection.execute("INSERT INTO #{self.class.schema_info_table_name} (version, plugin_name) VALUES (#{version},'#{current_plugin.name}')")
41
- else
42
- ActiveRecord::Base.connection.update("UPDATE #{self.class.schema_info_table_name} SET version = #{version} WHERE plugin_name = '#{current_plugin.name}'")
43
- end
44
- end
45
- alias_method :record_version_state_after_migrating, :set_schema_version
46
-
47
-
48
- def migrated
49
- current_plugin_version = self.class.current_version
50
- (1..current_plugin_version).to_a
51
- end
52
27
  end
53
28
  end
54
29
  end
@@ -4,6 +4,8 @@ module Desert
4
4
  "1.99.0" => {'version' => '1.99.0', 'git_tag' => 'v2.0.0_RC1'},
5
5
  "2.0.2" => {'version' => '2.0.2', 'git_tag' => 'v2.0.2'},
6
6
  "2.1.0" => {'version' => '2.1.0', 'git_tag' => 'v2.1.0'},
7
- "edge" => {'version' => 'edge', 'git_tag' => 'master'},
7
+ "2.2.0" => {'version' => '2.2.0', 'git_tag' => 'v2.2.0'},
8
+ "2.2.2" => {'version' => '2.2.2', 'git_tag' => 'v2.2.2'},
9
+ # "edge" => {'version' => 'edge', 'git_tag' => 'master'},
8
10
  }
9
11
  end
@@ -0,0 +1,4 @@
1
+ dir = File.dirname(__FILE__)
2
+ Dir["#{dir}/tasks/*.rake"].each do |file|
3
+ load file
4
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: desert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal Labs
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-13 00:00:00 -07:00
12
+ date: 2008-12-27 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -23,47 +23,49 @@ extra_rdoc_files:
23
23
  - README.rdoc
24
24
  - CHANGES
25
25
  files:
26
- - CHANGES
27
26
  - MIT-LICENSE
28
- - Rakefile
29
27
  - README.rdoc
28
+ - Rakefile
29
+ - CHANGES
30
30
  - init.rb
31
- - lib/desert/manager.rb
32
- - lib/desert/plugin.rb
33
- - lib/desert/plugin_migrations/extensions/1.0/schema_statements.rb
34
- - lib/desert/plugin_migrations/extensions/2.1/schema_statements.rb
35
- - lib/desert/plugin_migrations/extensions/schema_statements.rb
36
- - lib/desert/plugin_migrations/migrator.rb
37
- - lib/desert/plugin_migrations.rb
38
- - lib/desert/plugin_templates/1.2.0/action_mailer.rb
39
- - lib/desert/plugin_templates/1.2.0/action_view.rb
40
- - lib/desert/plugin_templates/1.99.0/action_mailer.rb
41
- - lib/desert/plugin_templates/1.99.0/action_view.rb
42
- - lib/desert/plugin_templates/2.0.0/action_mailer.rb
43
- - lib/desert/plugin_templates/2.0.2/action_view.rb
44
- - lib/desert/plugin_templates/2.1.0/action_view.rb
45
- - lib/desert/plugin_templates/action_controller.rb
46
- - lib/desert/plugin_templates/action_view.rb
47
- - lib/desert/plugin_templates/edge/action_view.rb
31
+ - lib/desert.rb
48
32
  - lib/desert/plugin_templates.rb
49
- - lib/desert/rails/1.2.0/initializer.rb
50
- - lib/desert/rails/2.0.0/plugin.rb
51
33
  - lib/desert/rails/dependencies.rb
34
+ - lib/desert/rails/2.0.0/plugin.rb
35
+ - lib/desert/rails/1.2.0/initializer.rb
52
36
  - lib/desert/rails/migration.rb
53
37
  - lib/desert/rails/route_set.rb
54
38
  - lib/desert/rails.rb
39
+ - lib/desert/manager.rb
40
+ - lib/desert/plugin_migrations.rb
55
41
  - lib/desert/ruby/object.rb
56
- - lib/desert/ruby.rb
57
42
  - lib/desert/supported_rails_versions.rb
43
+ - lib/desert/ruby.rb
58
44
  - lib/desert/version_checker.rb
59
- - lib/desert.rb
45
+ - lib/desert/tasks.rb
46
+ - lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb
47
+ - lib/desert/plugin_migrations/2.1/migrator.rb
48
+ - lib/desert/plugin_migrations/1.2/extensions/schema_statements.rb
49
+ - lib/desert/plugin_migrations/1.2/migrator.rb
50
+ - lib/desert/plugin_migrations/migrator.rb
51
+ - lib/desert/plugin.rb
52
+ - lib/desert/plugin_templates/edge/action_view.rb
53
+ - lib/desert/plugin_templates/action_controller.rb
54
+ - lib/desert/plugin_templates/1.99.0/action_mailer.rb
55
+ - lib/desert/plugin_templates/1.99.0/action_view.rb
56
+ - lib/desert/plugin_templates/2.0.0/action_mailer.rb
57
+ - lib/desert/plugin_templates/2.1.0/action_view.rb
58
+ - lib/desert/plugin_templates/2.0.2/action_view.rb
59
+ - lib/desert/plugin_templates/action_view.rb
60
+ - lib/desert/plugin_templates/1.2.0/action_mailer.rb
61
+ - lib/desert/plugin_templates/1.2.0/action_view.rb
60
62
  - generators/desert_plugin
61
- - generators/desert_plugin/desert_plugin_generator.rb
62
63
  - generators/desert_plugin/templates
63
- - generators/desert_plugin/templates/empty_file
64
- - generators/desert_plugin/templates/plugin_migration.rb
65
64
  - generators/desert_plugin/templates/routes.rb
65
+ - generators/desert_plugin/templates/plugin_migration.rb
66
66
  - generators/desert_plugin/templates/spec_helper.rb
67
+ - generators/desert_plugin/templates/empty_file
68
+ - generators/desert_plugin/desert_plugin_generator.rb
67
69
  - generators/desert_plugin/USAGE
68
70
  has_rdoc: true
69
71
  homepage: http://pivotallabs.com
@@ -90,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
92
  requirements: []
91
93
 
92
94
  rubyforge_project: pivotalrb
93
- rubygems_version: 1.2.0
95
+ rubygems_version: 1.3.1
94
96
  signing_key:
95
97
  specification_version: 2
96
98
  summary: Desert is a component framework for Rails that allows your plugins to be packaged as mini Rails apps.
@@ -1,12 +0,0 @@
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 #{Desert::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,6 +0,0 @@
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"
6
- end