guard-bundler 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +1,20 @@
1
1
  # encoding: utf-8
2
2
  require 'guard'
3
3
  require 'guard/guard'
4
+ require 'bundler'
4
5
 
5
6
  module Guard
6
7
  class Bundler < Guard
7
- BUNDLER_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE).freeze
8
-
9
8
  autoload :Notifier, 'guard/bundler/notifier'
10
9
 
11
10
  def initialize(watchers = [], options = {})
12
11
  super
13
12
 
14
- @original_env = {}
15
13
  options[:notify] = true if options[:notify].nil?
16
14
  end
17
-
18
- def start
19
- return refresh_bundle if bundle_need_refresh?
20
- true
21
- end
22
15
 
23
- def stop
24
- true
16
+ def start
17
+ refresh_bundle
25
18
  end
26
19
 
27
20
  def reload
@@ -29,8 +22,7 @@ module Guard
29
22
  end
30
23
 
31
24
  def run_on_change(paths = [])
32
- return refresh_bundle if bundle_need_refresh?
33
- true
25
+ refresh_bundle
34
26
  end
35
27
 
36
28
  private
@@ -39,41 +31,27 @@ module Guard
39
31
  !!options[:notify]
40
32
  end
41
33
 
42
- def bundle_need_refresh?
43
- with_clean_env do
44
- `bundle check`
45
- end
46
- $? == 0 ? false : true
47
- end
48
-
49
- def with_clean_env
50
- unset_bundler_env_vars
51
- ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, "Gemfile")
52
- yield
53
- ensure
54
- restore_env
55
- end
56
-
57
- def unset_bundler_env_vars
58
- BUNDLER_ENV_VARS.each do |key|
59
- @original_env[key] = ENV[key]
60
- ENV[key] = nil
34
+ def refresh_bundle
35
+ if bundle_need_refresh?
36
+ UI.info 'Refresh bundle', :reset => true
37
+ start_at = Time.now
38
+ ::Bundler.with_clean_env do
39
+ @result = system('bundle install')
40
+ end
41
+ Notifier::notify(@result, Time.now - start_at) if notify?
42
+ @result
43
+ else
44
+ UI.info 'Bundle already up-to-date', :reset => true
45
+ Notifier::notify('up-to-date', nil) if notify?
46
+ true
61
47
  end
62
48
  end
63
49
 
64
- def restore_env
65
- @original_env.each { |key, value| ENV[key] = value }
66
- end
67
-
68
- def refresh_bundle
69
- UI.info 'Refresh bundle', :reset => true
70
- start_at = Time.now
71
- result = ''
72
- with_clean_env do
73
- result = system('bundle install')
50
+ def bundle_need_refresh?
51
+ ::Bundler.with_clean_env do
52
+ `bundle check`
74
53
  end
75
- Notifier::notify(true, Time.now - start_at) if notify?
76
- result
54
+ $? == 0 ? false : true
77
55
  end
78
56
 
79
57
  end
@@ -4,13 +4,14 @@ module Guard
4
4
  class Notifier
5
5
 
6
6
  def self.guard_message(result, duration)
7
- message = ''
8
- if result
9
- message << "Bundle has been updated\nin %.1f seconds." % [duration]
7
+ case result
8
+ when 'up-to-date'
9
+ "Bundle already up-to-date"
10
+ when true
11
+ "Bundle has been updated\nin %.1f seconds." % [duration]
10
12
  else
11
- message << "Bundle can't be updated,\nplease check manually."
13
+ "Bundle can't be updated,\nplease check manually."
12
14
  end
13
- message
14
15
  end
15
16
 
16
17
  # failed | success
@@ -31,4 +32,4 @@ module Guard
31
32
 
32
33
  end
33
34
  end
34
- end
35
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Guard
3
3
  module BundlerVersion
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
6
6
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: guard-bundler
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Yann Lugrin
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-18 00:00:00 +01:00
13
+ date: 2011-05-14 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -30,10 +30,10 @@ dependencies:
30
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
- - - ~>
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 1.0.2
36
- type: :development
35
+ version: 1.0.0
36
+ type: :runtime
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
@@ -43,9 +43,20 @@ dependencies:
43
43
  requirements:
44
44
  - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: 2.0.1
46
+ version: 2.6.0
47
47
  type: :development
48
48
  version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: guard-rspec
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 0.3.1
58
+ type: :development
59
+ version_requirements: *id004
49
60
  description: Guard::Bundler automatically install/update your gem bundle when needed
50
61
  email:
51
62
  - yann.lugrin@sans-savoir.net
@@ -88,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
99
  requirements: []
89
100
 
90
101
  rubyforge_project: guard-bundler
91
- rubygems_version: 1.5.2
102
+ rubygems_version: 1.6.2
92
103
  signing_key:
93
104
  specification_version: 3
94
105
  summary: Guard gem for Bundler