prettys 0.0.1 → 0.0.2
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.
- checksums.yaml +7 -0
- data/lib/converter.rb +26 -0
- data/lib/prettys.rb +21 -3
- metadata +9 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5644d68aec8dcb4ef481fa2a2139f77485532258
|
4
|
+
data.tar.gz: 051970260a1f4ee9650e8ea63df6e16366aa3954
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 996274699b7f321c5badc5e345174a45bfcbfbe14d86c36e1be008959f18f74dce31da3f17e876208b2e759d256f98b7748aa0505df907d8a40b18d67e41d566
|
7
|
+
data.tar.gz: 6092d2f928608e664a43eeca79b15e351900f2b996115d9e516265f7f8738e02b04f4a7f46aa1237aad796678ccaf5a6819b94340c76eb7eb315073a4f4c95ff
|
data/lib/converter.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Prettys
|
2
|
+
class Converter
|
3
|
+
attr_reader :format
|
4
|
+
|
5
|
+
SUPPORTED_FORMATS = {
|
6
|
+
raw: :inspect,
|
7
|
+
json: :to_json,
|
8
|
+
yaml: :to_yaml
|
9
|
+
}
|
10
|
+
|
11
|
+
private_constant :SUPPORTED_FORMATS
|
12
|
+
|
13
|
+
def initialize(format)
|
14
|
+
self.format = format
|
15
|
+
end
|
16
|
+
|
17
|
+
def format=(format)
|
18
|
+
raise ArgumentError, "Unsupported format." unless SUPPORTED_FORMATS.include?(format)
|
19
|
+
@format = format
|
20
|
+
end
|
21
|
+
|
22
|
+
def convert(object)
|
23
|
+
object.send(SUPPORTED_FORMATS[format])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/prettys.rb
CHANGED
@@ -1,10 +1,28 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'json'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Prettys
|
5
|
+
require 'converter'
|
6
|
+
|
7
|
+
@converter = Converter.new(:json)
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def format
|
11
|
+
@converter.format
|
12
|
+
end
|
13
|
+
|
14
|
+
def format=(format)
|
15
|
+
@converter.format = format
|
16
|
+
end
|
17
|
+
|
18
|
+
def prettys(object)
|
19
|
+
@converter.convert(object)
|
20
|
+
end
|
3
21
|
end
|
4
22
|
end
|
5
23
|
|
6
24
|
class Object
|
7
25
|
def prettys
|
8
|
-
Prettys.prettys
|
26
|
+
Prettys.prettys(self)
|
9
27
|
end
|
10
28
|
end
|
metadata
CHANGED
@@ -1,46 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prettys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Maciej Ciemborowicz
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-20 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
13
|
+
description: Colorful inspector for Ruby objects.
|
15
14
|
email: pub@ciemborowicz.pl
|
16
15
|
executables: []
|
17
16
|
extensions: []
|
18
17
|
extra_rdoc_files: []
|
19
18
|
files:
|
20
19
|
- lib/prettys.rb
|
20
|
+
- lib/converter.rb
|
21
21
|
homepage: http://rubygems.org/gems/prettys
|
22
22
|
licenses:
|
23
23
|
- MIT
|
24
|
+
metadata: {}
|
24
25
|
post_install_message:
|
25
26
|
rdoc_options: []
|
26
27
|
require_paths:
|
27
28
|
- lib
|
28
29
|
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
-
none: false
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
35
|
requirements:
|
37
|
-
- -
|
36
|
+
- - '>='
|
38
37
|
- !ruby/object:Gem::Version
|
39
38
|
version: '0'
|
40
39
|
requirements: []
|
41
40
|
rubyforge_project:
|
42
|
-
rubygems_version:
|
41
|
+
rubygems_version: 2.0.3
|
43
42
|
signing_key:
|
44
|
-
specification_version:
|
43
|
+
specification_version: 4
|
45
44
|
summary: Prettys
|
46
45
|
test_files: []
|