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.
- data/CHANGELOG +19 -0
- data/README +45 -0
- data/init.rb +1 -1
- data/lib/plugems.rb +1 -1
- data/lib/plugems/loader.rb +133 -131
- metadata +4 -2
data/CHANGELOG
ADDED
@@ -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
|
data/lib/plugems.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module RailsVersionVerifier
|
2
|
-
ver = Rails::VERSION::STRING.split('.').
|
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.
|
data/lib/plugems/loader.rb
CHANGED
@@ -5,23 +5,23 @@ require 'plugems/tasks/loader'
|
|
5
5
|
require 'plugems/plugem_view_support.rb'
|
6
6
|
|
7
7
|
module Plugems
|
8
|
-
|
8
|
+
class Loader
|
9
9
|
|
10
10
|
module ClassMethods
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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.
|
7
|
-
date: 2007-
|
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: []
|