bbcloud 0.6.2 → 0.7
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.
- data/bbcloud.gemspec +1 -3
- data/lib/bbcloud/commands/servers-show.rb +1 -1
- data/lib/bbcloud/version.rb +1 -1
- metadata +26 -61
- data/lib/bbcloud/commands/servers-restart.rb +0 -30
- data/lib/bbcloud/vendor/hirb/.gemspec +0 -22
- data/lib/bbcloud/vendor/hirb/CHANGELOG.rdoc +0 -106
- data/lib/bbcloud/vendor/hirb/LICENSE.txt +0 -22
- data/lib/bbcloud/vendor/hirb/README.rdoc +0 -182
- data/lib/bbcloud/vendor/hirb/Rakefile +0 -35
- data/lib/bbcloud/vendor/hirb/lib/bond/completions/hirb.rb +0 -15
- data/lib/bbcloud/vendor/hirb/lib/hirb/console.rb +0 -43
- data/lib/bbcloud/vendor/hirb/lib/hirb/dynamic_view.rb +0 -113
- data/lib/bbcloud/vendor/hirb/lib/hirb/formatter.rb +0 -116
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers/auto_table.rb +0 -24
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers/object_table.rb +0 -14
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers/parent_child_tree.rb +0 -24
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers/table/filters.rb +0 -10
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers/table/resizer.rb +0 -82
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers/table.rb +0 -323
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers/tree.rb +0 -181
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers/vertical_table.rb +0 -37
- data/lib/bbcloud/vendor/hirb/lib/hirb/helpers.rb +0 -17
- data/lib/bbcloud/vendor/hirb/lib/hirb/import_object.rb +0 -10
- data/lib/bbcloud/vendor/hirb/lib/hirb/menu.rb +0 -221
- data/lib/bbcloud/vendor/hirb/lib/hirb/pager.rb +0 -95
- data/lib/bbcloud/vendor/hirb/lib/hirb/string.rb +0 -44
- data/lib/bbcloud/vendor/hirb/lib/hirb/util.rb +0 -96
- data/lib/bbcloud/vendor/hirb/lib/hirb/version.rb +0 -3
- data/lib/bbcloud/vendor/hirb/lib/hirb/view.rb +0 -284
- data/lib/bbcloud/vendor/hirb/lib/hirb/views/couch_db.rb +0 -11
- data/lib/bbcloud/vendor/hirb/lib/hirb/views/misc_db.rb +0 -15
- data/lib/bbcloud/vendor/hirb/lib/hirb/views/mongo_db.rb +0 -14
- data/lib/bbcloud/vendor/hirb/lib/hirb/views/orm.rb +0 -11
- data/lib/bbcloud/vendor/hirb/lib/hirb/views/rails.rb +0 -19
- data/lib/bbcloud/vendor/hirb/lib/hirb/views.rb +0 -8
- data/lib/bbcloud/vendor/hirb/lib/hirb.rb +0 -81
- data/lib/bbcloud/vendor/hirb/test/auto_table_test.rb +0 -30
- data/lib/bbcloud/vendor/hirb/test/console_test.rb +0 -27
- data/lib/bbcloud/vendor/hirb/test/deps.rip +0 -4
- data/lib/bbcloud/vendor/hirb/test/dynamic_view_test.rb +0 -94
- data/lib/bbcloud/vendor/hirb/test/formatter_test.rb +0 -171
- data/lib/bbcloud/vendor/hirb/test/hirb_test.rb +0 -39
- data/lib/bbcloud/vendor/hirb/test/import_test.rb +0 -9
- data/lib/bbcloud/vendor/hirb/test/menu_test.rb +0 -239
- data/lib/bbcloud/vendor/hirb/test/object_table_test.rb +0 -79
- data/lib/bbcloud/vendor/hirb/test/pager_test.rb +0 -162
- data/lib/bbcloud/vendor/hirb/test/resizer_test.rb +0 -62
- data/lib/bbcloud/vendor/hirb/test/table_test.rb +0 -550
- data/lib/bbcloud/vendor/hirb/test/test_helper.rb +0 -61
- data/lib/bbcloud/vendor/hirb/test/tree_test.rb +0 -184
- data/lib/bbcloud/vendor/hirb/test/util_test.rb +0 -59
- data/lib/bbcloud/vendor/hirb/test/view_test.rb +0 -172
- data/lib/bbcloud/vendor/hirb/test/views_test.rb +0 -13
data/bbcloud.gemspec
CHANGED
@@ -20,9 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
s.add_dependency 'gli', '1.1.2'
|
23
|
-
|
24
|
-
# s.add_dependency 'hirb', '0.3.4'
|
25
|
-
# end
|
23
|
+
s.add_dependency 'hirb', '0.3.5'
|
26
24
|
s.add_dependency 'brightbox-fog', '0.3.16'
|
27
25
|
s.add_dependency 'excon', '>=0.2.4'
|
28
26
|
s.add_dependency 'ini', '0.1.1'
|
data/lib/bbcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.6.2
|
8
|
+
- 7
|
9
|
+
version: "0.7"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- John Leach
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-16 00:00:00 +00:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -35,9 +34,25 @@ dependencies:
|
|
35
34
|
type: :runtime
|
36
35
|
version_requirements: *id001
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
37
|
+
name: hirb
|
39
38
|
prerelease: false
|
40
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - "="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 25
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 3
|
48
|
+
- 5
|
49
|
+
version: 0.3.5
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: brightbox-fog
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
56
|
none: false
|
42
57
|
requirements:
|
43
58
|
- - "="
|
@@ -49,11 +64,11 @@ dependencies:
|
|
49
64
|
- 16
|
50
65
|
version: 0.3.16
|
51
66
|
type: :runtime
|
52
|
-
version_requirements: *
|
67
|
+
version_requirements: *id003
|
53
68
|
- !ruby/object:Gem::Dependency
|
54
69
|
name: excon
|
55
70
|
prerelease: false
|
56
|
-
requirement: &
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
57
72
|
none: false
|
58
73
|
requirements:
|
59
74
|
- - ">="
|
@@ -65,11 +80,11 @@ dependencies:
|
|
65
80
|
- 4
|
66
81
|
version: 0.2.4
|
67
82
|
type: :runtime
|
68
|
-
version_requirements: *
|
83
|
+
version_requirements: *id004
|
69
84
|
- !ruby/object:Gem::Dependency
|
70
85
|
name: ini
|
71
86
|
prerelease: false
|
72
|
-
requirement: &
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
73
88
|
none: false
|
74
89
|
requirements:
|
75
90
|
- - "="
|
@@ -81,7 +96,7 @@ dependencies:
|
|
81
96
|
- 1
|
82
97
|
version: 0.1.1
|
83
98
|
type: :runtime
|
84
|
-
version_requirements: *
|
99
|
+
version_requirements: *id005
|
85
100
|
description: Scripts to interact with the Brightbox cloud API
|
86
101
|
email:
|
87
102
|
- john@brightbox.co.uk
|
@@ -134,7 +149,6 @@ files:
|
|
134
149
|
- lib/bbcloud/commands/servers-create.rb
|
135
150
|
- lib/bbcloud/commands/servers-destroy.rb
|
136
151
|
- lib/bbcloud/commands/servers-list.rb
|
137
|
-
- lib/bbcloud/commands/servers-restart.rb
|
138
152
|
- lib/bbcloud/commands/servers-show.rb
|
139
153
|
- lib/bbcloud/commands/servers-shutdown.rb
|
140
154
|
- lib/bbcloud/commands/servers-snapshot.rb
|
@@ -154,55 +168,6 @@ files:
|
|
154
168
|
- lib/bbcloud/users.rb
|
155
169
|
- lib/bbcloud/version.rb
|
156
170
|
- lib/bbcloud/zones.rb
|
157
|
-
- lib/bbcloud/vendor/hirb/.gemspec
|
158
|
-
- lib/bbcloud/vendor/hirb/README.rdoc
|
159
|
-
- lib/bbcloud/vendor/hirb/test/deps.rip
|
160
|
-
- lib/bbcloud/vendor/hirb/test/console_test.rb
|
161
|
-
- lib/bbcloud/vendor/hirb/test/view_test.rb
|
162
|
-
- lib/bbcloud/vendor/hirb/test/util_test.rb
|
163
|
-
- lib/bbcloud/vendor/hirb/test/formatter_test.rb
|
164
|
-
- lib/bbcloud/vendor/hirb/test/table_test.rb
|
165
|
-
- lib/bbcloud/vendor/hirb/test/dynamic_view_test.rb
|
166
|
-
- lib/bbcloud/vendor/hirb/test/tree_test.rb
|
167
|
-
- lib/bbcloud/vendor/hirb/test/hirb_test.rb
|
168
|
-
- lib/bbcloud/vendor/hirb/test/pager_test.rb
|
169
|
-
- lib/bbcloud/vendor/hirb/test/menu_test.rb
|
170
|
-
- lib/bbcloud/vendor/hirb/test/test_helper.rb
|
171
|
-
- lib/bbcloud/vendor/hirb/test/views_test.rb
|
172
|
-
- lib/bbcloud/vendor/hirb/test/auto_table_test.rb
|
173
|
-
- lib/bbcloud/vendor/hirb/test/import_test.rb
|
174
|
-
- lib/bbcloud/vendor/hirb/test/object_table_test.rb
|
175
|
-
- lib/bbcloud/vendor/hirb/test/resizer_test.rb
|
176
|
-
- lib/bbcloud/vendor/hirb/CHANGELOG.rdoc
|
177
|
-
- lib/bbcloud/vendor/hirb/Rakefile
|
178
|
-
- lib/bbcloud/vendor/hirb/LICENSE.txt
|
179
|
-
- lib/bbcloud/vendor/hirb/lib/bond/completions/hirb.rb
|
180
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers.rb
|
181
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/version.rb
|
182
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/pager.rb
|
183
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/import_object.rb
|
184
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/formatter.rb
|
185
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/console.rb
|
186
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers/parent_child_tree.rb
|
187
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers/auto_table.rb
|
188
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers/vertical_table.rb
|
189
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers/table.rb
|
190
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers/object_table.rb
|
191
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers/table/resizer.rb
|
192
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers/table/filters.rb
|
193
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/helpers/tree.rb
|
194
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/string.rb
|
195
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/views/couch_db.rb
|
196
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/views/rails.rb
|
197
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/views/mongo_db.rb
|
198
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/views/misc_db.rb
|
199
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/views/orm.rb
|
200
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/menu.rb
|
201
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/dynamic_view.rb
|
202
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/util.rb
|
203
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/views.rb
|
204
|
-
- lib/bbcloud/vendor/hirb/lib/hirb/view.rb
|
205
|
-
- lib/bbcloud/vendor/hirb/lib/hirb.rb
|
206
171
|
has_rdoc: true
|
207
172
|
homepage: http://docs.brightbox.com/cli
|
208
173
|
licenses: []
|
@@ -1,30 +0,0 @@
|
|
1
|
-
desc 'Restart the specified servers'
|
2
|
-
arg_name 'server-id...'
|
3
|
-
command [:restart] do |c|
|
4
|
-
c.desc "Soft restart (default)"
|
5
|
-
c.switch [:s, "soft"]
|
6
|
-
|
7
|
-
c.desc "Hard restart"
|
8
|
-
c.default_value true
|
9
|
-
c.switch [:d, "hard"]
|
10
|
-
|
11
|
-
c.action do |global_options,options,args|
|
12
|
-
|
13
|
-
if options[:soft] and options[:hard]
|
14
|
-
raise "Cannot do both hard and soft restart at the same time"
|
15
|
-
end
|
16
|
-
|
17
|
-
type = options[:hard] ? "hard" : "soft"
|
18
|
-
|
19
|
-
servers = Server.find(args).compact
|
20
|
-
|
21
|
-
servers.each do |s|
|
22
|
-
info "Restarting server #{s}"
|
23
|
-
s.reboot(type)
|
24
|
-
s.reload
|
25
|
-
end
|
26
|
-
|
27
|
-
render_table(servers)
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require 'rubygems' unless Object.const_defined?(:Gem)
|
3
|
-
require File.dirname(__FILE__) + "/lib/hirb/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "hirb"
|
7
|
-
s.version = Hirb::VERSION
|
8
|
-
s.authors = ["Gabriel Horner"]
|
9
|
-
s.email = "gabriel.horner@gmail.com"
|
10
|
-
s.homepage = "http://tagaholic.me/hirb/"
|
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."
|
13
|
-
s.required_rubygems_version = ">= 1.3.6"
|
14
|
-
s.rubyforge_project = 'tagaholic'
|
15
|
-
s.add_development_dependency 'bacon', '>= 1.1.0'
|
16
|
-
s.add_development_dependency 'mocha'
|
17
|
-
s.add_development_dependency 'mocha-on-bacon'
|
18
|
-
s.add_development_dependency 'bacon-bits'
|
19
|
-
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
20
|
-
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
21
|
-
s.license = 'MIT'
|
22
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
== 0.3.4
|
2
|
-
* Added auto format of array-like objects i.e. ActiveRecord::Relation and Set.
|
3
|
-
* Fixed bug when Hirb::Console#table is used without Hirb enabled.
|
4
|
-
* Fixed bug when hirb is running within cron and uses tput.
|
5
|
-
|
6
|
-
== 0.3.3
|
7
|
-
* Added ignore_errors option to ignore view errors and continue with original view.
|
8
|
-
* Added support for array menu items.
|
9
|
-
* Added support to ObjectTable for objects with an undefined :send method.
|
10
|
-
|
11
|
-
== 0.3.2
|
12
|
-
* Added irb autocompletions for bond.
|
13
|
-
* Fixed tests for ruby 1.9.
|
14
|
-
* Changed tests to use bacon.
|
15
|
-
* Removed jeweler in Rakefile and pointless $LOAD_PATH manipulation.
|
16
|
-
|
17
|
-
== 0.3.1
|
18
|
-
* Bug fix on DynamicView.class_to_method to allow overrides of default views.
|
19
|
-
* Modified mongo_mapper view to have _id first.
|
20
|
-
|
21
|
-
== 0.3.0
|
22
|
-
* Added dynamic views.
|
23
|
-
* Added default table views for the following database classes/modules:
|
24
|
-
CouchFoo::Base, CouchPotato::Persistence, CouchRest::ExtendedDocument,
|
25
|
-
DBI::Row, DataMapper::Resource, Friendly::Document, MongoMapper::Document, MongoMapper::EmbeddedDocument,
|
26
|
-
Mongoid::Document, Ripple::Document and Sequel::Model.
|
27
|
-
* Added Hirb.add_view and Hirb.add_dynamic_view for easier view manipulation.
|
28
|
-
* Added :multi_line_nodes option for Tree.
|
29
|
-
* Fixed :change_fields option bug in Table.
|
30
|
-
* Fixed no headers and nil fields bug in Table.
|
31
|
-
* Removed deprecations in Hirb.config_file + View.enable.
|
32
|
-
* Removed Views classes and View.format_class.
|
33
|
-
* Removed :return_rows option for Table.
|
34
|
-
|
35
|
-
== 0.2.10
|
36
|
-
* Added multiple options to Menu, most importantly :two_d and :action.
|
37
|
-
* Improved table resizing algorithm.
|
38
|
-
* Added merging of configs for multiple Hirb.enable calls.
|
39
|
-
* Added :max_fields, :hide_empty, :delete_callbacks, :resize, :header_filter
|
40
|
-
and :return_rows options to Table.
|
41
|
-
* Added escaping for \t and \r in Table.
|
42
|
-
* Renamed Table's :no_newlines option to :escape_special_chars.
|
43
|
-
* Removed Table's :field_lengths option.
|
44
|
-
* Removed Menu's :validate_one option.
|
45
|
-
* Bug fix for table header of a basic array.
|
46
|
-
* Deprecating Hirb.config_file + View.enable in next release.
|
47
|
-
|
48
|
-
== 0.2.9
|
49
|
-
* Added newline filtering and :no_newlines option for table helper.
|
50
|
-
* Added default filters for hashes that have hash values.
|
51
|
-
* Bug fix for deprecated to_a call.
|
52
|
-
|
53
|
-
== 0.2.8
|
54
|
-
* Added callbacks to Hirb::Helpers::Table.
|
55
|
-
* Added :change_fields option to Hirb::Helpers::Table.
|
56
|
-
* Added terminal size detection for jruby.
|
57
|
-
* Bug fix for paging long outputs.
|
58
|
-
* Bug fix to make unexpected hirb rendering errors more clear.
|
59
|
-
|
60
|
-
== 0.2.7
|
61
|
-
* 2 ruby 1.9 bug fixes.
|
62
|
-
* Bug fix in :fields of Hirb::Helpers::ObjectTable.
|
63
|
-
* Made :class option in Hirb::Formatter friendlier to external apps.
|
64
|
-
|
65
|
-
== 0.2.6
|
66
|
-
* Added :description option and added proc ability to :children_method option for helpers.
|
67
|
-
* Bug fix for no ENV['HOME'] on Windows.
|
68
|
-
* Bug fix on unaliasing output_method.
|
69
|
-
* Bug fix on multiple renders of vertical table.
|
70
|
-
|
71
|
-
== 0.2.5
|
72
|
-
* Added ability to use Hirb.enable with non-irb ruby shells.
|
73
|
-
* Helper configs now recursively merge when inheriting from others via :ancestor option.
|
74
|
-
|
75
|
-
== 0.2.4
|
76
|
-
* Bug fix on UTF-8 support.
|
77
|
-
|
78
|
-
== 0.2.3
|
79
|
-
* Added UTF-8 support for Ruby 1.8.x
|
80
|
-
* Added :all_fields option to Table helper.
|
81
|
-
|
82
|
-
== 0.2.2
|
83
|
-
* Added a friendlier default (a vertical table) to incorrectly configured tables.
|
84
|
-
* Added vertical table helper thanks to chrononaut.
|
85
|
-
* Added detection of :select option from ActiveRecord queries in ActiveRecordTable helper.
|
86
|
-
* Added handling anything that responds to :to_a in AutoTable helper.
|
87
|
-
|
88
|
-
== 0.2.1
|
89
|
-
* Fixed typo in Hirb::Console.view
|
90
|
-
|
91
|
-
== 0.2.0
|
92
|
-
* Major refactoring with bug fixes and better tests.
|
93
|
-
* Improved table algorithm to ensure that tables don't wrap.
|
94
|
-
* Added a pager which detects if output should be paged, Hirb::Pager.
|
95
|
-
* Added a selection menu, Hirb::Menu
|
96
|
-
* Following API changes: Hirb::Helpers::Table.max_width removed and config files don't use
|
97
|
-
the :view key anymore.
|
98
|
-
== 0.1.2
|
99
|
-
* Added tree views.
|
100
|
-
* Added output_method option to Hirb::View.render_output.
|
101
|
-
|
102
|
-
== 0.1.1
|
103
|
-
* Fixed bug when rendering table with many fields.
|
104
|
-
|
105
|
-
== 0.1.0
|
106
|
-
* Initial release
|
@@ -1,22 +0,0 @@
|
|
1
|
-
The MIT LICENSE
|
2
|
-
|
3
|
-
Copyright (c) 2010 Gabriel Horner
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,182 +0,0 @@
|
|
1
|
-
To read a linked version of this README, {click here}[http://tagaholic.me/hirb/doc/].
|
2
|
-
|
3
|
-
== Description
|
4
|
-
|
5
|
-
Hirb provides a mini view framework for console applications and uses it to improve irb's default inspect output.
|
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
|
-
views in the form of helper classes. The two main helpers, Hirb::Helpers::Table and Hirb::Helpers::Tree, provide several options
|
8
|
-
for generating ascii tables and trees. Using Hirb::Helpers::AutoTable, hirb has useful default views for at least ten popular database gems
|
9
|
-
i.e. Rails' ActiveRecord::Base. Other than views, hirb offers a smart pager and a console menu. The smart pager
|
10
|
-
only pages when the output exceeds the current screen size. The menu is used in conjunction with tables to offer
|
11
|
-
{two dimensional menus}[http://tagaholic.me/2010/02/16/two-dimensional-console-menus-with-hirb.html].
|
12
|
-
|
13
|
-
== Install
|
14
|
-
|
15
|
-
Install the gem with:
|
16
|
-
|
17
|
-
sudo gem install hirb
|
18
|
-
|
19
|
-
== View Tutorials
|
20
|
-
|
21
|
-
* To create and configure views, see Hirb::View or {here if on the web}[http://tagaholic.me/hirb/doc/classes/Hirb/View.html].
|
22
|
-
* To create dynamic views, see Hirb::DynamicView or {here if on the web}[http://tagaholic.me/hirb/doc/classes/Hirb/DynamicView.html].
|
23
|
-
|
24
|
-
== Printing Ascii Tables
|
25
|
-
|
26
|
-
To print ascii tables from an array of arrays, hashes or any objects:
|
27
|
-
|
28
|
-
puts Hirb::Helper::AutoTable.render(ARRAY_OF_OBJECTS)
|
29
|
-
|
30
|
-
Hirb will intelligently pick up on field names from an array of hashes and create properly-aligned
|
31
|
-
fields from an array of arrays. See
|
32
|
-
{here}[http://tagaholic.me/2009/10/15/boson-and-hirb-interactions.html#hirbs_handy_tables] for examples.
|
33
|
-
|
34
|
-
== Rails Example
|
35
|
-
|
36
|
-
Let's load and enable the view framework:
|
37
|
-
$ script/console
|
38
|
-
Loading local environment (Rails 2.3.5)
|
39
|
-
>> require 'hirb'
|
40
|
-
=> true
|
41
|
-
>> Hirb.enable
|
42
|
-
=> nil
|
43
|
-
|
44
|
-
The default configuration provides table views for ActiveRecord::Base descendants.
|
45
|
-
If a class isn't configured, Hirb reverts to irb's default echo mode.
|
46
|
-
>> Hirb::Formatter.dynamic_config['ActiveRecord::Base']
|
47
|
-
=> {:class=>Hirb::Helpers::AutoTable, :ancestor=>true}
|
48
|
-
|
49
|
-
# Tag is a model class and descendant of ActiveRecord::Base
|
50
|
-
>> Tag.last
|
51
|
-
+-----+-------------------------+-------------+---------------+-----------+-----------+-------+
|
52
|
-
| id | created_at | description | name | namespace | predicate | value |
|
53
|
-
+-----+-------------------------+-------------+---------------+-----------+-----------+-------+
|
54
|
-
| 907 | 2009-03-06 21:10:41 UTC | | gem:tags=yaml | gem | tags | yaml |
|
55
|
-
+-----+-------------------------+-------------+---------------+-----------+-----------+-------+
|
56
|
-
1 row in set
|
57
|
-
|
58
|
-
>> Hirb::Formatter.dynamic_config['String']
|
59
|
-
=> nil
|
60
|
-
>> 'plain ol irb'
|
61
|
-
=> 'plain ol irb'
|
62
|
-
>> Hirb::Formatter.dynamic_config['Symbol']
|
63
|
-
=> nil
|
64
|
-
>> :blah
|
65
|
-
=> :blah
|
66
|
-
|
67
|
-
From above you can see there are no views configured for a String or a Symbol so Hirb defaults to
|
68
|
-
irb's echo mode. On the other hand, Tag has a view thanks to being a descendant of ActiveRecord::Base
|
69
|
-
and there being an :ancestor option.
|
70
|
-
|
71
|
-
Having seen hirb display views based on an output object's class, let's see it handle an array of objects:
|
72
|
-
|
73
|
-
>> Tag.all :limit=>3, :order=>"id DESC"
|
74
|
-
+-----+-------------------------+-------------+-------------------+-----------+-----------+----------+
|
75
|
-
| id | created_at | description | name | namespace | predicate | value |
|
76
|
-
+-----+-------------------------+-------------+-------------------+-----------+-----------+----------+
|
77
|
-
| 907 | 2009-03-06 21:10:41 UTC | | gem:tags=yaml | gem | tags | yaml |
|
78
|
-
| 906 | 2009-03-06 08:47:04 UTC | | gem:tags=nomonkey | gem | tags | nomonkey |
|
79
|
-
| 905 | 2009-03-04 00:30:10 UTC | | article:tags=ruby | article | tags | ruby |
|
80
|
-
+-----+-------------------------+-------------+-------------------+-----------+-----------+----------+
|
81
|
-
3 rows in set
|
82
|
-
|
83
|
-
At any time you can disable Hirb if you really like irb's lovely echo mode:
|
84
|
-
>> Hirb.disable
|
85
|
-
=> nil
|
86
|
-
>> Tag.all :limit=>3, :order=>"id DESC"
|
87
|
-
=> [#<Tag id: 907, name: "gem:tags=yaml", description: nil, created_at: "2009-03-06 21:10:41",
|
88
|
-
namespace: "gem", predicate: "tags", value: "yaml">, #<Tag id: 906, name: "gem:tags=nomonkey",
|
89
|
-
description: nil, created_at: "2009-03-06 08:47:04", namespace: "gem", predicate: "tags", value:
|
90
|
-
"nomonkey">, #<Tag id: 905, name: "article:tags=ruby", description: nil, created_at: "2009-03-04
|
91
|
-
00:30:10", namespace: "article", predicate: "tags", value: "ruby">]
|
92
|
-
|
93
|
-
== Views: Anytime, Anywhere
|
94
|
-
While preconfigured tables are great for database records, sometimes you just want to create
|
95
|
-
tables/views for any output object:
|
96
|
-
|
97
|
-
#These examples don't need to have Hirb::View enabled.
|
98
|
-
>> Hirb.disable
|
99
|
-
=> nil
|
100
|
-
|
101
|
-
# Imports table() and view()
|
102
|
-
>> extend Hirb::Console
|
103
|
-
=> main
|
104
|
-
|
105
|
-
# Create a table of Dates comparing them with different formats.
|
106
|
-
>> table [Date.today, Date.today.next_month], :fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
|
107
|
-
+------------+--------+-----------+-------+--------------------------+
|
108
|
-
| to_s | ld | ajd | amjd | asctime |
|
109
|
-
+------------+--------+-----------+-------+--------------------------+
|
110
|
-
| 2009-03-11 | 155742 | 4909803/2 | 54901 | Wed Mar 11 00:00:00 2009 |
|
111
|
-
| 2009-04-11 | 155773 | 4909865/2 | 54932 | Sat Apr 11 00:00:00 2009 |
|
112
|
-
+------------+--------+-----------+-------+--------------------------+
|
113
|
-
2 rows in set
|
114
|
-
|
115
|
-
# Same table as the previous method. However view() will be able to call any helper.
|
116
|
-
>> view [Date.today, Date.today.next_month], :class=>:object_table,
|
117
|
-
:fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
|
118
|
-
|
119
|
-
If these console methods weren't convenient enough, try:
|
120
|
-
|
121
|
-
# Imports view() to all objects.
|
122
|
-
>> require 'hirb/import_object'
|
123
|
-
=>true
|
124
|
-
# Yields same table as above examples.
|
125
|
-
>> [Date.today, Date.today.next_month].view :class=>:object_table,
|
126
|
-
:fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
|
127
|
-
|
128
|
-
Although views by default are printed to STDOUT, they can be easily modified to write anywhere:
|
129
|
-
# Setup views to write to file 'console.log'.
|
130
|
-
>> Hirb::View.render_method = lambda {|output| File.open("console.log", 'w') {|f| f.write(output) } }
|
131
|
-
|
132
|
-
# Writes to file with same table output as above example.
|
133
|
-
>> view [Date.today, Date.today.next_month], :class=>:object_table,
|
134
|
-
:fields=>[:to_s, :ld, :ajd, :amjd, :asctime]
|
135
|
-
|
136
|
-
# Doesn't write to file because Symbol doesn't have a view and thus defaults to irb's echo mode.
|
137
|
-
>> :blah
|
138
|
-
=>:blah
|
139
|
-
|
140
|
-
# Go back to printing Hirb views to STDOUT.
|
141
|
-
>> Hirb::View.reset_render_method
|
142
|
-
|
143
|
-
== Pager
|
144
|
-
|
145
|
-
Hirb has both pager and formatter functionality enabled by default.
|
146
|
-
If you want to turn off the functionality of either you can pass that in at startup:
|
147
|
-
|
148
|
-
Hirb.enable :pager=>false
|
149
|
-
Hirb.enable :formatter=>false
|
150
|
-
|
151
|
-
or toggle their state at runtime:
|
152
|
-
|
153
|
-
Hirb::View.toggle_pager
|
154
|
-
Hirb::View.toggle_formatter
|
155
|
-
|
156
|
-
== Sharing Helpers and Views
|
157
|
-
If you have tested helpers you'd like to share, fork Hirb and put them under lib/hirb/helpers. To share
|
158
|
-
views for certain classes, put them under lib/hirb/views. Please submit views for gems that have a nontrivial
|
159
|
-
number of users.
|
160
|
-
|
161
|
-
== Limitations
|
162
|
-
If using Wirble, you should call Hirb after it since they both override irb's default output.
|
163
|
-
|
164
|
-
== Motivation
|
165
|
-
Table code from http://gist.github.com/72234 and {my console app's needs}[http://github.com/cldwalker/tag-tree].
|
166
|
-
|
167
|
-
== Credits
|
168
|
-
* Chrononaut for vertical table helper.
|
169
|
-
* crafterm, spastorino, xaviershay, bogdan and joshua for patches.
|
170
|
-
|
171
|
-
== Bugs/Issues
|
172
|
-
Please report them {on github}[http://github.com/cldwalker/hirb/issues].
|
173
|
-
|
174
|
-
== Links
|
175
|
-
* http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html
|
176
|
-
* http://tagaholic.me/2009/03/18/ruby-class-trees-rails-plugin-trees-with-hirb.html
|
177
|
-
* http://tagaholic.me/2009/06/19/page-irb-output-and-improve-ri-with-hirb.html
|
178
|
-
|
179
|
-
== Todo
|
180
|
-
* Consider generating views based on methods an object responds to.
|
181
|
-
* Provide helper methods to all views.
|
182
|
-
* Consider adding a template helper.
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
def gemspec
|
5
|
-
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
6
|
-
end
|
7
|
-
|
8
|
-
desc "Build the gem"
|
9
|
-
task :gem=>:gemspec do
|
10
|
-
sh "gem build .gemspec"
|
11
|
-
FileUtils.mkdir_p 'pkg'
|
12
|
-
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Install the gem locally"
|
16
|
-
task :install => :gem do
|
17
|
-
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
18
|
-
end
|
19
|
-
|
20
|
-
desc "Generate the gemspec"
|
21
|
-
task :generate do
|
22
|
-
puts gemspec.to_ruby
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "Validate the gemspec"
|
26
|
-
task :gemspec do
|
27
|
-
gemspec.validate
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'Run tests'
|
31
|
-
task :test do |t|
|
32
|
-
sh 'bacon -q -Ilib -I. test/*_test.rb'
|
33
|
-
end
|
34
|
-
|
35
|
-
task :default => :test
|
@@ -1,15 +0,0 @@
|
|
1
|
-
complete(:methods=>%w{Hirb::View.enable Hirb.enable}) {
|
2
|
-
%w{config_file output_method output width height formatter pager pager_command}
|
3
|
-
}
|
4
|
-
complete(:methods=>%w{Hirb::Helpers::Table.render table}) {
|
5
|
-
%w{fields headers max_fields max_width resize number change_fields}+
|
6
|
-
%w{filters header_filter filter_any filter_classes vertical all_fields}+
|
7
|
-
%w{description escape_special_chars table_class hide_empty}
|
8
|
-
}
|
9
|
-
complete(:method=>"Hirb::Helpers::Tree.render") {
|
10
|
-
%w{type validate indent limit description multi_line_nodes value_method children_method}
|
11
|
-
}
|
12
|
-
complete(:methods=>%w{Hirb::Menu.render menu}) {
|
13
|
-
%w{helper_class prompt ask directions readline two_d default_field action multi_action} +
|
14
|
-
%w{action_object command reopen}
|
15
|
-
}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Hirb
|
2
|
-
# This module is meant to be extended to provide methods for use in a console/irb shell.
|
3
|
-
# For example:
|
4
|
-
# >> extend Hirb::Console
|
5
|
-
# >> view 'some string', :class=>Some::String::Formatter
|
6
|
-
# >> table [[:row1], [:row2]]
|
7
|
-
module Console
|
8
|
-
class<<self
|
9
|
-
# A console version of render_output() which takes its same options but allows for shorthand. All options are passed to
|
10
|
-
# the helper except for the formatter options. Formatter options are :class, :method and :output_method.
|
11
|
-
# Examples:
|
12
|
-
# render_output output, :class=>:tree :type=>:directory
|
13
|
-
# # is the same as:
|
14
|
-
# render_output output, :class=>:tree, :options=> {:type=>:directory}
|
15
|
-
#
|
16
|
-
def render_output(output, options={})
|
17
|
-
View.load_config unless View.config_loaded?
|
18
|
-
View.render_output(output, options.merge(:console=>true))
|
19
|
-
end
|
20
|
-
|
21
|
-
# Takes same arguments and options as render_output() but returns formatted output instead of rendering it.
|
22
|
-
def format_output(output, options={}, &block)
|
23
|
-
View.load_config unless View.config_loaded?
|
24
|
-
View.formatter.format_output(output, options.merge(:console=>true), &block)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Renders a table for the given object. Takes same options as Hirb::Helpers::Table.render.
|
29
|
-
def table(output, options={})
|
30
|
-
Console.render_output(output, options.merge(:class=>"Hirb::Helpers::AutoTable"))
|
31
|
-
end
|
32
|
-
|
33
|
-
# Renders any specified view for the given object. Takes same options as Hirb::View.render_output.
|
34
|
-
def view(output, options={})
|
35
|
-
Console.render_output(output, options)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Renders a menu given an array using Hirb::Menu.render.
|
39
|
-
def menu(output, options={}, &block)
|
40
|
-
Console.format_output(output, options.merge(:class=>"Hirb::Menu"), &block)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|