awesome_print 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/CHANGELOG +8 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +26 -0
- data/README.md +52 -14
- data/Rakefile +2 -46
- data/lib/ap.rb +3 -17
- data/lib/awesome_print.rb +16 -12
- data/lib/{ap → awesome_print}/core_ext/array.rb +0 -0
- data/lib/{ap → awesome_print}/core_ext/class.rb +0 -0
- data/lib/{ap → awesome_print}/core_ext/kernel.rb +2 -2
- data/lib/awesome_print/core_ext/logger.rb +20 -0
- data/lib/{ap → awesome_print}/core_ext/method.rb +0 -0
- data/lib/{ap → awesome_print}/core_ext/object.rb +0 -0
- data/lib/{ap → awesome_print}/core_ext/string.rb +8 -5
- data/lib/awesome_print/ext/action_view.rb +18 -0
- data/lib/awesome_print/ext/active_record.rb +40 -0
- data/lib/awesome_print/ext/active_support.rb +40 -0
- data/lib/awesome_print/ext/mongo_mapper.rb +38 -0
- data/lib/awesome_print/ext/mongoid.rb +39 -0
- data/lib/awesome_print/ext/nokogiri.rb +45 -0
- data/lib/awesome_print/formatter.rb +350 -0
- data/lib/awesome_print/inspector.rb +140 -0
- data/{rails/init.rb → lib/awesome_print/version.rb} +5 -4
- data/spec/colors_spec.rb +106 -0
- data/spec/{awesome_print_spec.rb → formats_spec.rb} +187 -37
- data/spec/methods_spec.rb +20 -0
- data/spec/objects_spec.rb +79 -0
- data/spec/spec_helper.rb +1 -1
- metadata +49 -53
- data/VERSION +0 -1
- data/init.rb +0 -1
- data/lib/ap/awesome_print.rb +0 -352
- data/lib/ap/core_ext/logger.rb +0 -18
- data/lib/ap/mixin/action_view.rb +0 -17
- data/lib/ap/mixin/active_record.rb +0 -54
- data/lib/ap/mixin/active_support.rb +0 -46
- data/lib/ap/mixin/mongo_mapper.rb +0 -54
- data/spec/action_view_spec.rb +0 -25
- data/spec/active_record_spec.rb +0 -136
- data/spec/colorization_spec.rb +0 -84
- data/spec/logger_spec.rb +0 -43
- data/spec/mongo_mapper_spec.rb +0 -63
- data/spec/string_spec.rb +0 -20
data/spec/mongo_mapper_spec.rb
DELETED
@@ -1,63 +0,0 @@
|
|
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/string_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "String extensions" do
|
4
|
-
[ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i|
|
5
|
-
it "should have #{color} color" do
|
6
|
-
color.to_s.send(color).should == "\033[1;#{30+i}m#{color}\033[0m"
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should have #{color}ish color" do
|
10
|
-
color.to_s.send(:"#{color}ish").should == "\033[0;#{30+i}m#{color}\033[0m"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should have black and pale colors" do
|
15
|
-
"black".send(:black).should == "black".send(:grayish)
|
16
|
-
"pale".send(:pale).should == "pale".send(:whiteish)
|
17
|
-
"pale".send(:pale).should == "\e[0;37mpale\e[0m"
|
18
|
-
"whiteish".send(:whiteish).should == "\e[0;37mwhiteish\e[0m"
|
19
|
-
end
|
20
|
-
end
|