singularity_dsl 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2I3NmZkZDJkNmFhZTU1Zjc3ZDVjZDliMmQ3N2Y5Njk1MThhOTUxOQ==
4
+ MjIxMjE1MTRiOTY0ZDdiODRhOTYzMmY4NjFhNmEwN2M5NTkwNTI3NA==
5
5
  data.tar.gz: !binary |-
6
- ZmZlYzdiZDcyZDY5OGMyZTk1YzVkOTFhYTI5NTZlNzJhZTFkY2IwYQ==
6
+ YTMzZThjMjc5NTA1MzlhY2IxM2NhYjEzMTRkZjdjMzk5MDViMWIyNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2FkNTUwMjA4ZTEyZjNmNjYwOTU1ZTNjNThjZWRhZWQzYWYwMGVkM2Y1NmQ3
10
- MTYwNDlkMzM5ZTM1MzkyMTMxMjE1YWFlOTc4MTgxMzMxZmFiZjJiM2RlZmI1
11
- MGVhYWUxMjE4ZTgxYmJlM2FiOTQ3Y2I1OTE1ZmU5Zjc5YmI3MWU=
9
+ NDYzOTU5NDgxNmNmMzFjNDY2ZGUyN2Q3ZjkxZGUxZmQzODRmYjI5Y2UyOTUy
10
+ ZDQ4MmM2YWQ0NDYxMWNkODAxM2JkZjViMDBmYzE5YTY4MmI5NjBiYjEwMzIw
11
+ N2YxMGU4ZDBkZDUwMzJmNzNkNDIzNTdlOWQzMjM1YzczZjY3ODY=
12
12
  data.tar.gz: !binary |-
13
- MDEyODBiNmVjMmViZjQ3Y2M3NWQxYzc4Y2IyNWNkYjJmMWNlMGVkMjc1ZGMz
14
- MDNmZjJhN2UzYjUzZTkxMDEwZmQzYTBmMmM5YTlhNjMxMGNmYjNkN2ZhZmQy
15
- MTU4ZTAyNjUzYzZmZTlhM2ZkYmYzZDVlYTlkNzhlNDg2MWJjM2Y=
13
+ NDE1ZDUxNDYyOTc4MjdlMzEzNzBhMzI2NmFiZWJmOWUwOGUxODE1NDZmNDk2
14
+ Y2RiOThmOTQxOGU5ZDE1YTM1NzI0NzQ5N2M0NzA2YmI5NDYyNWU2N2ZjMjNm
15
+ MjY3NzA1NzczZWMyN2Q4MDYwNzFmOTE5MDM5NWY4NGFmNDkzMjA=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- singularity_dsl (1.5.2)
4
+ singularity_dsl (1.5.3)
5
5
  json (~> 1.0)
6
6
  mixlib-shellout (~> 1.6.0.rc.0)
7
7
  rainbow (~> 2.0.0)
@@ -23,6 +23,7 @@ module SingularityDsl
23
23
  super
24
24
  @diff_list = nil
25
25
  @git = GitHelper.new
26
+ @git.verbosity options[:verbose]
26
27
  env_vars(options[:env] || [])
27
28
  end
28
29
 
@@ -43,6 +44,9 @@ module SingularityDsl
43
44
  class_option :env,
44
45
  type: :array,
45
46
  desc: 'EnvVars to set, formatted as VAR:VAL'
47
+ class_option :verbose,
48
+ type: :boolean,
49
+ desc: 'Turn on verbose logging.'
46
50
  class_option :flags,
47
51
  type: :array,
48
52
  desc: <<-EOD
@@ -1,14 +1,18 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'mixlib/shellout'
4
+ require 'singularity_dsl/stdout'
4
5
 
5
6
  module SingularityDsl
6
7
  # wrapper class for rugged
7
8
  class GitHelper
8
- attr_reader :dir
9
+ include SingularityDsl::Stdout
10
+
11
+ attr_reader :dir, :verbose
9
12
 
10
13
  def initialize
11
14
  throw 'git not installed' unless git_installed
15
+ @verbose = false
12
16
  end
13
17
 
14
18
  def clean_reset
@@ -37,7 +41,7 @@ module SingularityDsl
37
41
 
38
42
  def add_remote(url)
39
43
  remote = remote_from_url url
40
- exec("git remote add #{remote} #{url}")
44
+ exec("git remote add #{remote} #{url}") if url
41
45
  fetch_all
42
46
  end
43
47
 
@@ -56,6 +60,11 @@ module SingularityDsl
56
60
  install_submodules
57
61
  end
58
62
 
63
+ def verbosity(level)
64
+ @verbose = level.is_a?(Fixnum) && level > 0
65
+ @verbose = level if level.is_a? TrueClass
66
+ end
67
+
59
68
  private
60
69
 
61
70
  def remote_cmd(branch, url, action)
@@ -100,6 +109,10 @@ module SingularityDsl
100
109
 
101
110
  def exec(cmd)
102
111
  task = Mixlib::ShellOut.new cmd
112
+ if @verbose
113
+ info cmd
114
+ task.live_stream = STDOUT
115
+ end
103
116
  task.run_command
104
117
  task.exitstatus
105
118
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version const for gem
4
4
  module SingularityDsl
5
- VERSION = '1.5.2'
5
+ VERSION = '1.5.3'
6
6
  end
@@ -11,6 +11,10 @@ describe 'GitHelper' do
11
11
  let(:git) { SingularityDsl::GitHelper.new }
12
12
 
13
13
  context '#initialize' do
14
+ it 'sets verbose off' do
15
+ expect(git.verbose).to eql false
16
+ end
17
+
14
18
  it 'throws if git is not installed' do
15
19
  allow_any_instance_of(SingularityDsl::GitHelper)
16
20
  .to receive(:git_installed)
@@ -20,6 +24,28 @@ describe 'GitHelper' do
20
24
  end
21
25
  end
22
26
 
27
+ context '#verbosity' do
28
+ it 'sets verbose to true when number > 0 given' do
29
+ git.verbosity 1
30
+ expect(git.verbose).to eql true
31
+ end
32
+
33
+ it 'sets verbose to true when true given' do
34
+ git.verbosity true
35
+ expect(git.verbose).to eql true
36
+ end
37
+
38
+ it 'sets verbose to false when number == 0 given' do
39
+ git.verbosity 0
40
+ expect(git.verbose).to eql false
41
+ end
42
+
43
+ it 'sets verbose to false when non-Fixnum given' do
44
+ git.verbosity 'wat'
45
+ expect(git.verbose).to eql false
46
+ end
47
+ end
48
+
23
49
  context '#clean_reset' do
24
50
  it 'fails when reset fails' do
25
51
  allow(git).to receive(:reset).and_return(1)
@@ -94,6 +94,7 @@ describe 'ShellTask' do
94
94
  it 'runs alternative command' do
95
95
  cmd = 'echo "hi :)"'
96
96
  alt = 'echo "no"'
97
+ sh_task.live_stream = false
97
98
  sh_task.command cmd
98
99
  sh_task.alt alt
99
100
  sh_task.condition 'ls -z'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singularity_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - chr0n1x