hirb 0.6.0 → 0.6.1

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/.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}
18
+ s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/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
@@ -0,0 +1,8 @@
1
+ before_install: bundle init --gemspec=.gemspec
2
+ script: bacon -q -Ilib -I. test/*_test.rb
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - jruby
8
+ - rbx
@@ -1,3 +1,7 @@
1
+ == 0.6.1
2
+ * Fix for mongoid view
3
+ * Fix tests on rubinius + jruby
4
+
1
5
  == 0.6.0
2
6
  * Add tab table
3
7
  * Tests pass in 1.9.3
@@ -180,7 +180,7 @@ Table code from http://gist.github.com/72234 and {my console app's needs}[http:/
180
180
  == Credits
181
181
  * Chrononaut for vertical table helper.
182
182
  * janlelis for unicode table helper.
183
- * crafterm, spastorino, xaviershay, bogdan, asanghi and joshua for patches.
183
+ * crafterm, spastorino, xaviershay, bogdan, asanghi, vwall and joshua for patches.
184
184
 
185
185
  == Bugs/Issues
186
186
  Please report them {on github}[http://github.com/cldwalker/hirb/issues].
@@ -32,7 +32,7 @@ module Hirb
32
32
  # Examples:
33
33
  # 1-3,5-6 -> [1,2,3,5,6]
34
34
  # * -> all elements in array
35
- # '' -> []
35
+ # '' -> []
36
36
  def choose_from_array(array, input, options={})
37
37
  options = {:splitter=>","}.merge(options)
38
38
  return array if input.strip == '*'
@@ -1,3 +1,3 @@
1
1
  module Hirb
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
@@ -1,6 +1,9 @@
1
1
  module Hirb::Views::MongoDb #:nodoc:
2
2
  def mongoid__document_view(obj)
3
- {:fields=>['_id'] + obj.class.fields.keys}
3
+ fields = obj.class.fields.keys
4
+ fields.delete('_id')
5
+ fields.unshift('_id')
6
+ {:fields=>fields}
4
7
  end
5
8
 
6
9
  def mongo_mapper__document_view(obj)
@@ -11,4 +14,4 @@ module Hirb::Views::MongoDb #:nodoc:
11
14
  alias_method :mongo_mapper__embedded_document_view, :mongo_mapper__document_view
12
15
  end
13
16
 
14
- Hirb::DynamicView.add Hirb::Views::MongoDb, :helper=>:auto_table
17
+ Hirb::DynamicView.add Hirb::Views::MongoDb, :helper=>:auto_table
@@ -3,13 +3,16 @@ require File.join(File.dirname(__FILE__), 'test_helper')
3
3
  describe "auto table" do
4
4
  it "converts nonarrays to arrays and renders" do
5
5
  require 'set'
6
+ # rubinius sorts Set#to_a differently
7
+ arr = RUBY_DESCRIPTION.include?('rubinius') ? Set.new([1,2,3]).to_a : [1,2,3]
8
+
6
9
  expected_table = <<-TABLE.unindent
7
10
  +-------+
8
11
  | value |
9
12
  +-------+
10
- | 1 |
11
- | 2 |
12
- | 3 |
13
+ | #{arr[0]} |
14
+ | #{arr[1]} |
15
+ | #{arr[2]} |
13
16
  +-------+
14
17
  3 rows in set
15
18
  TABLE
@@ -27,4 +30,4 @@ describe "auto table" do
27
30
  TABLE
28
31
  Helpers::AutoTable.render({:a=>12345}).should == expected_table
29
32
  end
30
- end
33
+ end
@@ -4,7 +4,7 @@ describe "View" do
4
4
  def formatter_config
5
5
  View.formatter.config
6
6
  end
7
-
7
+
8
8
  it "page_output pages when view is enabled" do
9
9
  Hirb.enable
10
10
  View.pager.stubs(:activated_by?).returns(true)
@@ -101,12 +101,22 @@ describe "View" do
101
101
 
102
102
  describe "resize" do
103
103
  def pager; View.pager; end
104
- before { View.pager = nil; reset_config; Hirb.enable }
104
+ before do
105
+ View.pager = nil; reset_config; Hirb.enable
106
+ end
107
+
105
108
  after { Hirb.disable}
106
109
  it "changes width and height with stty" do
110
+ if RUBY_PLATFORM[/java/]
111
+ Util.expects(:command_exists?).with('tput').returns(false)
112
+ end
113
+ # stub tty? since running with rake sets
114
+ STDIN.stubs(:tty?).returns(true)
107
115
  Util.expects(:command_exists?).with('stty').returns(true)
108
116
  ENV['COLUMNS'] = ENV['LINES'] = nil # bypasses env usage
109
- View.resize
117
+
118
+ capture_stderr { View.resize }
119
+
110
120
  pager.width.should.not == 10
111
121
  pager.height.should.not == 10
112
122
  reset_terminal_size
@@ -121,8 +131,11 @@ describe "View" do
121
131
 
122
132
  it "with no environment or stty still has valid width and height" do
123
133
  View.config[:width] = View.config[:height] = nil
124
- Util.expects(:command_exists?).with('stty').returns(false)
134
+ unless RUBY_PLATFORM[/java/]
135
+ Util.expects(:command_exists?).with('stty').returns(false)
136
+ end
125
137
  ENV['COLUMNS'] = ENV['LINES'] = nil
138
+
126
139
  View.resize
127
140
  pager.width.is_a?(Integer).should == true
128
141
  pager.height.is_a?(Integer).should == true
@@ -150,13 +163,13 @@ describe "View" do
150
163
  View.render_method.expects(:call).with(string)
151
164
  View.capture_and_render { print string }
152
165
  end
153
-
166
+
154
167
  it "state is toggled by toggle_pager" do
155
168
  previous_state = View.config[:pager]
156
169
  View.toggle_pager
157
170
  View.config[:pager].should == !previous_state
158
171
  end
159
-
172
+
160
173
  it "state is toggled by toggle_formatter" do
161
174
  previous_state = View.config[:formatter]
162
175
  View.toggle_formatter
@@ -10,4 +10,13 @@ describe "activerecord table" do
10
10
  pet = stub(:name=>'rufus', :age=>7, :attributes=>{'name'=>'rufus'}, :class=>stub(:column_names=>%w{age name}))
11
11
  Helpers::AutoTable.active_record__base_view(pet).should == {:fields=>[:name]}
12
12
  end
13
- end
13
+ end
14
+
15
+ describe "mongoid table" do
16
+ it "only has one _id" do
17
+ fields = {'_id' => 'x0f0x', 'name' => 'blah'}
18
+ mongoid_stub = stub(:class => stub(:fields => fields))
19
+ Helpers::AutoTable.mongoid__document_view(mongoid_stub).should ==
20
+ {:fields => fields.keys.sort}
21
+ end
22
+ end
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.0
4
+ version: 0.6.1
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: 2011-11-28 00:00:00.000000000 Z
12
+ date: 2012-03-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
16
- requirement: &2152986240 !ruby/object:Gem::Requirement
16
+ requirement: &70230866543140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2152986240
24
+ version_requirements: *70230866543140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mocha
27
- requirement: &2152985720 !ruby/object:Gem::Requirement
27
+ requirement: &70230866542680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.8
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2152985720
35
+ version_requirements: *70230866542680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mocha-on-bacon
38
- requirement: &2152985220 !ruby/object:Gem::Requirement
38
+ requirement: &70230866514280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.1.1
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2152985220
46
+ version_requirements: *70230866514280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bacon-bits
49
- requirement: &2152984840 !ruby/object:Gem::Requirement
49
+ requirement: &70230866513900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152984840
57
+ version_requirements: *70230866513900
58
58
  description: Hirb provides a mini view framework for console applications and uses
59
59
  it to improve ripl(irb)'s default inspect output. Given an object or array of objects,
60
60
  hirb renders a view based on the object's class and/or ancestry. Hirb offers reusable
@@ -124,6 +124,7 @@ files:
124
124
  - test/deps.rip
125
125
  - Rakefile
126
126
  - .gemspec
127
+ - .travis.yml
127
128
  homepage: http://tagaholic.me/hirb/
128
129
  licenses:
129
130
  - MIT
@@ -145,9 +146,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
146
  version: 1.3.5
146
147
  requirements: []
147
148
  rubyforge_project:
148
- rubygems_version: 1.8.10
149
+ rubygems_version: 1.8.15
149
150
  signing_key:
150
151
  specification_version: 3
151
152
  summary: A mini view framework for console/irb that's easy to use, even while under
152
153
  its influence.
153
154
  test_files: []
155
+ has_rdoc: