evoker 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/evoker.rb CHANGED
@@ -14,6 +14,8 @@ require 'evoker/version'
14
14
  # Evoker is a tool to manage external dependencies of a project using
15
15
  # Rake to run downloads.
16
16
  module Evoker
17
+ extend Rake::DSL
18
+
17
19
  # {Rake::FileList} of defined entities
18
20
  # @example can be used as dependency for the default target
19
21
  # task :default => Evoker::ENTITIES
@@ -140,4 +142,36 @@ module Evoker
140
142
  end
141
143
  end
142
144
  module_function :git
145
+
146
+ private
147
+
148
+ # Define smart constant's default
149
+ # @param name [#to_s] constant's name (will be upcased)
150
+ # @param default constant's default value
151
+ def self.smart_const(name, default)
152
+ @@SMART_CONST_DEFAULTS ||= {}
153
+ @@SMART_CONST_DEFAULTS[name.to_s.upcase] = default
154
+ end
155
+
156
+ # Get smart constant's effective value
157
+ #
158
+ # Effective value is:
159
+ # 1. `ENV[name.to_s.upcase]` if present
160
+ # 2. Otherwise, user-defined top-level constant named `name.to_s.upcase`
161
+ # 3. Otherwise, default set with {smart_const}
162
+ # 4. Otherwise, nil
163
+ #
164
+ # @param name [#to_s] constant's name
165
+ def smart_const_get(name)
166
+ name = name.to_s.upcase
167
+ if ENV.has_key?(name)
168
+ ENV[name]
169
+ elsif Object.const_defined?(name)
170
+ Object.const_get(name)
171
+ else
172
+ @@SMART_CONST_DEFAULTS ||= {}
173
+ @@SMART_CONST_DEFAULTS[name]
174
+ end
175
+ end
176
+ module_function :smart_const_get
143
177
  end
data/lib/evoker/python.rb CHANGED
@@ -3,8 +3,9 @@
3
3
  require 'evoker'
4
4
 
5
5
  module Evoker
6
- PYTHON = ENV['PYTHON'] || 'python'
7
- PIP = ENV['PIP'] || 'pip'
6
+ smart_const(:python, 'python')
7
+ smart_const(:pip, 'pip')
8
+ smart_const(:virtualenv_version, '1.6.1')
8
9
 
9
10
  # Create Python virtual environment
10
11
  def virtualenv(*args)
@@ -15,9 +16,9 @@ module Evoker
15
16
  end
16
17
 
17
18
  if opts[:download_virtualenv]
18
- opts[:python] ||= PYTHON
19
+ opts[:python] ||= smart_const_get(:python)
19
20
  opts[:virtualenv] = "#{opts[:python]} ./virtualenv.py"
20
- opts[:virtualenv_version] ||= '1.6'
21
+ opts[:virtualenv_version] ||= smart_const_get(:virtualenv_version)
21
22
  opts[:virtualenv_url] ||= "http://github.com/pypa/virtualenv/raw/#{opts[:virtualenv_version]}/virtualenv.py"
22
23
  wget_virtualenv = wget opts[:virtualenv_url],
23
24
  :args => '--no-check-certificate',
@@ -59,7 +60,7 @@ module Evoker
59
60
  if args[:virtualenv]
60
61
  args[:pip] = "#{args[:virtualenv]}/bin/pip"
61
62
  else
62
- args[:pip] ||= PIP
63
+ args[:pip] ||= smart_const_get(:pip)
63
64
  end
64
65
  pip_cmd = "#{args[:pip]}"
65
66
  pip_cmd << " #{args[:args]}" if args[:args]
@@ -36,10 +36,23 @@ module Evoker
36
36
  end
37
37
  sh "tar -czf #{CACHE_TARBALL} --exclude '#{CACHE_BASENAME}*.tgz' ."
38
38
  puts "INFO: uploading #{CACHE_TARBALL} to #{CACHE_S3_BUCKET}..."
39
- File.open(CACHE_TARBALL, 'r') do |tarball|
40
- bucket.files.create(
41
- :key => CACHE_TARBALL,
42
- :body => tarball)
39
+
40
+ # retry upload 3 times
41
+ _tries = 0
42
+ begin
43
+ File.open(CACHE_TARBALL, 'r') do |tarball|
44
+ bucket.files.create(
45
+ :key => CACHE_TARBALL,
46
+ :body => tarball)
47
+ end
48
+ rescue
49
+ _tries += 1
50
+ if _tries <= 3
51
+ puts "WARN: retrying #{_tries}/3: #{$!}"
52
+ retry
53
+ else
54
+ raise
55
+ end
43
56
  end
44
57
  end
45
58
 
@@ -2,7 +2,7 @@ module Evoker
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 5
5
+ TINY = 6
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
 
8
8
  def VERSION.require_version(major, minor=0, tiny=0)
metadata CHANGED
@@ -1,89 +1,65 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: evoker
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 5
10
- version: 0.0.5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Maciej Pasternacki
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-04-30 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rake
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2152986940 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2
33
22
  type: :runtime
34
- version_requirements: *id001
35
- description: |
36
- Evoker is an add-on to Rake to download and manage project's external
23
+ prerelease: false
24
+ version_requirements: *2152986940
25
+ description: ! 'Evoker is an add-on to Rake to download and manage project''s external
26
+
37
27
  dependencied, update them as needed, cache them, etc.
38
28
 
29
+ '
39
30
  email: maciej@pasternacki.net
40
31
  executables: []
41
-
42
32
  extensions: []
43
-
44
33
  extra_rdoc_files: []
45
-
46
- files:
34
+ files:
47
35
  - lib/evoker/python.rb
48
36
  - lib/evoker/s3cache.rb
49
37
  - lib/evoker/version.rb
50
38
  - lib/evoker.rb
51
39
  - LICENSE
52
- has_rdoc: true
53
40
  homepage: http://github.com/mpasternacki/evoker
54
- licenses:
41
+ licenses:
55
42
  - BSD
56
43
  post_install_message:
57
44
  rdoc_options: []
58
-
59
- require_paths:
45
+ require_paths:
60
46
  - lib
61
- required_ruby_version: !ruby/object:Gem::Requirement
47
+ required_ruby_version: !ruby/object:Gem::Requirement
62
48
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 3
67
- segments:
68
- - 0
69
- version: "0"
70
- required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
54
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 23
76
- segments:
77
- - 1
78
- - 3
79
- - 6
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
80
58
  version: 1.3.6
81
59
  requirements: []
82
-
83
60
  rubyforge_project:
84
- rubygems_version: 1.5.0
61
+ rubygems_version: 1.8.6
85
62
  signing_key:
86
63
  specification_version: 3
87
64
  summary: Rake add-on to download and manage project's external dependencies
88
65
  test_files: []
89
-