hr 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hr.rb +20 -21
  3. data/lib/hr/version.rb +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06a46e52a822aa039b4d61b3b22e9e1dc3419bda
4
- data.tar.gz: 516e9615b22d19e2e424b7b55c8c7af88dec5700
3
+ metadata.gz: 6421274a8ce60eab245b26bd9dc85b407d5db3a0
4
+ data.tar.gz: a2a300116ccba8e9f5297cff57431a2216ee9a89
5
5
  SHA512:
6
- metadata.gz: 4945223d0acfa894904c9065a31124f0666ffe62df10ad0a86178adb7695fba7f9ae758920982ca20bb8d2aa1939781cc11f6da09a3b5dba9d926bb4feef1379
7
- data.tar.gz: 0392c2acd4a06f594e370bdf2e03e4ae13bd771395ad00aae259592d2d6a1f3b9ea2a2c12f5f647cbebb82e10dab65edf8133d58f222d7f46b92f0f470fa97d4
6
+ metadata.gz: 6c8d85fc275361b180da02ca0d6694aee9fb29b94c07b4d5768afb82f27adf51913a7488e0e72234fdc3d9cb48ec860450c93884902d68062b0b9a0e139ad330
7
+ data.tar.gz: 89885cc9839478d47ebfaf39bf643cbcca4fac61f44cbc49cc56c5fed90d9159935fadc7cda0d39b20f0088d00d8a8e8602c6ef637bdbf7cfa881a07fd7982d5
data/lib/hr.rb CHANGED
@@ -1,9 +1,27 @@
1
- require "hr/version"
2
- require "colorize"
1
+ require 'hr/version'
2
+ require 'colorize'
3
3
 
4
4
  module Hr
5
5
  extend self
6
6
 
7
+ def print(*patterns)
8
+ Kernel.print string(*patterns)
9
+ end
10
+
11
+ def string(*patterns)
12
+ options = patterns.last.is_a?(Hash) ? patterns.pop : {}
13
+ column_width = get_column_width
14
+ output = patterns.map do |pattern|
15
+ pattern = pattern.to_s
16
+ times = (column_width / pattern.length) + 1
17
+ (pattern * times)[0..column_width - 1]
18
+ end.join
19
+ options = options.inject({}){|tmp,(k,v)| tmp[k.to_sym] = v.to_sym; tmp}
20
+ options.any? ? output.colorize(options) : output
21
+ end
22
+
23
+ private
24
+
7
25
  def get_column_width
8
26
  column_width = 0
9
27
 
@@ -23,29 +41,10 @@ module Hr
23
41
  return column_width
24
42
  end
25
43
  end
26
-
27
- def print(*patterns)
28
- puts string(*patterns)
29
- end
30
-
31
- def string(*patterns)
32
- options = patterns.last.is_a?(Hash) ? patterns.pop : {}
33
- column_width = get_column_width
34
- output = patterns.map do |pattern|
35
- pattern = pattern.to_s
36
- times = (column_width / pattern.length) + 1
37
- (pattern * times)[0..column_width - 1]
38
- end.join("\n")
39
- options = options.inject({}){|tmp,(k,v)| tmp[k.to_sym] = v.to_sym; tmp}
40
- options.any? ? output.colorize(options) : output
41
- end
42
44
 
43
- private
44
-
45
45
  def command_exists?(command)
46
46
  ENV['PATH'].split(File::PATH_SEPARATOR).any? { |path|
47
47
  (File.exist? File.join(path, "#{command}")) || (File.exist? File.join(path, "#{command}.com")) || (File.exist? File.join(path, "#{command}.exe"))
48
48
  }
49
49
  end
50
-
51
50
  end
@@ -1,3 +1,3 @@
1
1
  module Hr
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Tse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-29 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.5.1
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Use hr to delimit your output for a better separation visually