hirb 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
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'
16
- s.add_development_dependency 'mocha'
17
- s.add_development_dependency 'mocha-on-bacon'
16
+ s.add_development_dependency 'mocha', '>= 0.9.8'
17
+ s.add_development_dependency 'mocha-on-bacon', '>= 0.1.1'
18
18
  s.add_development_dependency 'bacon-bits'
19
19
  s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
20
20
  s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
@@ -1,3 +1,6 @@
1
+ == 0.5.0
2
+ * Add :grep_fields option to Table
3
+
1
4
  == 0.4.5
2
5
  * Fix the fix
3
6
 
@@ -185,12 +185,10 @@ Table code from http://gist.github.com/72234 and {my console app's needs}[http:/
185
185
  == Bugs/Issues
186
186
  Please report them {on github}[http://github.com/cldwalker/hirb/issues].
187
187
 
188
+ == Contributing
189
+ {See here}[http://tagaholic.me/contributing.html]
190
+
188
191
  == Links
189
192
  * http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html
190
193
  * http://tagaholic.me/2009/03/18/ruby-class-trees-rails-plugin-trees-with-hirb.html
191
194
  * http://tagaholic.me/2009/06/19/page-irb-output-and-improve-ri-with-hirb.html
192
-
193
- == Todo
194
- * Consider generating views based on methods an object responds to.
195
- * Provide helper methods to all views.
196
- * Consider adding a template helper.
@@ -4,7 +4,7 @@ complete(:methods=>%w{Hirb::View.enable Hirb.enable}) {
4
4
  complete(:methods=>%w{Hirb::Helpers::Table.render table}) {
5
5
  %w{fields headers max_fields max_width resize number change_fields}+
6
6
  %w{filters header_filter filter_any filter_classes vertical all_fields}+
7
- %w{description escape_special_chars table_class hide_empty unicode}
7
+ %w{description escape_special_chars table_class hide_empty unicode grep_fields}
8
8
  }
9
9
  complete(:method=>"Hirb::Helpers::Tree.render") {
10
10
  %w{type validate indent limit description multi_line_nodes value_method children_method}
@@ -88,6 +88,7 @@ module Hirb
88
88
  # [*:number*] When set to true, numbers rows by adding a :hirb_number column as the first column. Default is false.
89
89
  # [*:change_fields*] A hash to change old field names to new field names. This can also be an array of new names but only for array rows.
90
90
  # This is useful when wanting to change auto-generated keys to more user-friendly names i.e. for array rows.
91
+ # [*:grep_fields*] A regexp that selects which fields to display. By default this is not set and applied.
91
92
  # [*:filters*] A hash of fields and their filters, applied to every row in a field. A filter can be a proc, an instance method
92
93
  # applied to the field value or a Filters method. Also see the filter_classes attribute below.
93
94
  # [*:header_filter*] A filter, like one in :filters, that is applied to all headers after the :headers option.
@@ -140,6 +141,7 @@ module Hirb
140
141
  @options = {:description=>true, :filters=>{}, :change_fields=>{}, :escape_special_chars=>true,
141
142
  :filter_any=>Helpers::Table.filter_any, :resize=>true}.merge(options)
142
143
  @fields = set_fields(rows)
144
+ @fields = @fields.select {|e| e.to_s[@options[:grep_fields]] } if @options[:grep_fields]
143
145
  @rows = set_rows(rows)
144
146
  @headers = set_headers
145
147
  if @options[:number]
@@ -1,3 +1,3 @@
1
1
  module Hirb
2
- VERSION = '0.4.5'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -1,4 +1,4 @@
1
1
  bacon >=1.1.0
2
- mocha >=0
3
- mocha-on-bacon >=0
2
+ mocha >=0.9.8
3
+ mocha-on-bacon >=0.1.1
4
4
  bacon-bits >=0
@@ -194,6 +194,30 @@ describe "Table" do
194
194
  table([{:a=>1, :b=>2}, {:a=>3, :b=>4}], :fields=>[:b, :c]).should == expected_table
195
195
  end
196
196
 
197
+ it "grep_fields option and symbol fields" do
198
+ expected_table = <<-TABLE.unindent
199
+ +----+----+
200
+ | f1 | f2 |
201
+ +----+----+
202
+ | 1 | 2 |
203
+ +----+----+
204
+ 1 row in set
205
+ TABLE
206
+ table([{:f1 => 1, :f2 => 2, :gf1 => 3}], :grep_fields => /^f/).should == expected_table
207
+ end
208
+
209
+ it "grep_fields option and non-symbol fields" do
210
+ expected_table = <<-TABLE.unindent
211
+ +---+
212
+ | 1 |
213
+ +---+
214
+ | 2 |
215
+ +---+
216
+ 1 row in set
217
+ TABLE
218
+ table([[1,2,3]], :grep_fields => /1/).should == expected_table
219
+ end
220
+
197
221
  it "invalid field in max_fields option renders" do
198
222
  expected_table = <<-TABLE.unindent
199
223
  +------------+---+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hirb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.5
5
+ version: 0.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Gabriel Horner
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-24 00:00:00 -04:00
13
+ date: 2011-08-06 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: "0"
35
+ version: 0.9.8
36
36
  type: :development
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
@@ -43,7 +43,7 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: "0"
46
+ version: 0.1.1
47
47
  type: :development
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  requirements: []
143
143
 
144
144
  rubyforge_project: tagaholic
145
- rubygems_version: 1.6.1
145
+ rubygems_version: 1.6.2
146
146
  signing_key:
147
147
  specification_version: 3
148
148
  summary: A mini view framework for console/irb that's easy to use, even while under its influence.