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 +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +7 -0
- data/lib/hirb/helpers.rb +1 -1
- data/lib/hirb/helpers/markdown_table.rb +14 -0
- data/lib/hirb/helpers/table.rb +2 -1
- data/lib/hirb/version.rb +1 -1
- data/test/table_test.rb +24 -0
- metadata +32 -12
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}
|
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
|
data/.travis.yml
CHANGED
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -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
|
data/lib/hirb/helpers.rb
CHANGED
@@ -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
|
data/lib/hirb/helpers/table.rb
CHANGED
@@ -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
|
-
|
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. **"
|
data/lib/hirb/version.rb
CHANGED
data/test/table_test.rb
CHANGED
@@ -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.
|
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-
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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.
|
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:
|