awesome_print 0.3.0 → 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,63 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ begin
4
+ require "mongo_mapper"
5
+ require "ap/mixin/mongo_mapper"
6
+
7
+ describe "AwesomePrint/MongoMapper" do
8
+ before :all do
9
+ class MongoUser
10
+ include MongoMapper::Document
11
+
12
+ key :first_name, String
13
+ key :last_name, String
14
+ end
15
+ end
16
+
17
+ before :each do
18
+ @ap = AwesomePrint.new(:plain => true)
19
+ end
20
+
21
+ it "should print for a class instance" do
22
+ user = MongoUser.new(:first_name => "Al", :last_name => "Capone")
23
+ out = @ap.send(:awesome, user)
24
+ str = <<-EOS.strip
25
+ #<MongoUser:0x01234567> {
26
+ "_id" => BSON::ObjectId('4d9183739a546f6806000001'),
27
+ "first_name" => "Al",
28
+ "last_name" => "Capone"
29
+ }
30
+ EOS
31
+ out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
32
+ out.gsub!(/0x([a-f\d]+)/, "0x01234567")
33
+ out.should == str
34
+ end
35
+
36
+ it "should print for a class" do
37
+ @ap.send(:awesome, MongoUser).should == <<-EOS.strip
38
+ class MongoUser < Object {
39
+ "_id" => :object_id,
40
+ "first_name" => :string,
41
+ "last_name" => :string
42
+ }
43
+ EOS
44
+ end
45
+
46
+ it "should print for a class when type is undefined" do
47
+ class Chamelion
48
+ include MongoMapper::Document
49
+ key :last_attribute
50
+ end
51
+
52
+ @ap.send(:awesome, Chamelion).should == <<-EOS.strip
53
+ class Chamelion < Object {
54
+ "_id" => :object_id,
55
+ "last_attribute" => :undefined
56
+ }
57
+ EOS
58
+ end
59
+ end
60
+
61
+ rescue LoadError
62
+ puts "Skipping MongoMapper specs..."
63
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,28 +1,51 @@
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
  #
7
- # Running specs with Ruby 1.8.7 and RSpec 1.3+:
8
- # $ rake spec # Entire spec suite.
9
- # $ ruby -rubygems spec/logger_spec.rb # Individual spec file.
10
- #
11
- # Running specs with Ruby 1.9.2 and RSpec 2.0+:
12
- # $ rake spec # Entire spec suite.
13
- # $ rspec spec/logger_spec.rb # Individual spec file.
7
+ # Running specs from the command line:
8
+ # $ rake spec # Entire spec suite.
9
+ # $ rspec spec/logger_spec.rb # Individual spec file.
14
10
  #
15
11
  $LOAD_PATH.unshift(File.dirname(__FILE__))
16
12
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
- require 'ap'
18
-
19
- if RUBY_VERSION.to_f < 1.9
20
- require 'spec'
21
- require 'spec/autorun'
22
- require 'rubygems'
23
- end
13
+ require 'awesome_print'
24
14
 
25
15
  def stub_dotfile!
26
16
  dotfile = File.join(ENV["HOME"], ".aprc")
27
17
  File.should_receive(:readable?).at_least(:once).with(dotfile).and_return(false)
28
18
  end
19
+
20
+ # The following is needed for the Infinity Test. It runs tests as subprocesses,
21
+ # which sets STDOUT.tty? to false and would otherwise prematurely disallow colors.
22
+ AwesomePrint.force_colors!
23
+
24
+ # Ruby 1.8.6 only: define missing String methods that are needed for the specs to pass.
25
+ if RUBY_VERSION < '1.8.7'
26
+ class String
27
+ def shellescape # Taken from Ruby 1.9.2 standard library, see lib/shellwords.rb.
28
+ return "''" if self.empty?
29
+ str = self.dup
30
+ str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
31
+ str.gsub!(/\n/, "'\n'")
32
+ str
33
+ end
34
+
35
+ def start_with?(*prefixes)
36
+ prefixes.each do |prefix|
37
+ prefix = prefix.to_s
38
+ return true if prefix == self[0, prefix.size]
39
+ end
40
+ false
41
+ end
42
+
43
+ def end_with?(*suffixes)
44
+ suffixes.each do |suffix|
45
+ suffix = suffix.to_s
46
+ return true if suffix == self[-suffix.size, suffix.size]
47
+ end
48
+ false
49
+ end
50
+ end
51
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_print
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 15
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 3
8
+ - 4
8
9
  - 0
9
- version: 0.3.0
10
+ version: 0.4.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Michael Dvorkin
@@ -14,21 +15,23 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-11-09 00:00:00 -08:00
18
+ date: 2011-05-13 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rspec
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 27
27
30
  segments:
28
- - 1
29
- - 3
31
+ - 2
32
+ - 5
30
33
  - 0
31
- version: 1.3.0
34
+ version: 2.5.0
32
35
  type: :development
33
36
  version_requirements: *id001
34
37
  description: "Great Ruby dubugging companion: pretty print Ruby objects to visualize their structure. Supports Rails ActiveRecord objects via included mixin."
@@ -53,18 +56,22 @@ files:
53
56
  - lib/ap/core_ext/class.rb
54
57
  - lib/ap/core_ext/kernel.rb
55
58
  - lib/ap/core_ext/logger.rb
59
+ - lib/ap/core_ext/method.rb
56
60
  - lib/ap/core_ext/object.rb
57
61
  - lib/ap/core_ext/string.rb
58
62
  - lib/ap/mixin/action_view.rb
59
63
  - lib/ap/mixin/active_record.rb
60
64
  - lib/ap/mixin/active_support.rb
65
+ - lib/ap/mixin/mongo_mapper.rb
61
66
  - lib/awesome_print.rb
62
67
  - rails/init.rb
63
68
  - spec/action_view_spec.rb
64
69
  - spec/active_record_spec.rb
65
70
  - spec/awesome_print_spec.rb
71
+ - spec/colorization_spec.rb
66
72
  - spec/logger_spec.rb
67
73
  - spec/methods_spec.rb
74
+ - spec/mongo_mapper_spec.rb
68
75
  - spec/spec_helper.rb
69
76
  - spec/string_spec.rb
70
77
  has_rdoc: true
@@ -72,36 +79,34 @@ homepage: http://github.com/michaeldv/awesome_print
72
79
  licenses: []
73
80
 
74
81
  post_install_message:
75
- rdoc_options:
76
- - --charset=UTF-8
82
+ rdoc_options: []
83
+
77
84
  require_paths:
78
85
  - lib
79
86
  required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
80
88
  requirements:
81
89
  - - ">="
82
90
  - !ruby/object:Gem::Version
91
+ hash: 3
83
92
  segments:
84
93
  - 0
85
94
  version: "0"
86
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
87
97
  requirements:
88
98
  - - ">="
89
99
  - !ruby/object:Gem::Version
100
+ hash: 3
90
101
  segments:
91
102
  - 0
92
103
  version: "0"
93
104
  requirements: []
94
105
 
95
106
  rubyforge_project: awesome_print
96
- rubygems_version: 1.3.6
107
+ rubygems_version: 1.3.7
97
108
  signing_key:
98
109
  specification_version: 3
99
110
  summary: Pretty print Ruby objects with proper indentation and colors.
100
- test_files:
101
- - spec/action_view_spec.rb
102
- - spec/active_record_spec.rb
103
- - spec/awesome_print_spec.rb
104
- - spec/logger_spec.rb
105
- - spec/methods_spec.rb
106
- - spec/spec_helper.rb
107
- - spec/string_spec.rb
111
+ test_files: []
112
+