simple-cli 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fe1d22e8204e5a34ef9b543d0357d17dc7c5b5b
4
- data.tar.gz: 7211fa7d521310ea21a4646327fe78845e274412
3
+ metadata.gz: b7533ba5ce80d0d6f173f3bc5cc071ff22590977
4
+ data.tar.gz: 2e416315dbb0addf9eedaa7e84fc0cebaf17dfbc
5
5
  SHA512:
6
- metadata.gz: d3917ea01b33fff5dd5826c69334fe9138bd97c9fccabf4877d70b0a9406bdde6d485354ebfdbcf204e2b4e30142ebc16f5d199648127b0445e25594ecde9367
7
- data.tar.gz: aa8fa6cd5c1af25df3596c95411fcaa5449e3c3aaf3f15da7f62bf4ca886d7592b1f28533beb116d1e490bbe130e7f5faea93f188f1012975a569c95296242ab
6
+ metadata.gz: 552c4c85dd75a898b035b53bfc67d2d74b3e1f37569099d7fb6ec88e61827272d23f28a0252bf30bf674d817b64040f1c25e3606baf31860a2ae0c73eb2e6768
7
+ data.tar.gz: b58f646e7a7aefe93c66731d228e2f14dfe2266112da195041e0f13f580c4d22b9ce280a3b8eb0dc3809306d97151e69ac7fe5065bf3774bdaa5c51bd948cc08
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple-cli (0.2.1)
4
+ simple-cli (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -50,21 +50,20 @@ module Simple::CLI::Helpers
50
50
  end
51
51
 
52
52
  def sh
53
- STDERR.puts "> #{self}"
53
+ ::Simple::CLI.logger.info "> #{self}"
54
54
  stdout_str, @process_status = Open3.capture2(*@args, binmode: true)
55
55
  stdout_str
56
56
  end
57
57
 
58
58
  def run
59
- STDERR.puts "> #{self}"
60
- rv = if @args.length > 1
61
- system to_s
62
- else
63
- system @args.first
64
- end
65
-
59
+ ::Simple::CLI.logger.info "> #{self}"
60
+ if @args.length > 1
61
+ system to_s
62
+ else
63
+ system @args.first
64
+ end
65
+ ensure
66
66
  @process_status = $?
67
- rv
68
67
  end
69
68
 
70
69
  def success?
@@ -84,14 +84,16 @@ module Simple::CLI::Logger::ColoredLogger
84
84
  if log_level < Logger::INFO
85
85
  padding = " " * (90 - msg_length) if msg_length < 90
86
86
  msg = "#{msg}#{padding}"
87
-
88
- source = caller[2]
89
- source.gsub!( Dir.getwd, "." )
90
- source.gsub!( File.expand_path("~"), "~" )
91
-
92
- msg = "#{msg}from #{source}"
87
+ msg = "#{msg}from #{source_from_caller}"
93
88
  end
94
89
 
95
90
  STDERR.puts msg
96
91
  end
92
+
93
+ # The heuristic used to determine the caller is not perfect, but should
94
+ # do well in most cases.
95
+ def source_from_caller
96
+ source = caller.find { |loc| !loc.include? "/simple-cli/lib/simple/cli" }
97
+ source || caller[2]
98
+ end
97
99
  end
@@ -1,5 +1,5 @@
1
1
  module Simple
2
2
  module CLI
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel