bee 0.11.4 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -25,4 +25,4 @@ or go to URL http://www.apache.org/licenses/LICENSE-2.0).
25
25
 
26
26
  = Copyright
27
27
 
28
- bee version 0.11.4 (C) Michel Casabianca & Contributors - 2006-2012
28
+ bee version 0.12.0 (C) Michel Casabianca & Contributors - 2006-2012
@@ -1,5 +1,7 @@
1
1
  require 'rubygems'
2
2
 
3
+ remove_const(:SPEC) if defined?(SPEC)
4
+
3
5
  SPEC = Gem::Specification.new do |spec|
4
6
  spec.name = '<%= name %>'
5
7
  spec.version = '<%= version %>'
@@ -9,6 +9,7 @@
9
9
  gem_spec: "#{build}/gem_spec"
10
10
  gem_erb: |
11
11
  require 'rubygems'
12
+ remove_const(:SPEC) if defined?(SPEC)
12
13
  SPEC = Gem::Specification.new do |spec|
13
14
  spec.name = '<%= name %>'
14
15
  spec.version = '0.0.1'
@@ -1,5 +1,7 @@
1
1
  require 'rubygems'
2
2
 
3
+ remove_const(:SPEC) if defined?(SPEC)
4
+
3
5
  SPEC = Gem::Specification.new do |spec|
4
6
  spec.name = '<%= name %>'
5
7
  spec.version = '<%= version %>'
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'rubygems'
16
+ require 'syck'
16
17
  require 'yaml'
17
18
  require 'bee_util'
18
19
  require 'bee_context'
@@ -18,6 +18,7 @@ require 'bee_util'
18
18
  require 'bee_listener'
19
19
  require 'bee_console_formatter'
20
20
  require 'getoptlong'
21
+ require 'syck'
21
22
  require 'yaml'
22
23
 
23
24
  module Bee
@@ -234,7 +235,7 @@ EOF
234
235
  puts formatter.help_template(template)
235
236
  elsif template
236
237
  file = Bee::Util::find_template(template)
237
- listener = Listener.new(formatter)
238
+ listener = Bee::Listener.new(formatter)
238
239
  build = Build.load(file, false, properties)
239
240
  build.run(targets, listener, dry_run)
240
241
  elsif resource
@@ -14,6 +14,7 @@
14
14
 
15
15
  require 'rubygems'
16
16
  require 'bee_console_style'
17
+ require 'syck'
17
18
  require 'yaml'
18
19
 
19
20
  module Bee
@@ -147,7 +147,7 @@ module Bee
147
147
 
148
148
  # Run a given construct.
149
149
  # - construct: construct to run as a Hash.
150
- # -dry: tells if we are running in dry mode. Defaults to false.
150
+ # - dry: tells if we are running in dry mode. Defaults to false.
151
151
  def run_construct(construct, dry=false)
152
152
  @listener.task(construct) if @listener
153
153
  return if dry
@@ -124,6 +124,9 @@ module Bee
124
124
  # Run targets.
125
125
  # - targets: list of target names to run.
126
126
  def run(targets, dry)
127
+ targets = [] if targets == ''
128
+ targets = targets || []
129
+ targets = Array(targets)
127
130
  if targets.length == 0
128
131
  if @default
129
132
  targets = @default
@@ -16,6 +16,7 @@ require 'rubygems'
16
16
  require 'bee_build'
17
17
  require 'bee_task_package'
18
18
  require 'bee_util'
19
+ require 'bee_version_dependant'
19
20
  require 'erb'
20
21
  require 'fileutils'
21
22
  require 'net/smtp'
@@ -922,7 +923,7 @@ EOF
922
923
  check_parameters(params, params_desc)
923
924
  library = params[:library]
924
925
  message = params[:message]
925
- available = Bee::Util::gem_available?(library)
926
+ available = Bee::VersionDependant::gem_available?(library)
926
927
  error message if not available
927
928
  end
928
929
 
@@ -946,6 +947,11 @@ EOF
946
947
  # root: :test
947
948
  # includes: "**/tc_*.rb"
948
949
  # dir: "test"
950
+ #
951
+ # Notes
952
+ #
953
+ # For ruby 1.9 and later, you must install gem 'test-unit' to run this
954
+ # task.
949
955
  def test(params)
950
956
  require 'test/unit'
