simple_worker 0.5.6 → 0.5.8
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/README.markdown +1 -1
- data/lib/simple_worker/base.rb +8 -2
- data/lib/simple_worker/service.rb +7 -6
- data/test/awesome_job.rb +2 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -225,7 +225,7 @@ uploaded separately and treated as distinctly separate workers.
|
|
225
225
|
Merging Gems
|
226
226
|
---------------------
|
227
227
|
|
228
|
-
This allows you to use any gem you'd like with SimpleWorker.
|
228
|
+
This allows you to use any gem you'd like with SimpleWorker. This uses the same syntax as bundler gem files.
|
229
229
|
|
230
230
|
merge_gem "some_gem"
|
231
231
|
merge_gem "some_gem_with_version", "1.2.3"
|
data/lib/simple_worker/base.rb
CHANGED
@@ -66,8 +66,14 @@ module SimpleWorker
|
|
66
66
|
|
67
67
|
# merges the specified gem.
|
68
68
|
def merge_gem(gem_name, version=nil)
|
69
|
-
|
70
|
-
|
69
|
+
gem_info = {:name=>gem_name}
|
70
|
+
if version.is_a?(Hash)
|
71
|
+
gem_info.merge!(version)
|
72
|
+
else
|
73
|
+
gem_info[:version] = version
|
74
|
+
end
|
75
|
+
@merged_gems << gem_info
|
76
|
+
require gem_info[:require] || gem_name
|
71
77
|
end
|
72
78
|
|
73
79
|
# merges the specified files.
|
@@ -70,18 +70,19 @@ module SimpleWorker
|
|
70
70
|
"class_name"=>class_name,
|
71
71
|
"file_name"=> File.basename(filename)
|
72
72
|
}
|
73
|
-
puts 'options for upload=' + options.inspect
|
73
|
+
#puts 'options for upload=' + options.inspect
|
74
74
|
ret = post_file("code/put", File.new(zip_filename), options)
|
75
75
|
ret
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
def get_gem_path(
|
80
|
-
gem_name =(
|
81
|
-
puts "Searching #{gem_name}"
|
79
|
+
def get_gem_path(gem_info)
|
80
|
+
gem_name =(gem_info[:require] || gem_info[:name].match(/^[a-zA-Z0-9\-_]+/)[0])
|
81
|
+
puts "Searching for #{gem_name}..."
|
82
82
|
searcher = Gem::GemPathSearcher.new
|
83
83
|
gems = searcher.find_all(gem_name)
|
84
|
-
|
84
|
+
# puts 'gems found=' + gems.inspect
|
85
|
+
gems = gems.select { |g| g.version.version==gem_info[:version] } if gem_info[:version]
|
85
86
|
if !gems.empty?
|
86
87
|
gem = gems.first
|
87
88
|
gem.full_gem_path + "/lib"
|
@@ -125,7 +126,7 @@ module SimpleWorker
|
|
125
126
|
if merged_gems
|
126
127
|
merged_gems.each do |gem|
|
127
128
|
# puts 'gem=' + gem.inspect
|
128
|
-
path = get_gem_path(gem
|
129
|
+
path = get_gem_path(gem)
|
129
130
|
if path
|
130
131
|
puts "Collecting gem #{path}"
|
131
132
|
Dir["#{path}/**/**"].each do |file|
|
data/test/awesome_job.rb
CHANGED