hirb 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_development_dependency 'mocha', '>= 0.9.8'
16
16
  s.add_development_dependency 'mocha-on-bacon', '>= 0.1.1'
17
17
  s.add_development_dependency 'bacon-bits'
18
- s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec .travis.yml}
18
+ s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} {.,test,spec}/deps.rip]) + %w{Rakefile .gemspec .travis.yml}
19
19
  s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
20
20
  s.license = 'MIT'
21
21
  end
@@ -1,5 +1,5 @@
1
1
  before_install: bundle init --gemspec=.gemspec
2
- script: bacon -q -Ilib -I. test/*_test.rb
2
+ script: MOCHA_OPTIONS=skip_integration bacon -q -Ilib -I. test/*_test.rb
3
3
  rvm:
4
4
  - 1.8.7
5
5
  - 1.9.2
@@ -1,3 +1,6 @@
1
+ == 0.7.0
2
+ * Add github markdown table
3
+
1
4
  == 0.6.2
2
5
  * Add * support to 1d/2d menus
3
6
 
@@ -115,6 +115,12 @@ tables/views for any output object:
115
115
  └───┴───┴───┘
116
116
  1 row in set
117
117
 
118
+ # Creates github-markdown
119
+ >> table [[:a, :b :c]], :markdown => true
120
+ | 0 | 1 | 2 |
121
+ |---|---|---|
122
+ | a | b | c |
123
+
118
124
  # Create a table of Dates comparing them with different formats.
119
125
  >> table [Date.today, Date.today.next_month], :fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
120
126
  +------------+--------+-----------+-------+--------------------------+
@@ -180,6 +186,7 @@ Table code from http://gist.github.com/72234 and {my console app's needs}[http:/
180
186
  == Credits
181
187
  * Chrononaut for vertical table helper.
182
188
  * janlelis for unicode table helper.
189
+ * technogeeky and FND for markdown table helper.
183
190
  * hsume2, crafterm, spastorino, xaviershay, bogdan, asanghi, vwall and joshua for patches.
184
191
 
185
192
  == Bugs/Issues
@@ -13,6 +13,6 @@ module Hirb
13
13
  end
14
14
 
15
15
  %w{table object_table auto_table tree parent_child_tree vertical_table
16
- unicode_table tab_table}.each do |e|
16
+ markdown_table unicode_table tab_table}.each do |e|
17
17
  require "hirb/helpers/#{e}"
18
18
  end
@@ -0,0 +1,14 @@
1
+ # Creates a markdown table for github
2
+ class Hirb::Helpers::MarkdownTable < Hirb::Helpers::Table
3
+ CHARS = {
4
+ :top => {:left => '', :center => '', :right => '', :horizontal => '',
5
+ :vertical => {:outside => '|', :inside => ' | '} },
6
+ :middle => {:left => '|', :center => ' | ', :right => '|', :horizontal => '-'},
7
+ :bottom => {:left => '', :center => '', :right => '', :horizontal => '',
8
+ :vertical => {:outside => '|', :inside => ' | '} }
9
+ }
10
+
11
+ def self.render(rows, options={})
12
+ new(rows, options).render
13
+ end
14
+ end
@@ -113,7 +113,8 @@ module Hirb
113
113
  options[:vertical] ? Helpers::VerticalTable.render(rows, options) :
114
114
  options[:unicode] ? Helpers::UnicodeTable.render(rows, options) :
115
115
  options[:tab] ? Helpers::TabTable.render(rows, options) :
116
- new(rows, options).render
116
+ options[:markdown] ? Helpers::MarkdownTable.render(rows, options) :
117
+ new(rows, options).render
117
118
  rescue TooManyFieldsForWidthError
118
119
  $stderr.puts "", "** Hirb Warning: Too many fields for the current width. Configure your width " +
119
120
  "and/or fields to avoid this error. Defaulting to a vertical table. **"
@@ -1,3 +1,3 @@
1
1
  module Hirb
2
- VERSION = '0.6.2'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -506,6 +506,30 @@ describe "Table" do
506
506
  should == expected_table
507
507
  end
508
508
 
509
+ it "markdown option renders" do
510
+ expected_table = <<-TABLE.chomp
511
+ | a | b |
512
+ |--- | ---|
513
+ | 1 | 2 |
514
+ | 3 | 4 |
515
+
516
+ 2 rows in set
517
+ TABLE
518
+ table([{:a=>1, :b=>2}, {:a=>3, :b=>4}], :markdown => true).
519
+ should == "\n#{expected_table}"
520
+ end
521
+
522
+ it "markdown option with no headers renders" do
523
+ expected_table = <<-TABLE.chomp
524
+ | 1 | 2 |
525
+ | 3 | 4 |
526
+
527
+ 2 rows in set
528
+ TABLE
529
+ table([{:a=>1, :b=>2}, {:a=>3, :b=>4}], :markdown => true, :headers => false).
530
+ should == "\n#{expected_table}"
531
+ end
532
+
509
533
  it "all_fields option renders all fields" do
510
534
  expected_table = <<-TABLE.unindent
511
535
  +---+---+---+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hirb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-19 00:00:00.000000000Z
12
+ date: 2012-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
16
- requirement: &70183088619280 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.1.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70183088619280
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.1.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: mocha
27
- requirement: &70183088618780 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 0.9.8
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70183088618780
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.8
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: mocha-on-bacon
38
- requirement: &70183088617940 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.1.1
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70183088617940
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.1
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: bacon-bits
49
- requirement: &70183088617440 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70183088617440
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: Hirb provides a mini view framework for console applications and uses
59
79
  it to improve ripl(irb)'s default inspect output. Given an object or array of objects,
60
80
  hirb renders a view based on the object's class and/or ancestry. Hirb offers reusable
@@ -77,6 +97,7 @@ files:
77
97
  - lib/hirb/dynamic_view.rb
78
98
  - lib/hirb/formatter.rb
79
99
  - lib/hirb/helpers/auto_table.rb
100
+ - lib/hirb/helpers/markdown_table.rb
80
101
  - lib/hirb/helpers/object_table.rb
81
102
  - lib/hirb/helpers/parent_child_tree.rb
82
103
  - lib/hirb/helpers/tab_table.rb
@@ -146,10 +167,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
167
  version: 1.3.5
147
168
  requirements: []
148
169
  rubyforge_project:
149
- rubygems_version: 1.8.15
170
+ rubygems_version: 1.8.24
150
171
  signing_key:
151
172
  specification_version: 3
152
173
  summary: A mini view framework for console/irb that's easy to use, even while under
153
174
  its influence.
154
175
  test_files: []
155
- has_rdoc: