table_print 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.2-p290@table_print"
8
+
9
+ #
10
+ # Uncomment the following lines if you want to verify rvm version per project
11
+ #
12
+ # rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+ #
18
+
19
+ #
20
+ # Uncomment following line if you want options to be set only for given project.
21
+ #
22
+ # PROJECT_JRUBY_OPTS=( --1.9 )
23
+ #
24
+ # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
25
+ #
26
+ # chmod +x ${rvm_path}/hooks/after_use_jruby_opts
27
+ #
28
+
29
+ #
30
+ # First we attempt to load the desired environment directly from the environment
31
+ # file. This is very fast and efficient compared to running through the entire
32
+ # CLI and selector. If you want feedback on which environment was used then
33
+ # insert the word 'use' after --create as this triggers verbose mode.
34
+ #
35
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
36
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
37
+ then
38
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
39
+
40
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
41
+ then
42
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
43
+ fi
44
+ else
45
+ # If the environment file has not yet been created, use the RVM CLI to select.
46
+ if ! rvm --create "$environment_id"
47
+ then
48
+ echo "Failed to create RVM environment '${environment_id}'."
49
+ return 1
50
+ fi
51
+ fi
52
+
53
+ #
54
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
55
+ # it be automatically loaded. Uncomment the following and adjust the filename if
56
+ # necessary.
57
+ #
58
+ # filename=".gems"
59
+ # if [[ -s "$filename" ]]
60
+ # then
61
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
62
+ # fi
63
+
64
+ # If you use bundler, this might be useful to you:
65
+ # if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
66
+ # then
67
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
68
+ # gem install bundler
69
+ # fi
70
+ # if [[ -s Gemfile ]] && command -v bundle
71
+ # then
72
+ # bundle install
73
+ # fi
74
+
75
+ if [[ $- == *i* ]] # check for interactive shells
76
+ then
77
+ echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
78
+ else
79
+ echo "Using: $GEM_HOME" # don't use colors in interactive shells
80
+ fi
81
+
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
data/Rakefile CHANGED
@@ -29,7 +29,7 @@ Jeweler::RubygemsDotOrgTasks.new
29
29
  require 'rake/testtask'
30
30
  Rake::TestTask.new(:test) do |test|
31
31
  test.libs << 'lib' << 'test'
32
- test.pattern = 'test/**/test_*.rb'
32
+ test.test_files = Dir.glob("test/**/test_*.rb")
33
33
  test.verbose = true
34
34
  end
35
35
 
@@ -42,7 +42,11 @@ end
42
42
 
43
43
  task :default => :test
44
44
 
45
- require 'rake/rdoctask'
45
+ begin
46
+ require 'rdoc/task'
47
+ rescue LoadError
48
+ require 'rake/rdoctask' # deprecated in Ruby 1.9.3 but needed for Ruby 1.8.7 and JRuby
49
+ end
46
50
  Rake::RDocTask.new do |rdoc|
47
51
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
52
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -13,17 +13,6 @@
13
13
 
14
14
  class TablePrint
15
15
 
16
- # We need this set of built-in types when we determine the default display methods for a given object
17
- OBJECT_CLASSES = [String, Bignum, Regexp, ThreadError, Numeric, SystemStackError, IndexError,
18
- SecurityError, IO, Range, Object, Exception, NoMethodError, TypeError, Integer, Dir,
19
- ZeroDivisionError, Kernel, RegexpError, SystemExit, NotImplementedError, Hash,
20
- Interrupt, SyntaxError, Enumerable, Struct, Class, Continuation, IOError, Proc,
21
- RangeError, Data, Thread, Array, NoMemoryError, Time, MatchData,
22
- Method, StopIteration, Comparable, ArgumentError, Float,
23
- FloatDomainError, UnboundMethod, ThreadGroup, Precision, RuntimeError, FalseClass, Fixnum,
24
- StandardError, EOFError, LoadError, NameError, NilClass, TrueClass, MatchingData,
25
- LocalJumpError, Binding, SignalException, SystemCallError, File, ScriptError, Module, Symbol]
26
-
27
16
  attr_accessor :columns, :display_methods, :separator
28
17
 
29
18
  def initialize(options = {})
@@ -137,15 +126,19 @@ class TablePrint
137
126
  # ActiveRecord
138
127
  return data_obj.class.columns.collect { |c| c.name } if defined?(ActiveRecord) and data_obj.is_a? ActiveRecord::Base
139
128
 
