hirb 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = "gabriel.horner@gmail.com"
10
10
  s.homepage = "http://tagaholic.me/hirb/"
11
11
  s.summary = "A mini view framework for console/irb that's easy to use, even while under its influence."
12
- s.description = "Hirb provides a mini view framework for console applications and uses it to improve irb's default inspect output. Given an object or array of objects, hirb renders a view based on the object's class and/or ancestry. Hirb offers reusable views in the form of helper classes. The two main helpers, Hirb::Helpers::Table and Hirb::Helpers::Tree, provide several options for generating ascii tables and trees. Using Hirb::Helpers::AutoTable, hirb has useful default views for at least ten popular database gems i.e. Rails' ActiveRecord::Base. Other than views, hirb offers a smart pager and a console menu. The smart pager only pages when the output exceeds the current screen size. The menu is used in conjunction with tables to offer two dimensional menus."
12
+ s.description = "Hirb provides a mini view framework for console applications and uses it to improve ripl(irb)'s default inspect output. Given an object or array of objects, hirb renders a view based on the object's class and/or ancestry. Hirb offers reusable views in the form of helper classes. The two main helpers, Hirb::Helpers::Table and Hirb::Helpers::Tree, provide several options for generating ascii tables and trees. Using Hirb::Helpers::AutoTable, hirb has useful default views for at least ten popular database gems i.e. Rails' ActiveRecord::Base. Other than views, hirb offers a smart pager and a console menu. The smart pager only pages when the output exceeds the current screen size. The menu is used in conjunction with tables to offer two dimensional menus."
13
13
  s.required_rubygems_version = ">= 1.3.5"
14
14
  s.rubyforge_project = 'tagaholic'
15
15
  s.add_development_dependency 'bacon', '>= 1.1.0'
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.3.6
2
+ * Tweak ripl support
3
+ * Allow override of :hirb_number thanks to asanghi.
4
+ * Fix Hirb.add_view to work with class which inherits Hash
5
+
1
6
  == 0.3.5
2
7
  * Add ripl support
3
8
  * Fix Formatter#determine_output_class for IO and Hash
