bee 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/egg/package/egg.yml +2 -2
- data/egg/sinatra/build.yml +9 -9
- data/lib/bee_console.rb +4 -4
- data/lib/bee_task_default.rb +19 -18
- data/lib/bee_task_packagemanager.rb +10 -20
- data/lib/bee_util.rb +82 -4
- data/lib/bee_version.rb +1 -1
- metadata +4 -4
data/README
CHANGED
data/egg/package/egg.yml
CHANGED
@@ -40,8 +40,8 @@
|
|
40
40
|
src: "#{base}/hello/build.erb"
|
41
41
|
dest: "#{here}/#{project_name}/build.yml"
|
42
42
|
- cp:
|
43
|
-
|
44
|
-
dest:
|
43
|
+
src: "#{base}/hello/script.rb"
|
44
|
+
dest: "#{here}/#{project_name}/lib/#{project_name}.rb"
|
45
45
|
- erb:
|
46
46
|
src: "#{base}/hello/launcher.erb"
|
47
47
|
dest: "#{here}/#{project_name}/bin/#{project_name}"
|
data/egg/sinatra/build.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
- build:
|
1
|
+
- build: <%= name %>
|
2
2
|
description: Project <%= name %>
|
3
|
-
default:
|
3
|
+
default: all
|
4
4
|
|
5
5
|
- properties:
|
6
6
|
name: "<%= name %>"
|
@@ -12,20 +12,20 @@
|
|
12
12
|
clean_dirs: [:build]
|
13
13
|
clean_files: ["**/*~", "**/.#*", "**/.DS_Store"]
|
14
14
|
|
15
|
-
- target:
|
15
|
+
- target: run
|
16
16
|
description: Run server
|
17
17
|
script:
|
18
18
|
- "./server.rb"
|
19
19
|
|
20
|
-
- target:
|
20
|
+
- target: call
|
21
21
|
description: Call server
|
22
22
|
script:
|
23
|
-
-
|
23
|
+
- http_get:
|
24
24
|
url: "#{url}/World"
|
25
25
|
prop: response
|
26
26
|
- print: :response
|
27
27
|
|
28
|
-
- target:
|
28
|
+
- target: zip
|
29
29
|
description: Generate a ZIP archive
|
30
30
|
script:
|
31
31
|
- mkdir: :build
|
@@ -34,12 +34,12 @@
|
|
34
34
|
prefix: :zip_prefix
|
35
35
|
dest: :zip_file
|
36
36
|
|
37
|
-
- target:
|
37
|
+
- target: clean
|
38
38
|
description: Clean generated files
|
39
39
|
script:
|
40
40
|
- rmdir: :clean_dirs
|
41
41
|
- rm: :clean_files
|
42
42
|
|
43
|
-
- target:
|
44
|
-
depends:
|
43
|
+
- target: all
|
44
|
+
depends: [clean, zip]
|
45
45
|
description: Generate the whole project
|
data/lib/bee_console.rb
CHANGED
@@ -46,8 +46,8 @@ Usage: bee [options] [targets]
|
|
46
46
|
-l Print bee logo on console.
|
47
47
|
-a Print list of available targets.
|
48
48
|
-o Print list of available options.
|
49
|
-
-
|
50
|
-
-
|
49
|
+
-x Print list of available tasks.
|
50
|
+
-y Print list of available templates.
|
51
51
|
targets Targets to run (default target if omitted).
|
52
52
|
EOF
|
53
53
|
# Options descriptions.
|
@@ -239,9 +239,9 @@ EOF
|
|
239
239
|
rescue Exception
|
240
240
|
targets = []
|
241
241
|
end
|
242
|
-
print targets.join(' ')
|
242
|
+
print targets.sort.join(' ')
|
243
243
|
elsif print_options
|
244
|
-
print OPTIONS.map {|o| o[0]}.join(' ')
|
244
|
+
print OPTIONS.map {|o| o[0]}.sort.join(' ')
|
245
245
|
elsif print_tasks
|
246
246
|
print Bee::Task::PackageManager.list_tasks.join(' ')
|
247
247
|
elsif print_templates
|
data/lib/bee_task_default.rb
CHANGED
@@ -169,6 +169,8 @@ module Bee
|
|
169
169
|
# - prop: Property to set with content of the response body. Optional
|
170
170
|
# defaults to output in a file.
|
171
171
|
# - limit: the redirections limit. Optional, defaults to 10.
|
172
|
+
# - username: username for HTTP basic authentication. Optional.
|
173
|
+
# - password: password for HTTP basic authentication. Optional.
|
172
174
|
#
|
173
175
|
# Example
|
174
176
|
#
|
@@ -176,15 +178,20 @@ module Bee
|
|
176
178
|
# url: http://rubyforge.org/frs/download.php/22185/bee-0.4.0.zip
|
177
179
|
def http_get(parameters)
|
178
180
|
params_desc = {
|
179
|
-
:url
|
180
|
-
:dest
|
181
|
-
:prop
|
182
|
-
:limit
|
181
|
+
:url => { :mandatory => true, :type => :string },
|
182
|
+
:dest => { :mandatory => false, :type => :string },
|
183
|
+
:prop => { :mandatory => false, :type => :string },
|
184
|
+
:limit => { :mandatory => false, :type => :integer,
|
185
|
+
:default => 10 },
|
186
|
+
:username => { :mandatory => false, :type => :string },
|
187
|
+
:password => { :mandatory => false, :type => :string },
|
183
188
|
}
|
184
189
|
check_parameters(parameters, params_desc)
|
185
|
-
url
|
186
|
-
dest
|
187
|
-
prop
|
190
|
+
url = parameters[:url]
|
191
|
+
dest = parameters[:dest]
|
192
|
+
prop = parameters[:prop]
|
193
|
+
username = parameters[:username]
|
194
|
+
password = parameters[:password]
|
188
195
|
if not dest and not prop
|
189
196
|
destination = File.basename(url)
|
190
197
|
elsif dest and File.directory?(dest)
|
@@ -197,7 +204,7 @@ module Bee
|
|
197
204
|
limit = parameters[:limit]
|
198
205
|
puts "Getting URL '#{url}'..."
|
199
206
|
begin
|
200
|
-
content = Util::fetch(url, limit)
|
207
|
+
content = Util::fetch(url, limit, username, password)
|
201
208
|
rescue Exception
|
202
209
|
error "Error getting URL: #{$!}"
|
203
210
|
end
|
@@ -548,6 +555,8 @@ EOF
|
|
548
555
|
# '**/*' to include all files recursively.
|
549
556
|
# - excludes: list of globs for files to exclude from copy. Optional,
|
550
557
|
# default to nil to exclude no file.
|
558
|
+
# - dest: destination directory for the copy, must be an existing
|
559
|
+
# directory.
|
551
560
|
# - dotmatch: tells if joker matches dot files. Optional, defaults to
|
552
561
|
# false.
|
553
562
|
# - flatten: tells if included files should be copied in destination
|
@@ -924,16 +933,7 @@ EOF
|
|
924
933
|
check_parameters(params, params_desc)
|
925
934
|
library = params[:library]
|
926
935
|
message = params[:message]
|
927
|
-
|
928
|
-
begin
|
929
|
-
Gem::activate(library, false)
|
930
|
-
available = true
|
931
|
-
rescue LoadError
|
932
|
-
available = false
|
933
|
-
end
|
934
|
-
else
|
935
|
-
available = Gem::available?(library)
|
936
|
-
end
|
936
|
+
available = Bee::Util::gem_available?(library)
|
937
937
|
error message if not available
|
938
938
|
end
|
939
939
|
|
@@ -1475,6 +1475,7 @@ EOF
|
|
1475
1475
|
dest = parameters[:dest]
|
1476
1476
|
files = filter_files(includes, excludes, root, dotmatch)
|
1477
1477
|
# build the archive
|
1478
|
+
puts "Building TARGZ archive '#{dest}'"
|
1478
1479
|
begin
|
1479
1480
|
current_dir = Dir.pwd
|
1480
1481
|
abs_dest = File.expand_path(dest)
|
@@ -69,7 +69,7 @@ module Bee
|
|
69
69
|
|
70
70
|
# List all available tasks.
|
71
71
|
def self.list_tasks
|
72
|
-
names = [nil] +
|
72
|
+
names = [nil] + Bee::Util::find_gems(/^bee_/).map {|gem| gem.name[4..-1]}
|
73
73
|
tasks = []
|
74
74
|
for name in names
|
75
75
|
package = self.load_package(name)
|
@@ -84,18 +84,17 @@ module Bee
|
|
84
84
|
|
85
85
|
# List all available templates.
|
86
86
|
def self.list_templates
|
87
|
-
gems =
|
87
|
+
gems = Bee::Util::find_gems(/^bee$/, /^bee_/)
|
88
88
|
templates = []
|
89
89
|
for gem in gems
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
90
|
+
gem_path = gem.full_gem_path
|
91
|
+
eggs = Dir.glob("#{gem_path}/egg/*.yml").
|
92
|
+
map{|p| p[gem_path.length+5..-5]}
|
93
|
+
if gem.name != 'bee'
|
94
|
+
package = gem.name[4..-1]
|
95
|
+
templates += eggs.map{|e| "#{package}.#{e}"}
|
96
|
+
else
|
97
|
+
templates += eggs
|
99
98
|
end
|
100
99
|
end
|
101
100
|
return templates.sort
|
@@ -119,15 +118,6 @@ module Bee
|
|
119
118
|
end
|
120
119
|
end
|
121
120
|
|
122
|
-
def self.find_gems(*patterns)
|
123
|
-
gems = []
|
124
|
-
index = Gem::SourceIndex.from_installed_gems()
|
125
|
-
for pattern in patterns
|
126
|
-
gems += index.find_name(pattern)
|
127
|
-
end
|
128
|
-
return gems
|
129
|
-
end
|
130
|
-
|
131
121
|
end
|
132
122
|
|
133
123
|
end
|
data/lib/bee_util.rb
CHANGED
@@ -138,7 +138,8 @@ module Bee
|
|
138
138
|
# Get a given URL.
|
139
139
|
# - url: URL to get.
|
140
140
|
# - limit: redirectrion limit (defaults to HTTP_REDIRECTIONS_LIMIT).
|
141
|
-
def self.fetch(url, limit=HTTP_REDIRECTIONS_LIMIT
|
141
|
+
def self.fetch(url, limit=HTTP_REDIRECTIONS_LIMIT,
|
142
|
+
username=nil, password=nil)
|
142
143
|
raise 'HTTP redirect too deep' if limit == 0
|
143
144
|
response = Net::HTTP.get_response(URI.parse(url))
|
144
145
|
case response
|
@@ -146,6 +147,14 @@ module Bee
|
|
146
147
|
response.body
|
147
148
|
when Net::HTTPRedirection
|
148
149
|
fetch(response['location'], limit-1)
|
150
|
+
when Net::HTTPUnauthorized
|
151
|
+
uri = URI.parse(url)
|
152
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
153
|
+
request = Net::HTTP::Get.new("#{uri.path}?#{uri.query}")
|
154
|
+
request.basic_auth(username, password)
|
155
|
+
response = http.request(request)
|
156
|
+
return response.body
|
157
|
+
end
|
149
158
|
else
|
150
159
|
response.error!
|
151
160
|
end
|
@@ -166,11 +175,27 @@ module Bee
|
|
166
175
|
end
|
167
176
|
# get gem descriptor
|
168
177
|
if version
|
169
|
-
|
178
|
+
if Gem::Specification.respond_to?(:find_by_name)
|
179
|
+
begin
|
180
|
+
gem_descriptor = Gem::Specification.find_by_name(gem, version)
|
181
|
+
rescue Exception
|
182
|
+
gem_descriptor = nil
|
183
|
+
end
|
184
|
+
else
|
185
|
+
gem_descriptor = Gem.source_index.find_name(gem, version)[0]
|
186
|
+
end
|
170
187
|
raise "Gem '#{gem}' was not found in version '#{version}'" if
|
171
188
|
not gem_descriptor
|
172
189
|
else
|
173
|
-
|
190
|
+
if Gem::Specification.respond_to?(:find_by_name)
|
191
|
+
begin
|
192
|
+
gem_descriptor = Gem::Specification::find_by_name(gem)
|
193
|
+
rescue Exception
|
194
|
+
gem_descriptor = nil
|
195
|
+
end
|
196
|
+
else
|
197
|
+
gem_descriptor = Gem.source_index.find_name(gem)[0]
|
198
|
+
end
|
174
199
|
raise "Gem '#{gem}' was not found" if not gem_descriptor
|
175
200
|
end
|
176
201
|
# get resource path
|
@@ -195,7 +220,7 @@ module Bee
|
|
195
220
|
resource = ":#{prefix}#{package}.egg/#{egg}.yml"
|
196
221
|
begin
|
197
222
|
file = absolute_path(resource, Dir.pwd)
|
198
|
-
rescue
|
223
|
+
rescue Exception
|
199
224
|
raise BuildError.new("Template '#{template}' not found")
|
200
225
|
end
|
201
226
|
raise BuildError.new("Template '#{template}' not found") if
|
@@ -236,6 +261,59 @@ module Bee
|
|
236
261
|
end
|
237
262
|
return hash
|
238
263
|
end
|
264
|
+
|
265
|
+
# Tells if a given gem is available.
|
266
|
+
def self.gem_available?(gem)
|
267
|
+
if lower_version(Gem::RubyGemsVersion, [1, 3, 0])
|
268
|
+
begin
|
269
|
+
Gem::activate(gem, false)
|
270
|
+
return true
|
271
|
+
rescue LoadError
|
272
|
+
return false
|
273
|
+
end
|
274
|
+
elsif lower_version(Gem::RubyGemsVersion, [1, 8, 0])
|
275
|
+
return Gem::available?(gem)
|
276
|
+
else
|
277
|
+
begin
|
278
|
+
Gem::Specification::find_by_name(gem)
|
279
|
+
return true
|
280
|
+
rescue LoadError
|
281
|
+
return false
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
# Find gems with name matching a given pattern. Returns the list of gem
|
287
|
+
# specifications.
|
288
|
+
def self.find_gems(*patterns)
|
289
|
+
gems = []
|
290
|
+
if Bee::Util::lower_version(Gem::RubyGemsVersion, [1, 8, 0])
|
291
|
+
index = Gem::SourceIndex.from_installed_gems()
|
292
|
+
for pattern in patterns
|
293
|
+
gems += index.find_name(pattern)
|
294
|
+
end
|
295
|
+
else
|
296
|
+
for pattern in patterns
|
297
|
+
Gem::Specification::each do |spec|
|
298
|
+
gems << spec if spec.name =~ pattern
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
return gems.uniq
|
303
|
+
end
|
304
|
+
|
305
|
+
# Tells if a given version is lower tah another.
|
306
|
+
def self.lower_version(v1, v2)
|
307
|
+
v1 = to_version(v1) if v1.kind_of?(String)
|
308
|
+
v2 = to_version(v2) if v2.kind_of?(String)
|
309
|
+
return ((v1 <=> v2) < 0)
|
310
|
+
end
|
311
|
+
|
312
|
+
# Convert a string to a version number (array of integers). Thus will turn
|
313
|
+
# '1.2.3' to [1, 2, 3].
|
314
|
+
def self.to_version(string)
|
315
|
+
return string.split('.').map{|s| s.to_i}
|
316
|
+
end
|
239
317
|
|
240
318
|
# Class that holds information about a given method.
|
241
319
|
class MethodInfo
|
data/lib/bee_version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 49
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 11
|
9
|
-
-
|
10
|
-
version: 0.11.
|
9
|
+
- 1
|
10
|
+
version: 0.11.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michel Casabianca & Contributors
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-09 00:00:00 +01:00
|
19
19
|
default_executable: bee
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|