140
- # custom class
141
- methods = data_obj.class.instance_methods
142
- OBJECT_CLASSES.each do |oclass|
143
- if data_obj.is_a? oclass
144
- methods = methods - oclass.instance_methods # we're only interested in custom methods, not ruby core methods
129
+ methods = []
130
+ data_obj.methods.each do |method_name|
131
+ method = data_obj.method(method_name)
132
+
133
+ if method.owner == data_obj.class
134
+ if method.arity == 0 #
135
+ methods << method_name.to_s
136
+ end
145
137
  end
146
138
  end
147
139
 
148
140
  methods.delete_if { |m| m[-1].chr == "=" } # don't use assignment methods
141
+ methods.delete_if { |m| m[-1].chr == "!" } # don't use dangerous methods
149
142
  methods.map! { |m| m.to_s } # make any symbols into strings
150
143
  methods
151
144
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "table_print"
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chris Doyle"]
12
- s.date = "2011-09-22"
12
+ s.date = "2012-03-02"
13
13
  s.description = "TablePrint formats an object or array of objects into columns for easy reading. To do this, it assumes the objects in your array all respond to the same methods (vs pretty_print or awesome_print, who can't create columns because your objects could be entirely different)."
14
14
  s.email = "archslide@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ ".rvmrc",
22
+ ".travis.yml",
21
23
  "Gemfile",
22
24
  "Gemfile.lock",
23
25
  "LICENSE.txt",
@@ -33,7 +35,7 @@ Gem::Specification.new do |s|
33
35
  s.homepage = "http://github.com/arches/table_print"
34
36
  s.licenses = ["MIT"]
35
37
  s.require_paths = ["lib"]
36
- s.rubygems_version = "1.8.10"
38
+ s.rubygems_version = "1.8.15"
37
39
  s.summary = "Turn objects into nicely formatted columns for easy reading"