data/README.rdoc CHANGED
@@ -2,7 +2,7 @@ To read a linked version of this README, {click here}[http://tagaholic.me/hirb/d
2
2
 
3
3
  == Description
4
4
 
5
- Hirb provides a mini view framework for console applications and uses it to improve irb's default inspect output.
5
+ Hirb provides a mini view framework for console applications and uses it to improve ripl(irb)'s default inspect output.
6
6
  Given an object or array of objects, hirb renders a view based on the object's class and/or ancestry. Hirb offers reusable
7
7
  views in the form of helper classes. The two main helpers, Hirb::Helpers::Table and Hirb::Helpers::Tree, provide several options
8
8
  for generating ascii tables and trees. Using Hirb::Helpers::AutoTable, hirb has useful default views for at least ten popular database gems
@@ -14,7 +14,7 @@ only pages when the output exceeds the current screen size. The menu is used in
14
14
 
15
15
  Install the gem with:
16
16
 
17
- sudo gem install hirb
17
+ gem install hirb
18
18
 
19
19
  == View Tutorials
20
20
 
@@ -159,14 +159,14 @@ views for certain classes, put them under lib/hirb/views. Please submit views fo
159
159
  number of users.
160
160
 
161
161
  == Limitations
162
- If using Wirble, you should call Hirb after it since they both override irb's default output.
162
+ If using Wirble and irb, you should call Hirb after it since they both override irb's default output.
163
163
 
164
164
  == Motivation
165
165
  Table code from http://gist.github.com/72234 and {my console app's needs}[http://github.com/cldwalker/tag-tree].
166
166
 
167
167
  == Credits
168
168
  * Chrononaut for vertical table helper.
169
- * crafterm, spastorino, xaviershay, bogdan and joshua for patches.
169
+ * crafterm, spastorino, xaviershay, bogdan, asanghi and joshua for patches.
170
170
 
171
171
  == Bugs/Issues
172
172
  Please report them {on github}[http://github.com/cldwalker/hirb/issues].
@@ -2,7 +2,7 @@ module Hirb
2
2
  # A Formatter object formats an output object (using Formatter.format_output) into a string based on the views defined
3
3
  # for its class and/or ancestry.
4
4
  class Formatter
5
- TO_A_EXCEPTIONS = ['Hash', 'IO']
5
+ TO_A_EXCEPTIONS = [Hash, IO]
6
6
 
7
7
  class<<self
8
8
  # This config is used by Formatter.format_output to lazily load dynamic views defined with Hirb::DynamicView.
@@ -77,7 +77,7 @@ module Hirb
77
77
  end
78
78
 
79
79
  def determine_output_class(output)
80
- output.respond_to?(:to_a) && !TO_A_EXCEPTIONS.include?(output.class.to_s) ?
80
+ output.respond_to?(:to_a) && !TO_A_EXCEPTIONS.any? {|e| output.is_a?(e) } ?
81
81
  Array(output)[0].class : output.class
82
82
  end
83
83
 
@@ -128,7 +128,7 @@ module Hirb
128
128
  @rows = set_rows(rows)
129
129
  @headers = set_headers
130
130
  if @options[:number]
131
- @headers[:hirb_number] = "number"
131
+ @headers[:hirb_number] ||= "number"
132
132
  @fields.unshift :hirb_number
133
133
  end
134
134
  Helpers::Table.last_table = self
data/lib/hirb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hirb
2
- VERSION = '0.3.5'
2
+ VERSION = '0.3.6'
3
3
  end
data/lib/ripl/hirb.rb CHANGED
@@ -1,8 +1,9 @@
1
+ require 'hirb'
2
+
1
3
  module Ripl::Hirb
2
4
  def before_loop
3
5
  super
4
- require 'hirb'
5
- Hirb.enable(Ripl.config[:hirb] || {}) unless Hirb::View.enabled?
6
+ Hirb.enable(Ripl.config[:hirb] || {})
6
7
  end
7
8
 
8
9
  def format_result(result)
@@ -72,10 +72,15 @@ describe "Formatter" do
72
72
  @formatter.parse_console_options(options).should == expected_options
73
73
  end
74
74
 
75
- it "#determine_output_class has exceptions for to_a" do
75
+ it "#determine_output_class bypasses exceptions for to_a" do
76
76
  @formatter.determine_output_class(STDOUT).should == IO
77
77
  @formatter.determine_output_class({:a=>1}).should == Hash
78
78
  end
79
+
80
+ it "#determine_output_class bypasses subclasses of exceptions for to_a" do
81
+ class Hash2 < Hash; end
82
+ @formatter.determine_output_class(Hash2[1=>2]).should == Hash2
83
+ end
79
84
  end
80
85
 
81
86
  describe "format_output" do
data/test/table_test.rb CHANGED
@@ -361,6 +361,19 @@ describe "Table" do
361
361
  table([['a','b'], ['c', 'd']], :number=>true).should == expected_table
362
362
  end
363
363
 
364
+ it "number option renders with header that can be overridden" do
365
+ expected_table = <<-TABLE.unindent
366
+ +----+---+---+
367
+ | SR | 0 | 1 |
368
+ +----+---+---+
369
+ | 1 | a | b |
370
+ | 2 | c | d |
371
+ +----+---+---+
372
+ 2 rows in set
373
+ TABLE
374
+ table([['a','b'], ['c', 'd']], :number=>true, :headers => {:hirb_number => "SR"}).should == expected_table
375
+ end
376
+
364
377
  it "description option false renders" do
365
378
  expected_table = <<-TABLE.unindent
366
379
  +---+---+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hirb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 5
10
- version: 0.3.5
9
+ - 6
10
+ version: 0.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gabriel Horner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-08 00:00:00 -05:00
18
+ date: 2011-01-08 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: "0"
77
77
  type: :development
78
78
  version_requirements: *id004
79
- description: Hirb provides a mini view framework for console applications and uses it to improve irb's default inspect output. Given an object or array of objects, hirb renders a view based on the object's class and/or ancestry. Hirb offers reusable views in the form of helper classes. The two main helpers, Hirb::Helpers::Table and Hirb::Helpers::Tree, provide several options for generating ascii tables and trees. Using Hirb::Helpers::AutoTable, hirb has useful default views for at least ten popular database gems i.e. Rails' ActiveRecord::Base. Other than views, hirb offers a smart pager and a console menu. The smart pager only pages when the output exceeds the current screen size. The menu is used in conjunction with tables to offer two dimensional menus.
79
+ description: Hirb provides a mini view framework for console applications and uses it to improve ripl(irb)'s default inspect output. Given an object or array of objects, hirb renders a view based on the object's class and/or ancestry. Hirb offers reusable views in the form of helper classes. The two main helpers, Hirb::Helpers::Table and Hirb::Helpers::Tree, provide several options for generating ascii tables and trees. Using Hirb::Helpers::AutoTable, hirb has useful default views for at least ten popular database gems i.e. Rails' ActiveRecord::Base. Other than views, hirb offers a smart pager and a console menu. The smart pager only pages when the output exceeds the current screen size. The menu is used in conjunction with tables to offer two dimensional menus.
80
80
  email: gabriel.horner@gmail.com
81
81
  executables: []
82
82