hirb 0.7.2 → 0.7.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63eebbe2f2657b717673929d5b303affc2c849df
4
- data.tar.gz: 2c1da1921ad7add89f10e4d0b753816ecb405fa0
3
+ metadata.gz: 3c82103d6a98efbf7551286da42328fe06933713
4
+ data.tar.gz: 007e3755d06c41814d5b3e80731f55c4b4cd47ff
5
5
  SHA512:
6
- metadata.gz: e40f5b24ece8d59b22c71f2a8a6afe35d4312410ff0e81dc68c9adfe2955bc309adb44dbb4867ce129f60bbafd21586b1551fba154643fcaafb4d29c20897ada
7
- data.tar.gz: 81ca4fa29e19da305c949d48ca5c057cff2f78a985ab82b643e8dbbfa40a6baa74df2535cd08fa0860113f2e8a00d57b5316e590d4da4f11a4f42bbcfb9581e9
6
+ metadata.gz: aad1ff6678f0a2b1a33aeeaf5ccf2cf647c96e9d0e4e077efec0e22c3c77ab3892534cba9810709b16b6f9729233658fe191ef206358f9c73e92db8b7677f938
7
+ data.tar.gz: 97a34adef83202ddfe42e989b8ef4ef639ce35b077258ca415af034f6cec0ba40be3786ffafd73030233ad4d82eabe23c8a31306a68627d7c6996d50cf0669cf
@@ -1,3 +1,6 @@
1
+ == 0.7.3
2
+ * Remove warnings
3
+
1
4
  == 0.7.2
2
5
  * Allow full paths on $PAGER
3
6
  * Fix AR tables with no id column
@@ -190,7 +190,8 @@ Table code from http://gist.github.com/72234 and {my console app's needs}[http:/
190
190
  * Chrononaut for vertical table helper.
191
191
  * janlelis for unicode table helper.
192
192
  * technogeeky and FND for markdown table helper.
193
- * hsume2, crafterm, spastorino, xaviershay, bogdan, asanghi, vwall, maxmeyer, jimjh, ddoherty03 and joshua for patches.
193
+ * hsume2, crafterm, spastorino, xaviershay, bogdan, asanghi, vwall, maxmeyer, jimjh, ddoherty03,
194
+ rochefort and joshua for patches.
194
195
 
195
196
  == Bugs/Issues