951
957
  params_desc = {
@@ -968,15 +974,19 @@ EOF
968
974
  not (File.exists?(dir) and File.directory?(dir))
969
975
  files = filter_files(root, includes, excludes, dotmatch)
970
976
  files.map! { |file| File.expand_path(File.join(root, file)) }
977
+ size = (files.kind_of?(Array) ? files.size : 1)
978
+ puts "Running #{size} unit test(s)"
971
979
  for file in files
972
980
  load file
973
981
  end
974
- size = (files.kind_of?(Array) ? files.size : 1)
975
- puts "Running #{size} unit test(s)"
976
982
  old_dir = Dir.pwd
977
983
  begin
978
984
  Dir.chdir(dir)
979
- runner = Test::Unit::AutoRunner.new(false)
985
+ if Bee::VersionDependant::ruby_lower_than('1.9.2')
986
+ runner = Test::Unit::AutoRunner.new(false)
987
+ else
988
+ runner = MiniTest::Unit.new()
989
+ end
980
990
  ok = runner.run
981
991
  error "Test failure" if not ok
982
992
  ensure
@@ -1031,7 +1041,7 @@ EOF
1031
1041
  (not File.exists?(src) or not File.file?(src) or
1032
1042
  not File.readable?(src))
1033
1043
  # load ERB source
1034
- erb_source = source||File.read(src)
1044
+ erb_source = source||File.open(src, 'r') {|f| f.read}
1035
1045
  if options
1036
1046
  template = ERB.new(erb_source, 0, options)
1037
1047
  else
@@ -76,6 +76,8 @@ module Bee
76
76
  methods = package.class.public_instance_methods(false)
77
77
  if name
78
78
  methods.map! {|method| "#{name}.#{method}"}
79
+ else
80
+ methods.map! {|method| method.to_s}
79
81
  end
80
82
  tasks += methods
81
83
  end
@@ -15,6 +15,7 @@
15
15
 
16
16
  require 'rubygems'
17
17
  require 'net/http'
18
+ require 'bee_version_dependant'
18
19
 
19
20
  module Bee
20
21
 
@@ -259,58 +260,15 @@ module Bee
259
260
  end
260
261
  return hash
261
262
  end
262
-
263
- # Tells if a given gem is available.
263
+
264
+ # Aliases
265
+
264
266
  def self.gem_available?(gem)
265
- if lower_version(Gem::RubyGemsVersion, [1, 3, 0])
266
- begin
267
- Gem::activate(gem, false)
268
- return true
269
- rescue LoadError
270
- return false
271
- end
272
- elsif lower_version(Gem::RubyGemsVersion, [1, 8, 0])
273
- return Gem::available?(gem)
274
- else
275
- begin
276
- Gem::Specification::find_by_name(gem)
277
- return true
278
- rescue LoadError
279
- return false
280
- end
281
- end
267
+ return Bee::VersionDependant::gem_available?(gem)
282
268
  end
283
269
 
284
- # Find gems with name matching a given pattern. Returns the list of gem
285
- # specifications.
286
270
  def self.find_gems(*patterns)
287
- gems = []
288
- if Bee::Util::lower_version(Gem::RubyGemsVersion, [1, 8, 0])
289
- index = Gem::SourceIndex.from_installed_gems()
290
- for pattern in patterns
291
- gems += index.find_name(pattern)
292
- end
293
- else
294
- for pattern in patterns
295
- Gem::Specification::each do |spec|
296
- gems << spec if spec.name =~ pattern
297
- end
298
- end
299
- end
300
- return gems.uniq
301
- end
302
-
303
- # Tells if a given version is lower tah another.
304
- def self.lower_version(v1, v2)
305
- v1 = to_version(v1) if v1.kind_of?(String)
306
- v2 = to_version(v2) if v2.kind_of?(String)
307
- return ((v1 <=> v2) < 0)
308
- end
309
-
310
- # Convert a string to a version number (array of integers). Thus will turn
311
- # '1.2.3' to [1, 2, 3].
312
- def self.to_version(string)
313
- return string.split('.').map{|s| s.to_i}
271
+ return Bee::VersionDependant::find_gems(*patterns)
314
272
  end
315
273
 
316
274
  # Class that holds information about a given method.
@@ -456,7 +414,7 @@ module Bee
456
414
  end
457
415
 
458
416
  end
459
-
417
+
460
418
  end
461
419
 
462
420
  end
@@ -1,5 +1,5 @@
1
1
  module Bee
2
2
 
3
- VERSION = '0.11.4'
3
+ VERSION = '0.12.0'
4
4
 
5
5
  end
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2006-2012 Michel Casabianca <michel.casabianca@gmail.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ module Bee
18
+
19
+ module VersionDependant
20
+
21
+ # Convert a string to a version number (array of integers). Thus will turn
22
+ # '1.2.3' to [1, 2, 3].
23
+ def self.to_version(string)
24
+ return string.split('.').map{|s| s.to_i}
25
+ end
26
+
27
+ # Compares two versions.
28
+ # Returns:
29
+ # - < 0 if first is lower than second.
30
+ # - > 0 if first is greater than second.
31
+ # - = 0 if first is equal to second.
32
+ def self.compare_versions(v1, v2)
33
+ v1 = to_version(v1) if v1.kind_of?(String)
34
+ v2 = to_version(v2) if v2.kind_of?(String)
35
+ return (v1 <=> v2)
36
+ end
37
+
38
+ # Get Ruby version as an Array.
39
+ def self.ruby_version()
40
+ return to_version(RUBY_VERSION)
41
+ end
42
+
43
+ # Get Gems version.
44
+ def self.gems_version()
45
+ return Gem::RubyGemsVersion
46
+ end
47
+
48
+ # Tells if ruby version is greater than a given string version.
49
+ def self.ruby_greater_than(version)
50
+ return compare_versions(ruby_version, to_version(version)) > 0
51
+ end
52
+
53
+ # Tells if ruby version is lower than a given string version.
54
+ def self.ruby_lower_than(version)
55
+ return compare_versions(ruby_version, to_version(version)) < 0
56
+ end
57
+
58
+ # Tells if ruby version equals a given string version.
59
+ def self.ruby_equals_to(version)
60
+ return compare_versions(ruby_version, to_version(version)) == 0
61
+ end
62
+
63
+ # Tells if a given gem is available.
64
+ def self.gem_available?(gem)
65
+ if compare_versions(gems_version, [1, 3, 0]) < 0
66
+ begin
67
+ Gem::activate(gem, false)
68
+ return true
69
+ rescue LoadError
70
+ return false
71
+ end
72
+ elsif compare_versions(gems_version, [1, 8, 0]) < 0
73
+ return Gem::available?(gem)
74
+ else
75
+ begin
76
+ Gem::Specification::find_by_name(gem)
77
+ return true
78
+ rescue LoadError
79
+ return false
80
+ end
81
+ end
82
+ end
83
+
84
+ # Find gems with name matching a given pattern. Returns the list of gem
85
+ # specifications.
86
+ def self.find_gems(*patterns)
87
+ gems = []
88
+ if compare_versions(gems_version, [1, 8, 0]) < 0
89
+ index = Gem::SourceIndex.from_installed_gems()
90
+ for pattern in patterns
91
+ gems += index.find_name(pattern)
92
+ end
93
+ else
94
+ for pattern in patterns
95
+ Gem::Specification::each do |spec|
96
+ gems << spec if spec.name =~ pattern
97
+ end
98
+ end
99
+ end
100
+ return gems.uniq
101
+ end
102
+
103
+ end
104
+
105
+ end
106
+
107
+ # patch test/unit to disable autorun for Ruby 1.9.2 or 1.9.1
108
+ if Bee::VersionDependant::ruby_equals_to('1.9.2') or Bee::VersionDependant::ruby_equals_to('1.9.1')
109
+
110
+ require 'minitest/unit'
111
+
112
+ module MiniTest
113
+
114
+ class Unit
115
+ def self.autorun
116
+ end
117
+ end
118
+
119
+ end
120
+
121
+ end
122
+
123
+ # patch test/unit to disable autorun for Ruby 1.9.3
124
+ if Bee::VersionDependant::ruby_equals_to('1.9.3')
125
+
126
+ require 'test/unit'
127
+
128
+ class Test::Unit::Runner
129
+ @@stop_auto_run = true
130
+ end
131
+
132
+ end
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: 59
4
+ hash: 47
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 11
9
- - 4
10
- version: 0.11.4
8
+ - 12
9
+ - 0
10
+ version: 0.12.0
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: 2012-08-16 00:00:00 +02:00
18
+ date: 2013-05-15 00:00:00 +02:00
19
19
  default_executable: bee
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -93,6 +93,7 @@ files:
93
93
  - lib/bee_task_packagemanager.rb
94
94
  - lib/bee_util.rb
95
95
  - lib/bee_version.rb
96
+ - lib/bee_version_dependant.rb
96
97
  - egg/application/bin/start
97
98
  - egg/application/bin/start.bat
98
99
  - egg/application/build.yml