simple-ui 0.2.0 → 0.2.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/simple/ui.rb +23 -8
  3. metadata +8 -16
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c18ccfabbea93ecbc590439a90bfc0aa09850598
4
+ data.tar.gz: 3f2596b7ce3fb1d4f0baa1e12e133727665b0450
5
+ SHA512:
6
+ metadata.gz: a65a08e6f3fcaec384df3eb8a14e29101047b01211019e927bec603ba197110cc9b4024ed2cae6878c4a4cb1402d6e2d7459c671fc158b34bdfdeeb61c394648
7
+ data.tar.gz: 3486021a89eac2b3b2d0b24df83f2ecaa1463fbde371e2e88ed5cca722923b6b330d385f0e1195909a14dc3567e9fbb5c1d8a8434da76e36a59eb0c67d5d6c6c
@@ -1,7 +1,7 @@
1
1
  module UI
2
2
  extend self
3
3
 
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
 
6
6
  def self.verbosity
7
7
  @verbosity ||= 1
@@ -82,9 +82,21 @@ module UI
82
82
  UI.log severity, msg, *args
83
83
  end
84
84
  end
85
+
86
+ def self.colored=(colored)
87
+ @colored = colored
88
+ end
85
89
 
86
- private
90
+ def self.colored?
91
+ if @colored.nil?
92
+ @colored = STDERR.tty?
93
+ end
94
+
95
+ @colored != false
96
+ end
87
97
 
98
+ private
99
+
88
100
  def self.log(sym, msg, *args)
89
101
  rv = args.empty? ? msg : args.first
90
102
 
@@ -94,16 +106,19 @@ module UI
94
106
  msg += ": " + args.map(&:inspect).join(", ")
95
107
  end
96
108
 
97
- timestamp = "[%3d msecs]" % (1000 * (Time.now - @@started_at))
98
-
99
- msg = "#{timestamp} #{msg}"
100
-
101
- if color = COLORS[MESSAGE_COLOR[sym]]
109
+ if color = colored? && COLORS[MESSAGE_COLOR[sym]]
102
110
  msg = "#{color}#{msg}#{COLORS[:clear]}"
103
111
  end
104
112
 
113
+ if verbosity > 2
114
+ source = caller[1]
115
+ source.gsub!( Dir.getwd, "." )
116
+ source.gsub!( File.expand_path("~"), "~" )
117
+ msg = "%-90s from: %s" % [ msg, source ]
118
+ end
119
+
105
120
  STDERR.puts msg
106
-
121
+
107
122
  rv
108
123
  end
109
124
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - radiospiel
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-22 00:00:00.000000000 Z
11
+ date: 2014-01-17 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Simple code for simple things in the console
15
14
  email: eno@radiospiel.org
@@ -17,38 +16,31 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
- - lib/simple/ui.rb
21
19
  - README.md
20
+ - lib/simple/ui.rb
22
21
  - test/simple_ui_test.rb
23
22
  - test/test_helper.rb
24
23
  homepage: http://github.com/radiospiel/simple-ui
25
24
  licenses: []
25
+ metadata: {}
26
26
  post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
- none: false
32
31
  requirements:
33
- - - ! '>='
32
+ - - '>='
34
33
  - !ruby/object:Gem::Version
35
34
  version: '0'
36
- segments:
37
- - 0
38
- hash: -1669227376838210990
39
35
  required_rubygems_version: !ruby/object:Gem::Requirement
40
- none: false
41
36
  requirements:
42
- - - ! '>='
37
+ - - '>='
43
38
  - !ruby/object:Gem::Version
44
39
  version: '0'
45
- segments:
46
- - 0
47
- hash: -1669227376838210990
48
40
  requirements: []
49
41
  rubyforge_project:
50
- rubygems_version: 1.8.25
42
+ rubygems_version: 2.2.1
51
43
  signing_key:
52
- specification_version: 3
44
+ specification_version: 4
53
45
  summary: Simple code for simple things in the console
54
46
  test_files: []