196
197
  Please report them {on github}[http://github.com/cldwalker/hirb/issues].
@@ -34,8 +34,8 @@ module Hirb
34
34
  attr_accessor :config_files, :config
35
35
 
36
36
  # Enables view functionality. See Hirb::View.enable for details.
37
- def enable(options={}, &block)
38
- View.enable(options, &block)
37
+ def enable(options={})
38
+ View.enable(options)
39
39
  end
40
40
 
41
41
  # Disables view functionality. See Hirb::View.disable for details.
@@ -44,8 +44,8 @@ module Hirb
44
44
  end
45
45
 
46
46
  # Adds views. See Hirb::View.add for details.
47
- def add_view(view, options, &block)
48
- View.add(view, options, &block)
47
+ def add_view(view, options)
48
+ View.add(view, options)
49
49
  end
50
50
 
51
51
  # Adds views. See Hirb::DynamicView.add for details.
@@ -55,6 +55,7 @@ module Hirb
55
55
 
56
56
  # Array of config files which are merged sequentially to produce config.
57
57
  # Defaults to config/hirb.yml and ~/.hirb_yml
58
+ undef :config_files
58
59
  def config_files
59
60
  @config_files ||= default_config_files
60
61
  end
@@ -62,13 +63,14 @@ module Hirb
62
63
  #:stopdoc:
63
64
  def default_config_files
64
65
  [File.join(Util.find_home, ".hirb.yml")] +
65
- (File.exists?('config/hirb.yml') ? ['config/hirb.yml'] : [])
66
+ (File.exist?('config/hirb.yml') ? ['config/hirb.yml'] : [])
66
67
  end
67
68
 
68
69
  def read_config_file(file=config_file)
69
- File.exists?(file) ? YAML::load_file(file) : {}
70
+ File.exist?(file) ? YAML.load_file(file) : {}
70
71
  end
71
72
 
73
+ undef :config
72
74
  def config(reload=false)
73
75
  if (@config.nil? || reload)
74
76
  @config = config_files.inject({}) {|acc,e|
@@ -29,7 +29,7 @@ module Hirb
29
29
  # [*:options*] Options to pass the helper method or class.
30
30
  # [*:ancestor*] Boolean which when true causes subclasses of the output class to inherit its config. This doesn't effect the current
31
31
  # output class. Defaults to false. This is used by ActiveRecord classes.
32
- #
32
+ #
33
33
  # Examples:
34
34
  # {'WWW::Delicious::Element'=>{:class=>'Hirb::Helpers::ObjectTable', :ancestor=>true, :options=>{:max_width=>180}}}
35
35
  # {'Date'=>{:class=>:auto_table, :ancestor=>true}}
@@ -101,10 +101,10 @@ module Hirb
101
101
  def build_klass_config(output_class)
102
102
  output_ancestors = output_class.ancestors.map {|e| e.to_s}.reverse
103
103
  output_ancestors.pop
104
- hash = output_ancestors.inject({}) {|h, klass|
105
- add_klass_config_if_true(h, klass) {|c,klass| c[klass] && c[klass][:ancestor] }
104
+ hash = output_ancestors.inject({}) {|h, ancestor_klass|
105
+ add_klass_config_if_true(h, ancestor_klass) {|c, klass| c[klass] && c[klass][:ancestor] }
106
106
  }
107
- add_klass_config_if_true(hash, output_class.to_s) {|c,klass| c[klass] }
107
+ add_klass_config_if_true(hash, output_class.to_s) {|c, klass| c[klass] }
108
108
  end
109
109
 
110
110
  def add_klass_config_if_true(hash, klass)
@@ -302,6 +302,7 @@ class Helpers::Table
302
302
  max_fields.each {|k,max| @field_lengths[k] = max if @field_lengths[k].to_i > max }
303
303
  end
304
304
 
305
+ undef :max_fields
305
306
  def max_fields
306
307
  @max_fields ||= (@options[:max_fields] ||= {}).each {|k,v|
307
308
  @options[:max_fields][k] = (actual_width * v.to_f.abs).floor if v.to_f.abs < 1
@@ -312,6 +313,7 @@ class Helpers::Table
312
313
  @actual_width ||= self.width - (@fields.size * BORDER_LENGTH + 1)
313
314
  end
314
315
 
316
+ undef :width
315
317
  def width
316
318
  @width ||= @options[:max_width] || View.width
317
319
  end
@@ -48,7 +48,7 @@ class Hirb::Helpers::Table
48
48
 
49
49
  # set all fields the same if relative doesn't work
50
50
  unless new_lengths.values.all? {|e| e > MIN_FIELD_LENGTH} && (sum(new_lengths.values) <= @width)
51
- new_lengths = @field_lengths.inject({}) {|t,(k,v)| t[k] = @width / @field_size; t }
51
+ new_lengths = @field_lengths.inject({}) {|t,(k,_v)| t[k] = @width / @field_size; t }
52
52
  end
53
53
  @field_lengths.each {|k,v| @field_lengths[k] = new_lengths[k] }
54
54
  end
@@ -89,7 +89,7 @@ module Hirb
89
89
  def choose_from_menu
90
90
  return unasked_choice if @output.size == 1 && !@options[:ask]
91
91
 
92
- if (helper_class = Util.any_const_get(@options[:helper_class]))
92
+ if (Util.any_const_get(@options[:helper_class]))
93
93
  View.render_output(@output, :class=>@options[:helper_class], :options=>@options.merge(:number=>true))
94
94
  else
95
95
  @output.each_with_index {|e,i| puts "#{i+1}: #{e}" }
@@ -13,7 +13,7 @@ module Hirb
13
13
  }
14
14
  klass
15
15
  rescue
16
- nil
16
+ nil
17
17
  end
18
18
  end
19
19
 
@@ -53,7 +53,7 @@ module Hirb
53
53
 
54
54
  # Determines if a shell command exists by searching for it in ENV['PATH'].
55
55
  def command_exists?(command)
56
- ENV['PATH'].split(File::PATH_SEPARATOR).any? {|d| File.exists? File.join(d, command) }
56
+ ENV['PATH'].split(File::PATH_SEPARATOR).any? {|d| File.exist? File.join(d, command) }
57
57
  end
58
58
 
59
59
  # Returns [width, height] of terminal when detected, nil if not detected.
@@ -1,3 +1,3 @@
1
1
  module Hirb
2
- VERSION = '0.7.2'
2
+ VERSION = '0.7.3'
3
3
  end
@@ -22,7 +22,7 @@ module Hirb
22
22
  # >> {:a=>1, :b=>{:c=>3}}
23
23
  # ---
24
24
  # :a : 1
25
- # :b :
25
+ # :b :
26
26
  # :c : 3
27
27
  # => true
28
28
  #
@@ -75,7 +75,7 @@ module Hirb
75
75
  # Examples:
76
76
  # Hirb.enable
77
77
  # Hirb.enable :formatter=>false
78
- def enable(options={}, &block)
78
+ def enable(options={})
79
79
  Array(options.delete(:config_file)).each {|e|
80
80
  @new_config_file = true
81
81
  Hirb.config_files << e
@@ -115,9 +115,9 @@ module Hirb
115
115
  config[:width], config[:height] = determine_terminal_size(width, height)
116
116
  pager.resize(config[:width], config[:height])
117
117
  end
118
-
118
+
119
119
  # This is the main method of this class. When view is enabled, this method searches for a formatter it can use for the output and if
120
- # successful renders it using render_method(). The options this method takes are helper config hashes as described in
120
+ # successful renders it using render_method(). The options this method takes are helper config hashes as described in
121
121
  # Hirb::Formatter.format_output(). Returns true if successful and false if no formatting is done or if not enabled.
122
122
  def view_output(output, options={})
123
123
  enabled? && config[:formatter] && render_output(output, options)
@@ -127,7 +127,7 @@ module Hirb
127
127
  false
128
128
  else
129
129
  index = (obj = e.backtrace.find {|f| f =~ /^\(eval\)/}) ? e.backtrace.index(obj) : e.backtrace.length
130
- $stderr.puts "Hirb Error: #{e.message}", e.backtrace.slice(0,index).map {|e| " " + e }
130
+ $stderr.puts "Hirb Error: #{e.message}", e.backtrace.slice(0,index).map {|_e| " " + _e }
131
131
  true
132
132
  end
133
133
  end
@@ -140,6 +140,7 @@ module Hirb
140
140
  # A lambda or proc which handles the final formatted object.
141
141
  # Although this pages/puts the object by default, it could be set to do other things
142
142
  # i.e. write the formatted object to a file.
143
+ undef :render_method
143
144
  def render_method
144
145
  @render_method ||= default_render_method
145
146
  end
@@ -148,7 +149,7 @@ module Hirb
148
149
  def reset_render_method
149
150
  @render_method = default_render_method
150
151
  end
151
-
152
+
152
153
  # Current console width
153
154
  def width
154
155
  config && config[:width] ? config[:width] : DEFAULT_WIDTH
@@ -253,10 +254,11 @@ module Hirb
253
254
 
254
255
  def config_loaded?; !!@config; end
255
256
 
257
+ undef :config
256
258
  def config
257
259
  @config
258
260
  end
259
-
261
+
260
262
  def default_render_method
261
263
  lambda {|output| page_output(output) || puts(output) }
262
264
  end
@@ -6,17 +6,17 @@ describe "Hirb" do
6
6
 
7
7
  it "config converts yaml when config file exists" do
8
8
  yaml_data = {:blah=>'blah'}
9
- File.stubs('exists?').returns(true)
9
+ File.stubs('exist?').returns(true)
10
10
  Hirb.config_files = ['ok']
11
- YAML::expects(:load_file).returns(yaml_data)
11
+ YAML.expects(:load_file).returns(yaml_data)
12
12
  Hirb.config.should == yaml_data
13
13
  end
14
-
14
+
15
15
  it "config defaults to hash when no config file" do
16
- File.stubs('exists?').returns(false)
16
+ File.stubs('exist?').returns(false)
17
17
  Hirb.config.should == {}
18
18
  end
19
-
19
+
20
20
  it "config reloads if given explicit reload" do
21
21
  Hirb.config
22
22
  Hirb.expects(:read_config_file).returns({})
@@ -36,4 +36,4 @@ describe "Hirb" do
36
36
  Hirb.config_files[0].class.should == String
37
37
  ENV["HOME"] = home
38
38
  end
39
- end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hirb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Horner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-27 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bacon
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: 1.3.5
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.2.0
160
+ rubygems_version: 2.4.5
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: A mini view framework for console/irb that's easy to use, even while under