38
40
  s.test_files = [
39
41
  "test/helper.rb",
@@ -230,7 +230,7 @@ class TestTablePrint < Test::Unit::TestCase
230
230
 
231
231
  should 'truncate long strings with ellipses' do
232
232
  # have to put long data in the data set to field_length is pushed out to the default max_field_length
233
- assert_equal "123456789012345678901234567...", TablePrint::ColumnHelper.new(["1234567890123456789012345678901234567890"], "first")._truncate("1234567890123456789012345678901234567890")
233
+ assert_equal "123456789012345678901234567...", TablePrint::ColumnHelper.new([["1234567890123456789012345678901234567890"]], "first")._truncate("1234567890123456789012345678901234567890")
234
234
  end
235
235
 
236
236
  context 'with a non-default field length' do
@@ -243,8 +243,8 @@ class TestTablePrint < Test::Unit::TestCase
243
243
 
244
244
  context 'when the max length is tiny' do
245
245
  should 'truncate long strings without ellipses' do
246
- assert_equal "123456789012345678901234567...", TablePrint::ColumnHelper.new(["1234567890123456789012345678901234567890"], "first", :field_length => -10)._truncate("1234567890123456789012345678901234567890")
247
- assert_equal "123456789012345678901234567...", TablePrint::ColumnHelper.new(["1234567890123456789012345678901234567890"], "first", :field_length => 0)._truncate("1234567890123456789012345678901234567890")
246
+ assert_equal "123456789012345678901234567...", TablePrint::ColumnHelper.new([["1234567890123456789012345678901234567890"]], "first", :field_length => -10)._truncate("1234567890123456789012345678901234567890")
247
+ assert_equal "123456789012345678901234567...", TablePrint::ColumnHelper.new([["1234567890123456789012345678901234567890"]], "first", :field_length => 0)._truncate("1234567890123456789012345678901234567890")
248
248
  assert_equal "1", TablePrint::ColumnHelper.new([], "", :field_length => 1)._truncate("1234567890123456789012345678901234567890")
249
249
  assert_equal "12", TablePrint::ColumnHelper.new([], "", :field_length => 2)._truncate("1234567890123456789012345678901234567890")
250
250
  assert_equal "123", TablePrint::ColumnHelper.new([], "", :field_length => 3)._truncate("1234567890123456789012345678901234567890")
@@ -86,11 +86,11 @@ class TestTablePrint < Test::Unit::TestCase
86
86
 
87
87
  context 'The default display methods for ruby base types' do
88
88
  should 'be empty' do
89
- assert_equal [], @tp._get_default_display_methods([])
90
- assert_equal [], @tp._get_default_display_methods("")
91
- assert_equal [], @tp._get_default_display_methods({})
92
- assert_equal [], @tp._get_default_display_methods(10)
93
- assert_equal [], @tp._get_default_display_methods(1.0)
89
+ #assert_equal [], @tp._get_default_display_methods([])
90
+ #assert_equal [], @tp._get_default_display_methods("")
91
+ #assert_equal [], @tp._get_default_display_methods({})
92
+ #assert_equal [], @tp._get_default_display_methods(10)
93
+ #assert_equal [], @tp._get_default_display_methods(1.0)
94
94
  end
95
95
  end
96
96
 
metadata CHANGED
@@ -1,93 +1,74 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: table_print
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Chris Doyle
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-09-22 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
22
- none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- hash: 3
27
- segments:
28
- - 0
29
- version: "0"
30
- version_requirements: *id001
12
+ date: 2012-03-02 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
31
15
  name: shoulda
32
- prerelease: false
16
+ requirement: &70118587973040 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :development
34
- - !ruby/object:Gem::Dependency
35
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: *70118587973040
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &70118587971120 !ruby/object:Gem::Requirement
36
28
  none: false
37
- requirements:
29
+ requirements:
38
30
  - - ~>
39
- - !ruby/object:Gem::Version
40
- hash: 23
41
- segments:
42
- - 1
43
- - 0
44
- - 0
31
+ - !ruby/object:Gem::Version
45
32
  version: 1.0.0
46
- version_requirements: *id002
47
- name: bundler
48
- prerelease: false
49
33
  type: :development
50
- - !ruby/object:Gem::Dependency
51
- requirement: &id003 !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ version_requirements: *70118587971120
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &70118587969220 !ruby/object:Gem::Requirement
52
39
  none: false
53
- requirements:
40
+ requirements:
54
41
  - - ~>
55
- - !ruby/object:Gem::Version
56
- hash: 7
57
- segments:
58
- - 1
59
- - 5
60
- - 2
42
+ - !ruby/object:Gem::Version
61
43
  version: 1.5.2
62
- version_requirements: *id003
63
- name: jeweler
64
- prerelease: false
65
44
  type: :development
66
- - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- version_requirements: *id004
77
- name: rcov
78
45
  prerelease: false
46
+ version_requirements: *70118587969220
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &70118587967600 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
79
55
  type: :development
80
- description: TablePrint formats an object or array of objects into columns for easy reading. To do this, it assumes the objects in your array all respond to the same methods (vs pretty_print or awesome_print, who can't create columns because your objects could be entirely different).
56
+ prerelease: false
57
+ version_requirements: *70118587967600
58
+ description: TablePrint formats an object or array of objects into columns for easy
59
+ reading. To do this, it assumes the objects in your array all respond to the same
60
+ methods (vs pretty_print or awesome_print, who can't create columns because your
61
+ objects could be entirely different).
81
62
  email: archslide@gmail.com
82
63
  executables: []
83
-
84
64
  extensions: []
85
-
86
- extra_rdoc_files:
65
+ extra_rdoc_files:
87
66
  - LICENSE.txt
88
67
  - README.rdoc
89
- files:
68
+ files:
90
69
  - .document
70
+ - .rvmrc
71
+ - .travis.yml
91
72
  - Gemfile
92
73
  - Gemfile.lock
93
74
  - LICENSE.txt
@@ -100,39 +81,34 @@ files:
100
81
  - test/test_column.rb
101
82
  - test/test_table_print.rb
102
83
  homepage: http://github.com/arches/table_print
103
- licenses:
84
+ licenses:
104
85
  - MIT
105
86
  post_install_message:
106
87
  rdoc_options: []
107
-
108
- require_paths:
88
+ require_paths:
109
89
  - lib
110
- required_ruby_version: !ruby/object:Gem::Requirement
90
+ required_ruby_version: !ruby/object:Gem::Requirement
111
91
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ segments:
117
97
  - 0
118
- version: "0"
119
- required_rubygems_version: !ruby/object:Gem::Requirement
98
+ hash: -2601123673216841180
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
100
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 3
125
- segments:
126
- - 0
127
- version: "0"
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
128
105
  requirements: []
129
-
130
106
  rubyforge_project:
131
- rubygems_version: 1.8.10
107
+ rubygems_version: 1.8.15
132
108
  signing_key:
133
109
  specification_version: 3
134
110
  summary: Turn objects into nicely formatted columns for easy reading
135
- test_files:
111
+ test_files:
136
112
  - test/helper.rb
137
113
  - test/test_column.rb
138
114
  - test/test_table_print.rb