awesome_print 0.2.1 → 0.4.0

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.
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
+ #
3
+ # Awesome Print is freely distributable under the terms of MIT license.
4
+ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
6
+ #
7
+ # Method#name was intorduced in Ruby 1.8.7 so we define it here as necessary.
8
+ #
9
+ unless nil.method(:class).respond_to?(:name)
10
+ class Method
11
+ def name
12
+ inspect.split(/[#.>]/)[-1]
13
+ end
14
+ end
15
+
16
+ class UnboundMethod
17
+ def name
18
+ inspect.split(/[#.>]/)[-1]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
+ #
3
+ # Awesome Print is freely distributable under the terms of MIT license.
4
+ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
6
+ class Object #:nodoc:
7
+ # Remaining instance '_methods' are handled in core_ext/class.rb.
8
+ %w(methods private_methods protected_methods public_methods singleton_methods).each do |name|
9
+ original_method = instance_method(name)
10
+
11
+ define_method name do |*args|
12
+ methods = original_method.bind(self).call(*args)
13
+ methods.instance_variable_set('@__awesome_methods__', self) # Evil?!
14
+ methods.sort!
15
+ end
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010 Michael Dvorkin
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
2
  #
3
3
  # Awesome Print is freely distributable under the terms of MIT license.
4
4
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
@@ -11,13 +11,14 @@ class String
11
11
  # 1 => bright
12
12
  # 0 => normal
13
13
 
14
- [ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i|
15
- if STDOUT.tty? && ENV['TERM'] && ENV['TERM'] != 'dumb'
16
- define_method color do "\033[1;#{30+i}m#{self}\033[0m" end
17
- define_method :"#{color}ish" do "\033[0;#{30+i}m#{self}\033[0m" end
18
- else
19
- define_method color do self end
20
- alias_method :"#{color}ish", color
14
+ %w(gray red green yellow blue purple cyan white).zip(
15
+ %w(black darkred darkgreen brown navy darkmagenta darkcyan slategray)).each_with_index do |(color, shade), i|
16
+ define_method color do |*html|
17
+ html[0] ? %Q|<pre style="color:#{color}">#{self}</pre>| : "\033[1;#{30+i}m#{self}\033[0m"
18
+ end
19
+
20
+ define_method "#{color}ish" do |*html|
21
+ html[0] ? %Q|<pre style="color:#{shade}">#{self}</pre>| : "\033[0;#{30+i}m#{self}\033[0m"
21
22
  end
22
23
  end
23
24
 
@@ -1,38 +1,17 @@
1
- # Copyright (c) 2010 Michael Dvorkin
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
2
  #
3
3
  # Awesome Print is freely distributable under the terms of MIT license.
4
4
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  module AwesomePrintActionView
7
7
 
8
- def self.included(base)
9
- unless base.const_defined?(:AP_ANSI_TO_HTML)
10
- hash = {} # Build ANSI => HTML color map.
11
- [ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i|
12
- hash["\033[1;#{30+i}m"] = color
13
- end
14
- [ :black, :darkred, :darkgreen, :brown, :navy, :darkmagenta, :darkcyan, :slategray ].each_with_index do |color, i|
15
- hash["\033[0;#{30+i}m"] = color
16
- end
17
- base.const_set(:AP_ANSI_TO_HTML, hash.freeze)
18
- end
19
- end
20
-
8
+ # Use HTML colors and add default "debug_dump" class to the resulting HTML.
21
9
  def ap_debug(object, options = {})
22
- formatted = h(object.ai(options))
23
-
24
- unless options[:plain]
25
- self.class::AP_ANSI_TO_HTML.each do |key, value|
26
- formatted.gsub!(key, %Q|<font color="#{value}">|)
27
- end
28
- formatted.gsub!("\033[0m", "</font>")
29
- end
30
-
31
- content_tag(:pre, formatted, :class => "debug_dump")
10
+ object.ai(options.merge(:html => true)).sub(/^<pre([\s>])/, '<pre class="debug_dump"\\1')
32
11
  end
33
12
 
34
13
  alias_method :ap, :ap_debug
35
14
 
36
15
  end
37
16
 
38
- ActionView::Base.send(:include, AwesomePrintActionView) if defined?(::ActionView)
17
+ ActionView::Base.send(:include, AwesomePrintActionView) if defined?(ActionView)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010 Michael Dvorkin
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
2
  #
3
3
  # Awesome Print is freely distributable under the terms of MIT license.
4
4
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
@@ -14,6 +14,8 @@ module AwesomePrintActiveRecord
14
14
  #------------------------------------------------------------------------------
15
15
  def printable_with_active_record(object)
16
16
  printable = printable_without_active_record(object)
17
+ return printable if !defined?(ActiveRecord::Base)
18
+
17
19
  if printable == :self
18
20
  if object.is_a?(ActiveRecord::Base)
19
21
  printable = :active_record_instance
@@ -27,6 +29,8 @@ module AwesomePrintActiveRecord
27
29
  # Format ActiveRecord instance object.
28
30
  #------------------------------------------------------------------------------
29
31
  def awesome_active_record_instance(object)
32
+ return object.inspect if !defined?(ActiveSupport::OrderedHash)
33
+
30
34
  data = object.class.column_names.inject(ActiveSupport::OrderedHash.new) do |hash, name|
31
35
  hash[name.to_sym] = object.send(name) if object.has_attribute?(name) || object.new_record?
32
36
  hash
@@ -37,17 +41,14 @@ module AwesomePrintActiveRecord
37
41
  # Format ActiveRecord class object.
38
42
  #------------------------------------------------------------------------------
39
43
  def awesome_active_record_class(object)
40
- if object.respond_to?(:columns)
41
- data = object.columns.inject(ActiveSupport::OrderedHash.new) do |hash, c|
42
- hash[c.name.to_sym] = c.type
43
- hash
44
- end
45
- "class #{object} < #{object.superclass} " << awesome_hash(data)
46
- else
47
- object.inspect
44
+ return object.inspect if !defined?(ActiveSupport::OrderedHash) || !object.respond_to?(:columns)
45
+
46
+ data = object.columns.inject(ActiveSupport::OrderedHash.new) do |hash, c|
47
+ hash[c.name.to_sym] = c.type
48
+ hash
48
49
  end
50
+ "class #{object} < #{object.superclass} " << awesome_hash(data)
49
51
  end
50
-
51
52
  end
52
53
 
53
54
  AwesomePrint.send(:include, AwesomePrintActiveRecord)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010 Michael Dvorkin
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
2
  #
3
3
  # Awesome Print is freely distributable under the terms of MIT license.
4
4
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
@@ -14,6 +14,8 @@ module AwesomePrintActiveSupport
14
14
  #------------------------------------------------------------------------------
15
15
  def printable_with_active_support(object)
16
16
  printable = printable_without_active_support(object)
17
+ return printable if !defined?(ActiveSupport::TimeWithZone) || !defined?(HashWithIndifferentAccess)
18
+
17
19
  if printable == :self
18
20
  if object.is_a?(ActiveSupport::TimeWithZone)
19
21
  printable = :active_support_time
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
+ #
3
+ # Awesome Print is freely distributable under the terms of MIT license.
4
+ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
6
+ module AwesomePrintMongoMapper
7
+
8
+ def self.included(base)
9
+ base.send :alias_method, :printable_without_mongo_mapper, :printable
10
+ base.send :alias_method, :printable, :printable_with_mongo_mapper
11
+ end
12
+
13
+ # Add MongoMapper class names to the dispatcher pipeline.
14
+ #------------------------------------------------------------------------------
15
+ def printable_with_mongo_mapper(object)
16
+ printable = printable_without_mongo_mapper(object)
17
+ return printable if !defined?(MongoMapper::Document)
18
+
19
+ if printable == :self
20
+ if object.is_a?(MongoMapper::Document) || object.is_a?(MongoMapper::EmbeddedDocument)
21
+ printable = :mongo_mapper_instance
22
+ end
23
+ elsif printable == :class && (object.ancestors & [MongoMapper::Document, MongoMapper::EmbeddedDocument]).size > 0
24
+ printable = :mongo_mapper_class
25
+ end
26
+ printable
27
+ end
28
+
29
+ # Format MongoMapper instance object.
30
+ #------------------------------------------------------------------------------
31
+ def awesome_mongo_mapper_instance(object)
32
+ return object.inspect if !defined?(ActiveSupport::OrderedHash)
33
+
34
+ data = object.keys.keys.sort_by{|k| k}.inject(ActiveSupport::OrderedHash.new) do |hash, name|
35
+ hash[name] = object[name]
36
+ hash
37
+ end
38
+ "#{object} " + awesome_hash(data)
39
+ end
40
+
41
+ # Format MongoMapper class object.
42
+ #------------------------------------------------------------------------------
43
+ def awesome_mongo_mapper_class(object)
44
+ return object.inspect if !defined?(ActiveSupport::OrderedHash) || !object.respond_to?(:keys)
45
+
46
+ data = object.keys.sort_by{|k| k}.inject(ActiveSupport::OrderedHash.new) do |hash, c|
47
+ hash[c.first] = (c.last.type || "undefined").to_s.underscore.intern
48
+ hash
49
+ end
50
+ "class #{object} < #{object.superclass} " << awesome_hash(data)
51
+ end
52
+ end
53
+
54
+ AwesomePrint.send(:include, AwesomePrintMongoMapper)
data/lib/ap.rb CHANGED
@@ -1,15 +1,24 @@
1
- # Copyright (c) 2010 Michael Dvorkin
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
2
  #
3
3
  # Awesome Print is freely distributable under the terms of MIT license.
4
4
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
- require File.dirname(__FILE__) + "/ap/core_ext/string"
7
- require File.dirname(__FILE__) + "/ap/core_ext/kernel"
8
- require File.dirname(__FILE__) + "/ap/awesome_print"
9
-
10
- require File.dirname(__FILE__) + "/ap/core_ext/logger" if defined?(::Logger) or defined?(::ActiveSupport::BufferedLogger)
6
+ #
7
+ # AwesomePrint might be loaded implicitly through ~/.irbrc so do nothing
8
+ # for subsequent requires.
9
+ #
10
+ unless defined?(AwesomePrint)
11
+ %w(array string method object class kernel).each do |file|
12
+ require File.dirname(__FILE__) + "/ap/core_ext/#{file}"
13
+ end
11
14
 
12
- require File.dirname(__FILE__) + "/ap/mixin/action_view" if defined?(::ActionView)
13
- require File.dirname(__FILE__) + "/ap/mixin/active_record" if defined?(::ActiveRecord)
14
- require File.dirname(__FILE__) + "/ap/mixin/active_support" if defined?(::ActiveSupport)
15
+ require File.dirname(__FILE__) + "/ap/awesome_print"
16
+ require File.dirname(__FILE__) + "/ap/core_ext/logger" if defined?(Logger)
17
+ require File.dirname(__FILE__) + "/ap/mixin/action_view" if defined?(ActionView)
15
18
 
19
+ # Load the following under normal circumstatnces as well as in Rails
20
+ # console when required from ~/.irbrc.
21
+ require File.dirname(__FILE__) + "/ap/mixin/active_record" if defined?(ActiveRecord) || (defined?(IRB) && ENV['RAILS_ENV'])
22
+ require File.dirname(__FILE__) + "/ap/mixin/active_support" if defined?(ActiveSupport) || (defined?(IRB) && ENV['RAILS_ENV'])
23
+ require File.dirname(__FILE__) + "/ap/mixin/mongo_mapper" if defined?(MongoMapper)
24
+ end
@@ -0,0 +1,26 @@
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
+ #
3
+ # Awesome Print is freely distributable under the terms of MIT license.
4
+ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
6
+ #
7
+ # This is the copy of original 'ap.rb' file that matches the gem name. It makes
8
+ # it possible to omit the :require part in bundler's Gemfile:
9
+ #
10
+ # gem 'awesome_print', '>= 0.4.0'
11
+ #
12
+ unless defined?(AwesomePrint)
13
+ %w(array string method object class kernel).each do |file|
14
+ require File.dirname(__FILE__) + "/ap/core_ext/#{file}"
15
+ end
16
+
17
+ require File.dirname(__FILE__) + "/ap/awesome_print"
18
+ require File.dirname(__FILE__) + "/ap/core_ext/logger" if defined?(Logger)
19
+ require File.dirname(__FILE__) + "/ap/mixin/action_view" if defined?(ActionView)
20
+
21
+ # Load the following under normal circumstatnces as well as in Rails
22
+ # console when required from ~/.irbrc.
23
+ require File.dirname(__FILE__) + "/ap/mixin/active_record" if defined?(ActiveRecord) || (defined?(IRB) && ENV['RAILS_ENV'])
24
+ require File.dirname(__FILE__) + "/ap/mixin/active_support" if defined?(ActiveSupport) || (defined?(IRB) && ENV['RAILS_ENV'])
25
+ require File.dirname(__FILE__) + "/ap/mixin/mongo_mapper" if defined?(MongoMapper)
26
+ end
data/rails/init.rb CHANGED
@@ -1 +1,9 @@
1
- require File.join(File.dirname(__FILE__), "..", "init")
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
+ #
3
+ # Awesome Print is freely distributable under the terms of MIT license.
4
+ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
6
+ #
7
+ # Load awesome_print when installed as Rails 2.3.x plugin.
8
+ #
9
+ require File.join(File.dirname(__FILE__), "..", "init") unless defined?(AwesomePrint)
@@ -1,35 +1,25 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- require 'action_view'
4
- require 'ap/mixin/action_view'
3
+ begin
4
+ require 'action_view'
5
+ require 'ap/mixin/action_view'
5
6
 
6
- describe "AwesomePrint ActionView extensions" do
7
- before(:each) do
8
- @view = ActionView::Base.new
9
- end
7
+ describe "AwesomePrint ActionView extension" do
8
+ before(:each) do
9
+ @view = ActionView::Base.new
10
+ end
10
11
 
11
- it "should wrap ap output with <pre> tag" do
12
- obj = 42
13
- @view.ap(obj, :plain => true).should == '<pre class="debug_dump">42</pre>'
14
- end
15
-
16
- it "should encode HTML entities" do
17
- obj = " &<hello>"
18
- @view.ap(obj, :plain => true).should == '<pre class="debug_dump">&quot; &amp;&lt;hello&gt;&quot;</pre>'
19
- end
20
-
21
- it "should convert primary ANSI colors to HTML" do
22
- obj = 42
23
- [ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each do |color|
24
- @view.ap(obj, :color => { :fixnum => color }).should == %Q|<pre class="debug_dump"><font color="#{color}">42</font></pre>|
12
+ it "uses HTML and adds 'debug_dump' class to plain <pre> tag" do
13
+ markup = rand
14
+ @view.ap(markup, :plain => true).should == %Q|<pre class="debug_dump">#{markup}</pre>|
25
15
  end
26
- end
27
16
 
28
- it "should convert mixed ANSI colors to HTML" do
29
- obj = 42
30
- [ :grayish, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :whiteish, :black, :pale ].zip(
31
- [ :black, :darkred, :darkgreen, :brown, :navy, :darkmagenta, :darkcyan, :slategray, :black, :slategray ]) do |ansi, html|
32
- @view.ap(obj, :color => { :fixnum => ansi }).should == %Q|<pre class="debug_dump"><font color="#{html}">42</font></pre>|
17
+ it "uses HTML and adds 'debug_dump' class to colorized <pre> tag" do
18
+ markup = ' &<hello>'
19
+ @view.ap(markup).should == '<pre class="debug_dump" style="color:brown">&quot; &amp;&lt;hello&gt;&quot;</pre>'
33
20
  end
34
21
  end
22
+
23
+ rescue LoadError
24
+ puts "Skipping ActionView specs..."
35
25
  end
@@ -1,94 +1,110 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- require 'active_record'
4
- require 'ap/mixin/active_record'
3
+ begin
4
+ require 'active_record'
5
+ require 'ap/mixin/active_record'
5
6
 
7
+ if defined?(::ActiveRecord)
6
8
 
7
- if defined?(::ActiveRecord)
8
-
9
- # Create tableless ActiveRecord model.
10
- #------------------------------------------------------------------------------
11
- class User < ActiveRecord::Base
12
- def self.columns()
13
- @columns ||= []
14
- end
9
+ # Create tableless ActiveRecord model.
10
+ #------------------------------------------------------------------------------
11
+ class User < ActiveRecord::Base
12
+ def self.columns()
13
+ @columns ||= []
14
+ end
15
15
 
16
- def self.column(name, sql_type = nil, default = nil, null = true)
17
- columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
18
- end
16
+ def self.column(name, sql_type = nil, default = nil, null = true)
17
+ columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
18
+ end
19
19
 
20
- column :id, :integer
21
- column :name, :string
22
- column :rank, :integer
23
- column :admin, :boolean
24
- column :created_at, :datetime
20
+ column :id, :integer
21
+ column :name, :string
22
+ column :rank, :integer
23
+ column :admin, :boolean
24
+ column :created_at, :datetime
25
25
 
26
- def self.table_exists?
27
- true
26
+ def self.table_exists?
27
+ true
28
+ end
28
29
  end
29
- end
30
30
 
31
- class SubUser < User
32
- def self.columns
33
- User.columns
31
+ class SubUser < User
32
+ def self.columns
33
+ User.columns
34
+ end
34
35
  end
35
- end
36
36
 
37
- describe "AwesomePrint/ActiveRecord" do
38
- before(:each) do
39
- stub_dotfile!
40
- end
41
-
42
- #------------------------------------------------------------------------------
43
- describe "ActiveRecord instance" do
37
+ describe "AwesomePrint/ActiveRecord" do
44
38
  before(:each) do
45
- ActiveRecord::Base.default_timezone = :utc
46
- @diana = User.new(:name => "Diana", :rank => 1, :admin => false, :created_at => "1992-10-10 12:30:00")
47
- @laura = User.new(:name => "Laura", :rank => 2, :admin => true, :created_at => "2003-05-26 14:15:00")
48
- @ap = AwesomePrint.new(:plain => true)
39
+ stub_dotfile!
49
40
  end
50
41
 
51
- it "display single record" do
52
- out = @ap.send(:awesome, @diana)
53
- out.gsub(/0x([a-f\d]+)/, "0x01234567").should == <<-EOS.strip
42
+ #------------------------------------------------------------------------------
43
+ describe "ActiveRecord instance" do
44
+ before(:each) do
45
+ ActiveRecord::Base.default_timezone = :utc
46
+ @diana = User.new(:name => "Diana", :rank => 1, :admin => false, :created_at => "1992-10-10 12:30:00")
47
+ @laura = User.new(:name => "Laura", :rank => 2, :admin => true, :created_at => "2003-05-26 14:15:00")
48
+ @ap = AwesomePrint.new(:plain => true)
49
+ end
50
+
51
+ it "display single record" do
52
+ out = @ap.send(:awesome, @diana)
53
+ str = <<-EOS.strip
54
54
  #<User:0x01234567> {
55
55
  :id => nil,
56
56
  :name => "Diana",
57
57
  :rank => 1,
58
58
  :admin => false,
59
- :created_at => Sat Oct 10 12:30:00 UTC 1992
59
+ :created_at => ?
60
60
  }
61
61
  EOS
62
- end
62
+ if RUBY_VERSION.to_f < 1.9
63
+ str.sub!('?', 'Sat Oct 10 12:30:00 UTC 1992')
64
+ else
65
+ str.sub!('?', '1992-10-10 12:30:00 UTC')
66
+ end
67
+
68
+ out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
69
+ end
63
70
 
64
- it "display multiple records" do
65
- out = @ap.send(:awesome, [ @diana, @laura ])
66
- out.gsub(/0x([a-f\d]+)/, "0x01234567").should == <<-EOS.strip
71
+ it "display multiple records" do
72
+ out = @ap.send(:awesome, [ @diana, @laura ])
73
+ str = <<-EOS.strip
67
74
  [
68
75
  [0] #<User:0x01234567> {
69
76
  :id => nil,
70
77
  :name => "Diana",
71
78
  :rank => 1,
72
79
  :admin => false,
73
- :created_at => Sat Oct 10 12:30:00 UTC 1992
80
+ :created_at => ?
74
81
  },
75
82
  [1] #<User:0x01234567> {
76
83
  :id => nil,
77
84
  :name => "Laura",
78
85
  :rank => 2,
79
86
  :admin => true,
80
- :created_at => Mon May 26 14:15:00 UTC 2003
87
+ :created_at => !
81
88
  }
82
89
  ]
83
90
  EOS
91
+ if RUBY_VERSION.to_f < 1.9
92
+ str.sub!('?', 'Sat Oct 10 12:30:00 UTC 1992')
93
+ str.sub!('!', 'Mon May 26 14:15:00 UTC 2003')
94
+ else
95
+ str.sub!('?', '1992-10-10 12:30:00 UTC')
96
+ str.sub!('!', '2003-05-26 14:15:00 UTC')
97
+ end
98
+
99
+ out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
100
+ end
84
101
  end
85
- end
86
102
 
87
- #------------------------------------------------------------------------------
88
- describe "ActiveRecord class" do
89
- it "should print the class" do
90
- @ap = AwesomePrint.new(:plain => true)
91
- @ap.send(:awesome, User).should == <<-EOS.strip
103
+ #------------------------------------------------------------------------------
104
+ describe "ActiveRecord class" do
105
+ it "should print the class" do
106
+ @ap = AwesomePrint.new(:plain => true)
107
+ @ap.send(:awesome, User).should == <<-EOS.strip
92
108
  class User < ActiveRecord::Base {
93
109
  :id => :integer,
94
110
  :name => :string,
@@ -96,13 +112,12 @@ class User < ActiveRecord::Base {
96
112
  :admin => :boolean,
97
113
  :created_at => :datetime
98
114
  }
99
- EOS
100
-
101
- end
115
+ EOS
116
+ end
102
117
 
103
- it "should print the class for non-direct subclasses of AR::Base" do
104
- @ap = AwesomePrint.new(:plain => true)
105
- @ap.send(:awesome, SubUser).should == <<-EOS.strip
118
+ it "should print the class for non-direct subclasses of AR::Base" do
119
+ @ap = AwesomePrint.new(:plain => true)
120
+ @ap.send(:awesome, SubUser).should == <<-EOS.strip
106
121
  class SubUser < User {
107
122
  :id => :integer,
108
123
  :name => :string,
@@ -110,9 +125,12 @@ class SubUser < User {
110
125
  :admin => :boolean,
111
126
  :created_at => :datetime
112
127
  }
113
- EOS
114
-
128
+ EOS
129
+ end
115
130
  end
116
131
  end
117
132
  end
133
+
134
+ rescue LoadError
135
+ puts "Skipping ActiveRecord specs..."
118
136
  end