hirber 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gemspec +6 -4
- data/README.md +230 -0
- data/README.rdoc +7 -1
- data/lib/hirb/version.rb +1 -1
- data/lib/{hirb.rb → hirber.rb} +0 -0
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f82bfadd2b8b049d1c15f89b451b52ca891af4bff93b81c218f970bf741e5253
|
4
|
+
data.tar.gz: df5d9ac56a1026c4c54e4d50cec1a912459d9a646e1810444575727c04654d98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71b44ebf48bf2a7198daba593cdca90582a3ba50f1d0f3b907000a798e7c7caa7d062c1fa09346d5d4c93451ff97ce7e4ef3a0774add562be7819a66bc4a6533
|
7
|
+
data.tar.gz: 84f974edc8579002d547eb3c0025faa9285a9fe9c31d730da0294273b12dd5c4e53f0c72162a75489a9ab5da37b1cf8c9d0112f0a5ade8420f8c3e73edfdd500
|
data/.gemspec
CHANGED
@@ -11,10 +11,12 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = "A mini view framework for console/irb that's easy to use, even while under its influence."
|
12
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
|
-
|
15
|
-
s.add_development_dependency
|
16
|
-
s.add_development_dependency
|
17
|
-
s.add_development_dependency
|
14
|
+
|
15
|
+
s.add_development_dependency "bacon", "~> 1.1"
|
16
|
+
s.add_development_dependency "mocha", "~> 0.12.1"
|
17
|
+
s.add_development_dependency "mocha-on-bacon", "~> 0.2.1"
|
18
|
+
s.add_development_dependency "bacon-bits", "~> 0.1"
|
19
|
+
|
18
20
|
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc,md} ext/**/*.{rb,c}]) + %w{Rakefile .gemspec .travis.yml}
|
19
21
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
20
22
|
s.license = 'MIT'
|
data/README.md
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
## Preface
|
2
|
+
|
3
|
+
This gem is a direct fork of [Hirb](https://github.com/cldwalker/hirb) (0.7.3)
|
4
|
+
which appears to be unmaintained since 2015. New release of Ruby (2.7.2)
|
5
|
+
introduced a breaking change into one of the methods in IRB module, which made
|
6
|
+
this Gem partially unusable. This fork aims to fix incompatibility. Feel free
|
7
|
+
to open PRs if you have any ideas to extend the functionality.
|
8
|
+
|
9
|
+
## Description
|
10
|
+
|
11
|
+
Hirb provides a mini view framework for console applications and uses it to
|
12
|
+
improve ripl(irb)'s default inspect output. Given an object or array of
|
13
|
+
objects, hirb renders a view based on the object's class and/or ancestry. Hirb
|
14
|
+
offers reusable views in the form of helper classes. The two main helpers,
|
15
|
+
Hirb::Helpers::Table and Hirb::Helpers::Tree, provide several options for
|
16
|
+
generating ascii tables and trees. Using Hirb::Helpers::AutoTable, hirb has
|
17
|
+
useful default views for at least ten popular database gems i.e. Rails'
|
18
|
+
ActiveRecord::Base. Other than views, hirb offers a smart pager and a console
|
19
|
+
menu. The smart pager only pages when the output exceeds the current screen
|
20
|
+
size. The menu is used in conjunction with tables to offer [two dimensional menus](http://tagaholic.me/2010/02/16/two-dimensional-console-menus-with-hirb.html).
|
21
|
+
|
22
|
+
## Install
|
23
|
+
|
24
|
+
Install the gem with:
|
25
|
+
|
26
|
+
gem install hirb
|
27
|
+
|
28
|
+
For people using full-width unicode characters, install
|
29
|
+
[hirb-unicode](https://github.com/miaout17/hirb-unicode):
|
30
|
+
|
31
|
+
gem install hirb-unicode
|
32
|
+
|
33
|
+
## View Tutorials
|
34
|
+
|
35
|
+
* To create and configure views, see Hirb::View or [here if on the web](http://tagaholic.me/hirb/doc/classes/Hirb/View.html).
|
36
|
+
* To create dynamic views, see Hirb::DynamicView or [here if on the web](http://tagaholic.me/hirb/doc/classes/Hirb/DynamicView.html).
|
37
|
+
|
38
|
+
## Printing Ascii Tables
|
39
|
+
|
40
|
+
To print ascii tables from an array of arrays, hashes or any objects:
|
41
|
+
|
42
|
+
puts Hirb::Helpers::AutoTable.render(ARRAY_OF_OBJECTS)
|
43
|
+
|
44
|
+
Hirb will intelligently pick up on field names from an array of hashes and
|
45
|
+
create properly-aligned fields from an array of arrays. See
|
46
|
+
[here](http://tagaholic.me/2009/10/15/boson-and-hirb-interactions.html#hirbs_handy_tables) for examples.
|
47
|
+
|
48
|
+
## Rails Example
|
49
|
+
|
50
|
+
Let's load and enable the view framework:
|
51
|
+
$ rails console
|
52
|
+
Loading local environment (Rails 3.0.3)
|
53
|
+
>> require 'hirb'
|
54
|
+
=> true
|
55
|
+
>> Hirb.enable
|
56
|
+
=> nil
|
57
|
+
|
58
|
+
The default configuration provides table views for ActiveRecord::Base
|
59
|
+
descendants. If a class isn't configured, Hirb reverts to irb's default echo
|
60
|
+
mode.
|
61
|
+
>> Hirb::Formatter.dynamic_config['ActiveRecord::Base']
|
62
|
+
=> {:class=>Hirb::Helpers::AutoTable, :ancestor=>true}
|
63
|
+
|
64
|
+
# Tag is a model class and descendant of ActiveRecord::Base
|
65
|
+
>> Tag.last
|
66
|
+
+-----+-------------------------+-------------+---------------+-----------+-----------+-------+
|
67
|
+
| id | created_at | description | name | namespace | predicate | value |
|
68
|
+
+-----+-------------------------+-------------+---------------+-----------+-----------+-------+
|
69
|
+
| 907 | 2009-03-06 21:10:41 UTC | | gem:tags=yaml | gem | tags | yaml |
|
70
|
+
+-----+-------------------------+-------------+---------------+-----------+-----------+-------+
|
71
|
+
1 row in set
|
72
|
+
|
73
|
+
>> Hirb::Formatter.dynamic_config['String']
|
74
|
+
=> nil
|
75
|
+
>> 'plain ol irb'
|
76
|
+
=> 'plain ol irb'
|
77
|
+
>> Hirb::Formatter.dynamic_config['Symbol']
|
78
|
+
=> nil
|
79
|
+
>> :blah
|
80
|
+
=> :blah
|
81
|
+
|
82
|
+
From above you can see there are no views configured for a String or a Symbol
|
83
|
+
so Hirb defaults to irb's echo mode. On the other hand, Tag has a view thanks
|
84
|
+
to being a descendant of ActiveRecord::Base and there being an :ancestor
|
85
|
+
option.
|
86
|
+
|
87
|
+
Having seen hirb display views based on an output object's class, let's see it
|
88
|
+
handle an array of objects:
|
89
|
+
|
90
|
+
>> Tag.all :limit=>3, :order=>"id DESC"
|
91
|
+
+-----+-------------------------+-------------+-------------------+-----------+-----------+----------+
|
92
|
+
| id | created_at | description | name | namespace | predicate | value |
|
93
|
+
+-----+-------------------------+-------------+-------------------+-----------+-----------+----------+
|
94
|
+
| 907 | 2009-03-06 21:10:41 UTC | | gem:tags=yaml | gem | tags | yaml |
|
95
|
+
| 906 | 2009-03-06 08:47:04 UTC | | gem:tags=nomonkey | gem | tags | nomonkey |
|
96
|
+
| 905 | 2009-03-04 00:30:10 UTC | | article:tags=ruby | article | tags | ruby |
|
97
|
+
+-----+-------------------------+-------------+-------------------+-----------+-----------+----------+
|
98
|
+
3 rows in set
|
99
|
+
|
100
|
+
At any time you can disable Hirb if you really like irb's lovely echo mode:
|
101
|
+
>> Hirb.disable
|
102
|
+
=> nil
|
103
|
+
>> Tag.all :limit=>3, :order=>"id DESC"
|
104
|
+
=> [#<Tag id: 907, name: "gem:tags=yaml", description: nil, created_at: "2009-03-06 21:10:41",
|
105
|
+
namespace: "gem", predicate: "tags", value: "yaml">, #<Tag id: 906, name: "gem:tags=nomonkey",
|
106
|
+
description: nil, created_at: "2009-03-06 08:47:04", namespace: "gem", predicate: "tags", value:
|
107
|
+
"nomonkey">, #<Tag id: 905, name: "article:tags=ruby", description: nil, created_at: "2009-03-04
|
108
|
+
00:30:10", namespace: "article", predicate: "tags", value: "ruby">]
|
109
|
+
|
110
|
+
## Views: Anytime, Anywhere
|
111
|
+
|
112
|
+
While preconfigured tables are great for database records, sometimes you just
|
113
|
+
want to create tables/views for any output object:
|
114
|
+
|
115
|
+
#These examples don't need to have Hirb::View enabled.
|
116
|
+
>> Hirb.disable
|
117
|
+
=> nil
|
118
|
+
|
119
|
+
# Imports table() and view()
|
120
|
+
>> extend Hirb::Console
|
121
|
+
=> main
|
122
|
+
|
123
|
+
# Create a unicode table
|
124
|
+
>> table [[:a, :b, :c]], :unicode => true
|
125
|
+
┌───┬───┬───┐
|
126
|
+
│ 0 │ 1 │ 2 │
|
127
|
+
├───┼───┼───┤
|
128
|
+
│ a ╎ b ╎ c │
|
129
|
+
└───┴───┴───┘
|
130
|
+
1 row in set
|
131
|
+
|
132
|
+
# Creates github-markdown
|
133
|
+
>> table [[:a, :b, :c]], :markdown => true
|
134
|
+
| 0 | 1 | 2 |
|
135
|
+
|---|---|---|
|
136
|
+
| a | b | c |
|
137
|
+
|
138
|
+
# Create a table of Dates comparing them with different formats.
|
139
|
+
>> table [Date.today, Date.today.next_month], :fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
|
140
|
+
+------------+--------+-----------+-------+--------------------------+
|
141
|
+
| to_s | ld | ajd | amjd | asctime |
|
142
|
+
+------------+--------+-----------+-------+--------------------------+
|
143
|
+
| 2009-03-11 | 155742 | 4909803/2 | 54901 | Wed Mar 11 00:00:00 2009 |
|
144
|
+
| 2009-04-11 | 155773 | 4909865/2 | 54932 | Sat Apr 11 00:00:00 2009 |
|
145
|
+
+------------+--------+-----------+-------+--------------------------+
|
146
|
+
2 rows in set
|
147
|
+
|
148
|
+
# Same table as the previous method. However view() will be able to call any helper.
|
149
|
+
>> view [Date.today, Date.today.next_month], :class=>:object_table,
|
150
|
+
:fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
|
151
|
+
|
152
|
+
If these console methods weren't convenient enough, try:
|
153
|
+
|
154
|
+
# Imports view() to all objects.
|
155
|
+
>> require 'hirb/import_object'
|
156
|
+
=> true
|
157
|
+
# Yields same table as above examples.
|
158
|
+
>> [Date.today, Date.today.next_month].view :class=>:object_table,
|
159
|
+
:fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
|
160
|
+
|
161
|
+
Although views by default are printed to STDOUT, they can be easily modified
|
162
|
+
to write anywhere:
|
163
|
+
# Setup views to write to file 'console.log'.
|
164
|
+
>> Hirb::View.render_method = lambda {|output| File.open("console.log", 'w') {|f| f.write(output) } }
|
165
|
+
|
166
|
+
# Writes to file with same table output as above example.
|
167
|
+
>> view [Date.today, Date.today.next_month], :class=>:object_table,
|
168
|
+
:fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
|
169
|
+
|
170
|
+
# Doesn't write to file because Symbol doesn't have a view and thus defaults to irb's echo mode.
|
171
|
+
>> :blah
|
172
|
+
=> :blah
|
173
|
+
|
174
|
+
# Go back to printing Hirb views to STDOUT.
|
175
|
+
>> Hirb::View.reset_render_method
|
176
|
+
|
177
|
+
## Pager
|
178
|
+
|
179
|
+
Hirb has both pager and formatter functionality enabled by default. Note - if
|
180
|
+
you copy and paste into your ruby console and think that one of your lines
|
181
|
+
will kick off the pager, be aware that subsequent characters will go to your
|
182
|
+
pager and could cause side effects like saving a file.
|
183
|
+
|
184
|
+
If you want to turn off the functionality of either pager or formatter, pass
|
185
|
+
that in at startup:
|
186
|
+
|
187
|
+
Hirb.enable :pager=>false
|
188
|
+
Hirb.enable :formatter=>false
|
189
|
+
|
190
|
+
or toggle their state at runtime:
|
191
|
+
|
192
|
+
Hirb::View.toggle_pager
|
193
|
+
Hirb::View.toggle_formatter
|
194
|
+
|
195
|
+
## Sharing Helpers and Views
|
196
|
+
|
197
|
+
If you have tested helpers you'd like to share, fork Hirb and put them under
|
198
|
+
lib/hirb/helpers. To share views for certain classes, put them under
|
199
|
+
lib/hirb/views. Please submit views for gems that have a nontrivial number of
|
200
|
+
users.
|
201
|
+
|
202
|
+
## Limitations
|
203
|
+
|
204
|
+
If using Wirble and irb, you should call Hirb after it since they both
|
205
|
+
override irb's default output.
|
206
|
+
|
207
|
+
## Motivation
|
208
|
+
|
209
|
+
Table code from http://gist.github.com/72234 and [my console app's needs](http://github.com/cldwalker/tag-tree).
|
210
|
+
|
211
|
+
## Credits
|
212
|
+
* Chrononaut for vertical table helper.
|
213
|
+
* janlelis for unicode table helper.
|
214
|
+
* technogeeky and FND for markdown table helper.
|
215
|
+
* hsume2, crafterm, spastorino, xaviershay, bogdan, asanghi, vwall,
|
216
|
+
maxmeyer, jimjh, ddoherty03, rochefort and joshua for patches.
|
217
|
+
|
218
|
+
|
219
|
+
## Bugs/Issues
|
220
|
+
|
221
|
+
Please report them [on github](http://github.com/cldwalker/hirb/issues).
|
222
|
+
|
223
|
+
## Contributing
|
224
|
+
[See here](http://tagaholic.me/contributing.html)
|
225
|
+
|
226
|
+
## Links
|
227
|
+
* http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html
|
228
|
+
* http://tagaholic.me/2009/03/18/ruby-class-trees-rails-plugin-trees-with-hirb.html
|
229
|
+
* http://tagaholic.me/2009/06/19/page-irb-output-and-improve-ri-with-hirb.html
|
230
|
+
|
data/README.rdoc
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
1
|
+
== Preface
|
2
|
+
|
3
|
+
This gem is a direct fork of {Hirb}[https://github.com/cldwalker/hirb]
|
4
|
+
(0.7.3) which appears to be unmaintained since 2015. New release of Ruby
|
5
|
+
(2.7.2) introduced a breaking change into one of the methods in IRB module,
|
6
|
+
which made this Gem partially unusable. This fork aims to fix incompatibility.
|
7
|
+
Feel free to open PRs if you have any ideas to extend the functionality.
|
2
8
|
|
3
9
|
== Description
|
4
10
|
|
data/lib/hirb/version.rb
CHANGED
data/lib/{hirb.rb → hirber.rb}
RENAMED
File without changes
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hirber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Horner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bacon
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1
|
19
|
+
version: '1.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.1
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mocha
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: bacon-bits
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '0.1'
|
69
69
|
description: Hirb provides a mini view framework for console applications and uses
|
70
70
|
it to improve ripl(irb)'s default inspect output. Given an object or array of objects,
|
71
71
|
hirb renders a view based on the object's class and/or ancestry. Hirb offers reusable
|
@@ -88,10 +88,10 @@ files:
|
|
88
88
|
- CHANGELOG.rdoc
|
89
89
|
- CONTRIBUTING.md
|
90
90
|
- LICENSE.txt
|
91
|
+
- README.md
|
91
92
|
- README.rdoc
|
92
93
|
- Rakefile
|
93
94
|
- lib/bond/completions/hirb.rb
|
94
|
-
- lib/hirb.rb
|
95
95
|
- lib/hirb/console.rb
|
96
96
|
- lib/hirb/dynamic_view.rb
|
97
97
|
- lib/hirb/formatter.rb
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/hirb/views/mongo_db.rb
|
121
121
|
- lib/hirb/views/orm.rb
|
122
122
|
- lib/hirb/views/rails.rb
|
123
|
+
- lib/hirber.rb
|
123
124
|
- lib/ripl/hirb.rb
|
124
125
|
- test/auto_table_test.rb
|
125
126
|
- test/console_test.rb
|
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
157
|
- !ruby/object:Gem::Version
|
157
158
|
version: 1.3.5
|
158
159
|
requirements: []
|
159
|
-
rubygems_version: 3.1.
|
160
|
+
rubygems_version: 3.1.4
|
160
161
|
signing_key:
|
161
162
|
specification_version: 4
|
162
163
|
summary: A mini view framework for console/irb that's easy to use, even while under
|