Every repository with this icon (
Every repository with this icon (
| Description: | A mini view framework for console/irb that's easy to use, even while under its influence. Console goodies include a no-wrap table, auto-pager, tree and menu. edit |
-
ERROR: Error installing hirb:
invalid gem format for /Library/Ruby/Gems/1.8/cache/hirb-0.2.9.gemAny idea what might be causing this?
Comments
-
If I'm paging through a long ActiveRecord resultset and press Q to quit paging, I get the following error:
Errno::EPIPE: Broken pipe from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/pager.rb:40:in `write' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/pager.rb:40:in `puts' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/pager.rb:40:in `basic_pager' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/pager.rb:7:in `command_pager' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/pager.rb:65:in `page' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/view.rb:156:in `page_output' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/view.rb:188:in `default_render_method' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/view.rb:142:in `call' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/view.rb:142:in `render_output' from /usr/lib/ruby/gems/1.8/gems/hirb-0.2.7/lib/hirb/view.rb:70:in `view_output' ...etc...Comments
markthomas
Wed Nov 04 18:30:22 -0800 2009
| link
Great--thanks!
-
Extract out table formatters into its own gem
2 comments Created 2 months ago by smtlaissezfaireI'd like to reuse the code you are using to display the tables. The closes thing that I've found is the terminal-table package:
Comments
I'm not sure I understand the issue. If you want to extract out parts of hirb, feel free to. It's a MIT license. If you're requesting to break down hirb into smaller gems, please explain why. I personally have no need to do that.
smtlaissezfaire
Tue Oct 13 19:03:45 -0700 2009
| link
Cool. I'm closing this ticket.
-
Cryptic error when displaying an array of more than 1 type of ActiveRecord object
2 comments Created 2 months ago by pdobbIt took me a while to figure out that this wasn't my app, and was instead Hirb. Simple enough to reproduce though (oversimplified test case):
$$ [User.first, Link.first]
NoMethodError: undefined method `username' for #<Link:0x6ccdea8>
from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/attribute_methods.rb:260:in `method_missing' from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/time/zones.rb:81:in `inject' from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:2036:in `inject' from (eval):6:in `output_value' from C:/Ruby/lib/ruby/1.8/irb.rb:151:in `eval_input' from C:/Ruby/lib/ruby/1.8/irb.rb:263:in `signal_status' from C:/Ruby/lib/ruby/1.8/irb.rb:147:in `eval_input' from C:/Ruby/lib/ruby/1.8/irb.rb:146:in `eval_input' from C:/Ruby/lib/ruby/1.8/irb.rb:70:in `start' from C:/Ruby/lib/ruby/1.8/irb.rb:69:in `catch' from C:/Ruby/lib/ruby/1.8/irb.rb:69:in `start' from C:/Ruby/bin/irb:13$$ Hirb.disable => nil
$$ [User.first, Link.first] => [#, #]
Note that the table view from Hirb does work fine if I use 2 ActiveRecord objects of the same type, e.g. [User.first, User.last].
If this error could somehow be trapped and a meaningful error displayed back to the user in its stead (so they don't spend an hour trying to debug their app like I did) that would be fantastic.
Thanks very much!
Comments
-
Hirb doesn't read hirb.yml when not in RAILS_ROOT
1 comment Created 3 months ago by jacobatI've created RAILS_ROOT/config/hirb.yml and it works as long as cwd == RAILS_ROOT, but If I do:
cd RAILS_ROOT/app/models
../../script/consolethen Hirb will not load the config provided.
Comments
-
Can't enable Hirb with Rails 2.3.4 on Windows
3 comments Created 3 months ago by freakentHi,
I've installed the Hirb gem on my Windows development machine but I get an error when I try to enable hirb.
1) C:\InstantRails\rails_apps\app>gem install cldwalker-hirb --source http://gems.github.com
2) C:\InstantRails\rails_apps\app>ruby script/console
Loading development environment (Rails 2.3.4)
3) require 'hirb'
=> []4) Hirb.enable
TypeError: can't convert nil into String
from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/cldwalker-hirb-0.2.5/lib/hirb.rb:44:in `join' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/cldwalker-hirb-0.2.5/lib/hirb.rb:44:in `config_file' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/cldwalker-hirb-0.2.5/lib/hirb.rb:52:in `read_config_file' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/cldwalker-hirb-0.2.5/lib/hirb.rb:57:in `config' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/cldwalker-hirb-0.2.5/lib/hirb/view.rb:186:in `default_config' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/cldwalker-hirb-0.2.5/lib/hirb/view.rb:170:in `load_config' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/cldwalker-hirb-0.2.5/lib/hirb/view.rb:30:in `enable' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/cldwalker-hirb-0.2.5/lib/hirb.rb:35:in `enable' from (irb):2:in `irb_binding' from C:/InstantRails/ruby/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding' from C:/InstantRails/ruby/lib/ruby/1.8/irb/workspace.rb:52Maybe IRB bug!!
Comments
As a work around, I created an empty hirb.yml in my rails app's config directory.
c:\InstantRails\rails_apps\app\config\hirb.ymlGreat, thanks for the solution!
I've just met the same problem. -
Hirb not recognized when loaded from .irbrc
5 comments Created 3 months ago by jeroenvandijkThe following was tested with rails(1.2.3, 2.3.2 and 2.3.3) and ruby 1.8.6
Given a file ~/.irbrc with:
if ENV['RAILS_ENV'] require 'hirb' Hirb.enable end$ script/console Loading development environment (Rails 2.3.3)
Hirb NameError: uninitialized constant Hirb
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:443:in `load_missing_constant' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:92:in `const_missing' from (irb):1When requesting several activerecord objects they get printed as usual without Hirb.
Comments
jeroenvandijk
Tue Sep 01 02:15:26 -0700 2009
| link
Note that I'm sure .irbrc gets loaded. Because the following gives me an error:
if ENV['RAILS_ENV'] raise "test" require 'hirb' Hirb.enable endYou'll need to require 'rubygems' before require 'hirb':
if ENV['RAILS_ENV'] require 'rubygems' require 'hirb' Hirb.enable end
jeroenvandijk
Tue Sep 01 02:50:25 -0700 2009
| link
Thanks that was indeed all to it! I feel a bit stupid now :)
Another gotcha is that Hirb does not seem to work at all if the utility_belt gem is loaded. At some point I'd like to fix this since I want to use both. :)
-
Hirb provokes error when putting two instances of different AR models in an array
2 comments Created 5 months ago by Florent2Looks like Hirb wants the two instances to have the same attributes, see http://pastie.org/545906
Comments
I've never needed to handle arrays of model objects from multiple models. But you're welcome to create your own helper like Hirb::Helpers::ActiveRecordTable. Here's where the ActiveRecord attributes are set: http://github.com/cldwalker/hirb/blob/c5123e5347fee0c4eec97f7dc13bdca020977c31/lib/hirb/helpers/active_record_table.rb#L11
-
I've created a crude patch (read: hack) for outputting tables vertically (known as "vertical output" in the mysql command-line client). This is very useful for larger tables. An usage example can be seen here:
If there's interest for adding this to the mainline I can create a proper patch with some more tests. My fork is available here.
Comments
-
Hello and "bravo" for Hirb. That's a great idea !
There is a little problem with handling UTF-8 characters like the french é or à or in other languages ö for instance. The characters count is off and the displayed is shifted to the left :
+----+---------------------+-------------+--------------------+----------+-----------+-------------------------+-------------------------+---------------+ | id | name | baptized_at | constellation_code | order_id | bundle_id | created_at | updated_at | language_code | +----+---------------------+-------------+--------------------+----------+-----------+-------------------------+-------------------------+---------------+ | 1 | Tata l'asticote | 2009-04-23 | And | | 0 | 2009-04-23 16:17:30 UTC | 2009-04-23 16:17:30 UTC | fr | | 2 | toto létoile PAOLI | 2009-04-23 | And | | 0 | 2009-04-23 16:17:41 UTC | 2009-04-23 16:17:41 UTC | fr |
Maybe looking into Rails' multibyte characters handling methods (like using .mb_chars) could help ?
Thanks for your work :)
Comments
Merci pour cette bonne idée. I don't know much about multibyte characters but I'll look into it when I get a chance. I'll be looking for a solution that doesn't depend on Rails' activesupport. From looking at jcode from standard lib, finding the length of a multibyte string, @string, could be as simple as:
@string.gsub(/[^\Wa-zA-Z_\d]/, ' ').length -
TooManyFieldsForWidthError on table with many columns
8 comments Created 6 months ago by jhulickThe following error seems to occur when selecting a record from a table with many columns (28 columns in my case):
Hirb::View.formatter_config => {"ActiveRecord::Base"=>{:class=>"Hirb::Views::ActiveRecord_Base", :ancestor=>true}} User.last SQL (34.9ms) SET NAMES 'utf8' SQL (13.5ms) SET SQL_AUTO_IS_NULL=0 User Load (240.0ms) SELECT * FROM
usersORDER BY users.id DESC LIMIT 1 User Columns (2.6ms) SHOW FIELDS FROMusersHirb::Helpers::Table::TooManyFieldsForWidthError: Hirb::Helpers::Table::TooManyFieldsForWidthError
from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/helpers/table.rb:159:in `adjust_long_fields' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/helpers/table.rb:147:in `restrict_field_lengths' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/helpers/table.rb:139:in `setup_field_lengths' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/helpers/table.rb:92:in `render' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/helpers/table.rb:53:in `render' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/helpers/object_table.rb:13:in `render' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/helpers/active_record_table.rb:14:in `render' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/views/activerecord_base.rb:7:in `render' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/formatter.rb:137:in `format_output' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/view.rb:117:in `render_output' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/view.rb:75:in `view_output' from /Library/Ruby/Gems/1.8/gems/cldwalker-hirb-0.2.1/lib/hirb/view.rb:31:in `output_value' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:151:in `eval_input' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:263:in `signal_status'Comments
yeah, same here, too bad :(
Pretty cool project however !
manuelmeurer
Sun Jun 28 09:14:06 -0700 2009
| link
It seems to me that Hirb should fall back to showing the record(s) in standard IRB output instead of showing this error...
This error occurs when you're trying to display too many columns for your given width. You can avoid this error by increasing your width or choosing only certain columns to display for your table. For the above User model, you could configure Hirb with this:
Hirb.enable :output=>{"User"=>{:options=>{:fields=>%w{field1 field2 field3} } } }
Although the above fallback suggestion is ok, I would rather show as many columns as possible. Would you prefer that default behavior as opposed to displaying this error?
Let me know if you come across any other bumps in configuring hirb. The docs, http://tagaholic.me/hirb/doc/, should be helpful.
While having the option to limit the columns Hirb shows is great. I would definitely prefer falling back to the default output instead of an error.
Another option: since Hirb::Helpers::Table output looks like standard mysql select output, how about adding support for vertical table output? That would solve the too many columns problem and would be pretty slick with pagination too.
I agree, falling on the default output would be much better. Otherwise Hirb can (almost) not be used on a small screen and/or a large model.
manuelmeurer
Mon Jun 29 00:14:24 -0700 2009
| link
Showing as many columns as possible with an indicator that there are more columns would be an option as well. I think we all agree that showing an error is the worst possible solution... :)
Looks like Chrononaut already created a vertical output "hack" #5 in case anyone else is interested.












Rubygems issue -- very odd.
I'm guessing you've solved this. If you haven't here's a possible solution.
Yep all good.