plugems 1.1.2 → 1.1.5

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.
Files changed (6) hide show
  1. data/CHANGELOG +19 -0
  2. data/README +45 -0
  3. data/init.rb +1 -1
  4. data/lib/plugems.rb +1 -1
  5. data/lib/plugems/loader.rb +133 -131
  6. metadata +4 -2
@@ -0,0 +1,19 @@
1
+ rel_1_1_5:
2
+ date: 2007-06-12
3
+ notes:
4
+ - Fixed requiring of plugem name file for plugins only if it exists
5
+
6
+ rel_1_1_2:
7
+ date: 2007-05-02
8
+ notes:
9
+ - Added the rails version validation since it is not compatible with edge
10
+
11
+ rel_1_1_1:
12
+ date: 2007-05-02
13
+ notes:
14
+ - Added support for lower and upper version limit specifications
15
+
16
+ rel_1_1_0:
17
+ date: 2007-05-01
18
+ notes:
19
+ - Initial Drop
data/README CHANGED
@@ -0,0 +1,45 @@
1
+ = Introduction
2
+
3
+ One sentence summary: "Everything is a gem, most things work from within the gem, and all dependencies are accounted for."
4
+
5
+ More details can be found on http://revolutiononrails.blogspot.com/2007/05/release-plugems-runtime.html
6
+
7
+ = Installation Guide:
8
+
9
+ == Install it on your box:
10
+
11
+ As a gem:
12
+ gem install plugems
13
+
14
+ == Create your plugem configuration:
15
+
16
+ Add config/manifest.yml describing your plugem and its dependencies:
17
+
18
+ :version: [1, 0]
19
+ :name: "cool_application"
20
+ :description: "My First Plugemified Application"
21
+ :dependencies:
22
+ - ['some_gem', '~> 1.0']
23
+ - ['other_gem', '> 2.0']
24
+ - ['one_more', '2.0.1']
25
+
26
+
27
+ == Bootstrap the plugems:
28
+
29
+ Add the plugems requirement to config/boot.rb at the bottom right before the initializer call:
30
+
31
+ # Add this line:
32
+ require_gem 'plugems', '~> 1.0'
33
+
34
+ Rails::Initializer.run(:set_load_path)
35
+ end
36
+
37
+
38
+ = License
39
+
40
+ Plugems released under the MIT license.
41
+
42
+
43
+ = Support
44
+
45
+ The plugin RubyForge page is http://rubyforge.org/projects/plugems
data/init.rb CHANGED
@@ -1 +1 @@
1
- require 'plugems'
1
+ require 'plugems' unless defined? Plugems
@@ -1,5 +1,5 @@
1
1
  module RailsVersionVerifier
2
- ver = Rails::VERSION::STRING.split('.').map(&:to_i).extend(Comparable)
2
+ ver = Rails::VERSION::STRING.split('.').collect(&:to_i).extend(Comparable)
3
3
  fail("The rails version #{ Rails::VERSION::STRING } is not supported by plugems") unless (ver >= [1,1,6] && ver <= [1,2,3])
4
4
  end
5
5
  # Rails 1.1.16 is not very extensible in how it loads rake tasks.
@@ -5,23 +5,23 @@ require 'plugems/tasks/loader'
5
5
  require 'plugems/plugem_view_support.rb'
6
6
 
7
7
  module Plugems
8
- class Loader
8
+ class Loader
9
9
 
10
10
  module ClassMethods
11
-
12
- def load(configuration)
13
- # TODO find a way to get the plugin_paths defined in the Rails::Initializer block, if any
14
- #@@configuration = configuration
15
- @@loaded_plugems = {} # hash of all loaded plugems, to prevent loading duplicates
16
-
17
- manifest = Plugems::Manifest.load("#{RAILS_ROOT}/config/manifest.yml")
18
- load_plugems(manifest)
19
- set_dependencies_loaded_flag
20
- end
21
-
22
- def gem_rake_tasks
23
- (@@gem_rake_tasks ||= []).flatten.uniq
24
- end
11
+
12
+ def load(configuration)
13
+ # TODO find a way to get the plugin_paths defined in the Rails::Initializer block, if any
14
+ #@@configuration = configuration
15
+ @@loaded_plugems = {} # hash of all loaded plugems, to prevent loading duplicates
16
+
17
+ manifest = Plugems::Manifest.load("#{RAILS_ROOT}/config/manifest.yml")
18
+ load_plugems(manifest)
19
+ set_dependencies_loaded_flag
20
+ end
21
+
22
+ def gem_rake_tasks
23
+ (@@gem_rake_tasks ||= []).flatten.uniq
24
+ end
25
25
 
26
26
  def gem_views
27
27
  (@@gem_views ||= []).flatten.uniq
@@ -29,125 +29,127 @@ module Plugems
29
29
 
30
30
  def plugin_views
31
31
  plugin_lib_paths.collect do |plugin_path|
32
- Dir["#{plugin_path}/views/**/*.*"]
32
+ Dir["#{plugin_path}/views/**/*.*"]
33
33
  end.flatten.uniq
34
34
  end
35
-
35
+
36
36
  def plugin?(name)
37
37
  (path = plugin_path(name)) && File.directory?(path)
38
- end
39
-
40
- def load_as_plugin(name)
41
- path = plugin_path(name)
42
- plugin_lib = File.join(path, "lib")
43
- $: << plugin_lib if File.exist?(plugin_lib)
38
+ end
39
+
40
+ def load_as_plugin(gem)
41
+ debug "Plugin #{gem}"
42
+ path = plugin_path(gem)
43
+ plugin_lib = File.join(path, "lib")
44
+ $: << plugin_lib if File.exist?(plugin_lib)
44
45
  process_plugin_manifest(path)
45
- end
46
-
47
- private
48
-
49
- def plugin_lib_paths
50
- # TODO determine if the configuration object is already configured by this point
51
- Rails::Configuration.new.plugin_paths.collect do |plugin_path|
52
- # Cant use Dir["foo/**/lib"] because symlinks are not followed with Dir
53
- Dir["#{plugin_path}/*"].collect { |plugin_lib| plugin_lib}
54
- end.flatten.uniq
55
- end
56
-
57
- def load_plugems(manifest)
58
- # after loading the gem specific dependencies require
59
- # each file picking up gems and plugins. This is loaded outside the above loop
60
- # incase of a dependency cycle...
61
- manifest.dependencies.each do |name, version|
62
- load_plugem(name, version || ">= 0.0.0")
63
- end
64
- end
65
-
66
- def load_plugem(name, version)
67
- return if @@loaded_plugems.include?(name)
68
- debug "Loading #{name}..."
69
- if plugin?(name)
70
- load_as_plugin(name)
71
- else
72
- load_as_gem(name,version)
73
- end
74
- debug "Loaded #{name}!"
75
- @@loaded_plugems[name] = true
76
- end
77
-
78
- def plugin_path(gem_or_plugin)
79
- name = gem_or_plugin.respond_to?(:name) ? gem_or_plugin.name : gem_or_plugin
80
- plugin_lib_paths.grep(/\/#{name}$/).first
81
- end
82
-
83
- def process_plugin_manifest(path)
84
- plugin_manifest_file = File.join(path, "config", "manifest.yml")
85
- if File.exists?(plugin_manifest_file)
86
- plugin_manifest = Plugems::Manifest.load(plugin_manifest_file)
87
- load_plugems(plugin_manifest)
88
- end
89
- end
90
-
91
- def load_as_gem(name, *version)
92
-
93
- begin
94
-
95
- require_gem name, *(version.flatten)
96
-
97
- path = gem_path(name)
98
- append_rake_tasks!(path)
99
- append_gem_views!(path)
100
-
101
- debug "#{name} - Found: (#{loaded_version(name)})"
102
- rescue Gem::LoadError, Gem::Exception => gem_load_error
103
- error "#{gem_load_error}"
104
- error "#{name} - Searching: (#{version.join(' && ')}), but found: (#{loaded_version(name)})"
105
- error "use BOOT_DEBUG=true to show more information."
106
- exit(1)
107
- rescue Exception => error
108
- error "#{error}"
109
- error.backtrace.each do |stacktrace|
110
- error " #{stacktrace}"
111
- end
112
- exit(1)
113
- end
114
-
115
- end
116
-
117
- def loaded_version(gem_name)
118
- gem_path(gem_name).split('/').grep(/#{gem_name}/).first[/[\d\.]+$/] rescue "Not Found"
119
- end
120
-
121
- def gem_path(gem_name)
122
- File.dirname($:.grep(%r{/gems/#{gem_name}-\d}).first)
123
- end
124
-
125
- def debug(msg)
126
- puts "[Plugems Debug]: #{msg}" if ENV['BOOT_DEBUG']
127
- end
128
-
129
- def error(msg)
130
- puts "[Plugems Error]: #{msg}"
131
- end
132
-
133
- def set_dependencies_loaded_flag
134
- # TODO: fix rhg_configuration to use Rails::Initializer.all_dependencies_loaded?
135
- Object.const_set('DEPENDENCIES_LOADED', true) unless defined?(DEPENDENCIES_LOADED)
136
- end
137
-
138
- def append_gem_views!(path)
139
- views = Dir["#{path}/views/**/*.*"]
140
- (@@gem_views ||= []) << views unless views.blank?
141
- end
142
-
143
- def append_rake_tasks!(path)
144
- tasks = Dir["#{path}/tasks/**/*.rake"].reject {|tsk| tsk=~/bootstrap|rails/}
145
- (@@gem_rake_tasks ||= []) << tasks unless tasks.blank?
146
- end
147
-
148
- end
149
-
150
- extend ClassMethods
151
-
152
- end
46
+ require_gem_file(gem)
47
+ end
48
+
49
+ private
50
+
51
+ def plugin_lib_paths
52
+ # TODO determine if the configuration object is already configured by this point
53
+ #(@config ||= Rails::Configuration.new).plugin_paths.collect do |plugin_path|
54
+ # Cant use Dir["foo/**/lib"] because symlinks are not followed with Dir
55
+ Dir["#{RAILS_ROOT}/vendor/plugins/*"].collect { |plugin_lib| plugin_lib}.flatten.uniq
56
+ #end.flatten.uniq
57
+ end
58
+
59
+ def load_plugems(manifest)
60
+ # after loading the gem specific dependencies require
61
+ # each file picking up gems and plugins. This is loaded outside the above loop
62
+ # incase of a dependency cycle...
63
+ manifest.dependencies.each do |name, version|
64
+ load_plugem(name, version || ">= 0.0.0")
65
+ end
66
+ end
67
+
68
+ def load_plugem(name, version)
69
+ return if @@loaded_plugems.include?(name)
70
+ debug " Looking for #{name} with #{version}..."
71
+ if plugin?(name)
72
+ load_as_plugin(name)
73
+ else
74
+ load_as_gem(name,version)
75
+ end
76
+ @@loaded_plugems[name] = true
77
+ end
78
+
79
+ def require_gem_file(gem_or_plugin)
80
+ name = gem_or_plugin.respond_to?(:name) ? gem_or_plugin.name : gem_or_plugin
81
+ file = File.join(plugin_path(gem_or_plugin), "lib", name + '.rb')
82
+ if File.exist?(file)
83
+ require file
84
+ debug "Requiring '#{ file }.rb'"
85
+ end
86
+ end
87
+
88
+ def plugin_path(gem_or_plugin)
89
+ name = gem_or_plugin.respond_to?(:name) ? gem_or_plugin.name : gem_or_plugin
90
+ plugin_lib_paths.grep(/\/#{name}$/).first
91
+ end
92
+
93
+ def process_plugin_manifest(path)
94
+ plugin_manifest_file = File.join(path, "config", "manifest.yml")
95
+ debug "Manifest: #{plugin_manifest_file}"
96
+ if File.exists?(plugin_manifest_file)
97
+ plugin_manifest = Plugems::Manifest.load(plugin_manifest_file)
98
+ load_plugems(plugin_manifest)
99
+ end
100
+ end
101
+
102
+ def load_as_gem(name, version)
103
+ debug "Gem: #{name}"
104
+
105
+ begin
106
+ gem = Gem.cache.search(/^#{name}$/, version).last rescue nil #RubyGems api specifies that the result is sorted by version
107
+ raise Gem::LoadError unless gem
108
+ require_gem gem.name, gem.version.version
109
+ append_rake_tasks!(gem.full_gem_path)
110
+ append_gem_views!(gem.full_gem_path)
111
+
112
+ debug "Gem: #{name} - Found: (#{gem.version.version})"
113
+ rescue Gem::LoadError, Gem::Exception => gem_load_error
114
+ error "#{name} - Searching: (#{version}), but found: (#{gem.version.version rescue "Unknown"})"
115
+ error "#{gem_load_error}"
116
+ error "use BOOT_DEBUG=true to show more information."
117
+ exit(1)
118
+ rescue Exception => error
119
+ error "#{error}"
120
+ error.backtrace[0..8].each do |stacktrace|
121
+ error " #{stacktrace}"
122
+ end
123
+ exit(1)
124
+ end
125
+
126
+ end
127
+
128
+ def debug(msg)
129
+ puts "[Plugems Debug]: #{msg}" if ENV['BOOT_DEBUG']
130
+ end
131
+
132
+ def error(msg)
133
+ puts "[Plugems Error]: #{msg}"
134
+ end
135
+
136
+ def set_dependencies_loaded_flag
137
+ # TODO: fix rhg_configuration to use Rails::Initializer.all_dependencies_loaded?
138
+ Object.const_set('DEPENDENCIES_LOADED', true) unless defined?(DEPENDENCIES_LOADED)
139
+ end
140
+
141
+ def append_gem_views!(path)
142
+ views = Dir["#{path}/views/**/*.*"]
143
+ (@@gem_views ||= []) << views unless views.blank?
144
+ end
145
+
146
+ def append_rake_tasks!(path)
147
+ tasks = Dir["#{path}/tasks/**/*.rake"].reject {|tsk| tsk=~/bootstrap|rails/}
148
+ (@@gem_rake_tasks ||= []) << tasks unless tasks.blank?
149
+ end
150
+
151
+ end
152
+
153
+ extend ClassMethods
154
+ end
153
155
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: plugems
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.2
7
- date: 2007-05-02 00:00:00 -04:00
6
+ version: 1.1.5
7
+ date: 2007-06-12 00:00:00 -04:00
8
8
  summary: Dependency-management framework built on top of Ruby On Rails
9
9
  require_paths:
10
10
  - lib
@@ -42,6 +42,7 @@ files:
42
42
  - config/manifest.yml
43
43
  - README
44
44
  - MIT-LICENSE
45
+ - CHANGELOG
45
46
  test_files: []
46
47
 
47
48
  rdoc_options: []
@@ -49,6 +50,7 @@ rdoc_options: []
49
50
  extra_rdoc_files:
50
51
  - README
51
52
  - MIT-LICENSE
53
+ - CHANGELOG
52
54
  executables: []
53
55
 
54
56
  extensions: []