mattock 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ require 'mattock/command-task'
2
+
3
+ module Mattock
4
+ class BundleCommandTask < CommandTask
5
+ class BundleEnvCleaner < CommandLine
6
+ def initialize(original)
7
+ @original = original
8
+ end
9
+
10
+ def run
11
+ original_env = ENV.to_hash
12
+ if defined? Bundler
13
+ %w{
14
+ BUNDLER_EDITOR
15
+ BUNDLE_APP_CONFIG
16
+ BUNDLE_BIN_PATH
17
+ BUNDLE_CONFIG
18
+ BUNDLE_PATH
19
+ BUNDLE_SPEC_RUN
20
+ DEBUG
21
+ DEBUG_RESOLVER
22
+ EDITOR
23
+ GEM_HOME
24
+ GEM_PATH
25
+ MANPAGER
26
+ PAGER
27
+ PATH
28
+ RB_USER_INSTALL
29
+ RUBYOPT
30
+ VISUAL
31
+ }.each do |bundler_varname|
32
+ begin
33
+ ENV[bundler_varname] = Bundler::ORIGINAL_ENV.fetch(bundler_varname)
34
+ rescue KeyError
35
+ ENV.delete(bundler_varname)
36
+ end
37
+ end
38
+ end
39
+ %w{
40
+ BUNDLE_GEMFILE
41
+ }
42
+
43
+ @original.run
44
+ ensure
45
+ ENV.replace(original_env)
46
+ end
47
+ end
48
+
49
+ def decorated(command)
50
+ BundleEnvCleaner.new(command)
51
+ end
52
+ end
53
+ end
@@ -31,6 +31,7 @@ module Mattock
31
31
  end
32
32
 
33
33
  module CommandLineExampleGroup
34
+ include CommandLineDSL
34
35
  module MockingExecute
35
36
  def execute
36
37
  Mattock::CommandLine.execute(command)
data/spec/command-task.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  require 'mattock/remote-command-task'
2
+ require 'mattock/bundle-command-task'
2
3
  require 'mattock/testing/rake-example-group'
3
4
  require 'mattock/testing/mock-command-line'
4
5
 
5
6
  describe Mattock::RemoteCommandTask do
6
7
  include Mattock::RakeExampleGroup
8
+ include Mattock::CommandLineExampleGroup
9
+
7
10
  let! :remote_task do
8
11
  namespace :test do
9
12
  Mattock::RemoteCommandTask.new do |t|
@@ -25,8 +28,6 @@ describe Mattock::RemoteCommandTask do
25
28
  end
26
29
 
27
30
  describe "when verification indicates command should proceed" do
28
- include Mattock::CommandLineExampleGroup
29
-
30
31
  it "should run both commands" do
31
32
  expect_command(/should_do/, 1)
32
33
  expect_command(/^ssh.*cd.*ls.*grep.*rubyfiles.txt/, 0)
@@ -35,3 +36,19 @@ describe Mattock::RemoteCommandTask do
35
36
  end
36
37
  end
37
38
  end
39
+
40
+ describe Mattock::BundleCommandTask do
41
+ include Mattock::RakeExampleGroup
42
+ include Mattock::CommandLineExampleGroup
43
+
44
+ let! :bundle_task do
45
+ Mattock::BundleCommandTask.new(:bundle_test) do |t|
46
+ t.command = cmd("bundle", "install", "--standalone")
47
+ end
48
+ end
49
+
50
+ it "should run command" do
51
+ expect_command(/bundle install/, 0)
52
+ rake["bundle_test"].invoke
53
+ end
54
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mattock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: corundum
16
- requirement: &84431630 !ruby/object:Gem::Requirement
16
+ requirement: &81729820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.0.1
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *84431630
24
+ version_requirements: *81729820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: valise
27
- requirement: &84446980 !ruby/object:Gem::Requirement
27
+ requirement: &81843990 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  - 6
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *84446980
38
+ version_requirements: *81843990
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: tilt
41
- requirement: &84446570 !ruby/object:Gem::Requirement
41
+ requirement: &81900760 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>'
@@ -48,7 +48,7 @@ dependencies:
48
48
  - 0
49
49
  type: :runtime
50
50
  prerelease: false
51
- version_requirements: *84446570
51
+ version_requirements: *81900760
52
52
  description: ! " If Rake won't do it by itself, you oughtta Mattock.\n\n If you
53
53
  survived the pun, you might enjoy this gem.\n\n Features:\n\n * Extensions to
54
54
  Tasklibs to support powerful deerpaths.\n * A commandline library that supports
@@ -75,6 +75,7 @@ files:
75
75
  - lib/mattock/template-host.rb
76
76
  - lib/mattock/yard_extensions.rb
77
77
  - lib/mattock/remote-command-task.rb
78
+ - lib/mattock/bundle-command-task.rb
78
79
  - lib/mattock/tasklib.rb
79
80
  - lib/mattock/task.rb
80
81
  - lib/mattock/configurable.rb
@@ -101,7 +102,7 @@ rdoc_options:
101
102
  - --main
102
103
  - doc/README
103
104
  - --title
104
- - mattock-0.3.1 RDoc
105
+ - mattock-0.3.2 RDoc
105
106
  require_paths:
106
107
  - lib/
107
108
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -112,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
113
  version: '0'
113
114
  segments:
114
115
  - 0
115
- hash: -637040849
116
+ hash: 634672435
116
117
  required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  none: false
118
119
  requirements: