value_inspect 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 284654571f19001c91bcf97cf58a090bc208720d
4
- data.tar.gz: aaaec6115d0cd38dba9e0598d14c1d8a99da6c92
3
+ metadata.gz: b0cfefeb965681eb6e53401f2aeb4bc468114fc6
4
+ data.tar.gz: 238b4725dc2a39d80bc20198adc319a4660f4ee8
5
5
  SHA512:
6
- metadata.gz: 0e78180e7238179a2d2d9554a56ed1517a0a4d57433b8b3a96844526f835d3c784e59959e220c76f1a4d148067046713358513f7209155104dd92d2fdeb94dde
7
- data.tar.gz: 8cf7956c8d2351e63a723d279d495d74ca627062ff37a39241ac6f3dc77769ed13b3fa9157341aca7c9802401afacec48d3b891fa53793d134d3d06f829ec25b
6
+ metadata.gz: 18e992b2b418d261ebac7948d123589ec7365844c2874ec0b522950c84f3777ff3c8648403e50c5c8fdc385a933f030f4d5b1d89d986d44ab887cc7ae88b143d
7
+ data.tar.gz: c492ac6a84455d8ebd5f78cf9e343a7146c34d48f19f434b17648bc2b87acd5161004c7070426cb6b40245f29a6f0e1b57d6c5c53d43c83977e5fc6f3fe3803f
data/README.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # ValueInspect
2
2
 
3
- Provides implementation of #inspect that is more readable and can be used in irb.
3
+ Provides implementation of #inspect that is more readable and can be used in irb. Especially useful for BigDecimal#inspect.
4
4
 
5
5
  ## Usage
6
6
 
7
+ **without** this gem:
8
+
7
9
  ```ruby
8
10
  Person = Struct.new :name, :age
9
11
 
10
- # Before
11
- # ======
12
-
13
12
  Date.new(1970, 1, 1).inspect
14
13
  # => #<Date: 1970-01-01 ((2440588j,0s,0n),+0s,2299161j)>
15
14
 
@@ -18,13 +17,16 @@ BigDecimal("3.14").inspect
18
17
 
19
18
  Person.new("John Doe", 20).inspect
20
19
  # => #<struct Person name=\"John Doe\", age=20>
20
+ ```
21
21
 
22
- # After
23
- # =====
22
+ **with** this gem:
24
23
 
25
- # remeber to put `require "value_inspect"` *after* e.g. `require "bigdecimal"`
24
+ ```ruby
25
+ # remember to put `require "value_inspect"` *after* e.g. `require "bigdecimal"`
26
26
  require "value_inspect"
27
27
 
28
+ Person = Struct.new :name, :age
29
+
28
30
  Date.new(1970, 1, 1).inspect
29
31
  # => Date.new(1970, 1, 1)
30
32
 
@@ -0,0 +1,7 @@
1
+ class BigDecimal
2
+ alias_method :original_inspect, :inspect
3
+
4
+ def inspect
5
+ "BigDecimal(\"%s\")" % to_s('F')
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ class Date
2
+ alias_method :original_inspect, :inspect
3
+
4
+ def inspect
5
+ "Date.new(%s, %s, %s)" % [year, month, day]
6
+ end
7
+ end
8
+
9
+ class DateTime
10
+ def inspect
11
+ "DateTime.new(%s, %s, %s)" % [year, month, day]
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ class Struct
2
+ alias_method :original_inspect, :inspect
3
+
4
+ def inspect
5
+ "%s.new(%s)" % [self.class.name, values.map(&:inspect).join(", ")]
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class Time
2
+ alias_method :original_inspect, :inspect
3
+
4
+ def inspect
5
+ strftime("Time.new(%Y, %-m, %-d, %-H, %-M, %-S, \"%:z\")")
6
+ end
7
+ end
@@ -0,0 +1,24 @@
1
+ module ValueInspect
2
+ module Values
3
+ module ClassMethods
4
+ def new(*args)
5
+ cls = super
6
+ cls.send(:alias_method, :original_inspect, :inspect)
7
+ cls.prepend InstanceMethods
8
+ cls
9
+ end
10
+ end
11
+
12
+ module InstanceMethods
13
+ def inspect
14
+ "%s.new(%s)" % [self.class.name, values.map(&:inspect).join(", ")]
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ class Value
21
+ class << self
22
+ prepend ValueInspect::Values::ClassMethods
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module ValueInspect
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/value_inspect.rb CHANGED
@@ -1,71 +1,7 @@
1
1
  require "value_inspect/version"
2
2
 
3
- class Struct
4
- alias_method :original_inspect, :inspect
5
-
6
- def inspect
7
- "%s.new(%s)" % [self.class.name, values.map(&:inspect).join(", ")]
8
- end
9
- end
10
-
11
- if defined? BigDecimal
12
- class BigDecimal
13
- alias_method :original_inspect, :inspect
14
-
15
- def inspect
16
- "BigDecimal(\"%s\")" % to_s('F')
17
- end
18
- end
19
- end
20
-
21
- class Time
22
- alias_method :original_inspect, :inspect
23
-
24
- def inspect
25
- strftime("Time.new(%Y, %-d, %-m, %-H, %-M, %-S, \"%:z\")")
26
- end
27
- end
28
-
29
- if defined? Date
30
- class Date
31
- alias_method :original_inspect, :inspect
32
-
33
- def inspect
34
- "Date.new(%s, %s, %s)" % [year, month, day]
35
- end
36
- end
37
-
38
- class DateTime
39
- def inspect
40
- "DateTime.new(%s, %s, %s)" % [year, month, day]
41
- end
42
- end
43
- end
44
-
45
- if defined? Value
46
- module ValueInspect
47
- module Values
48
- module ClassMethods
49
- def new(*args)
50
- cls = super
51
- cls.send(:alias_method, :original_inspect, :inspect)
52
- cls.prepend InstanceMethods
53
- cls
54
- end
55
- end
56
-
57
- module InstanceMethods
58
- def inspect
59
- "%s.new(%s)" % [self.class.name, values.map(&:inspect).join(", ")]
60
- end
61
- end
62
- end
63
- end
64
-
65
- class Value
66
- class << self
67
- prepend ValueInspect::Values::ClassMethods
68
- end
69
- end
70
- end
71
-
3
+ require "value_inspect/struct"
4
+ require "value_inspect/bigdecimal" if defined? BigDecimal
5
+ require "value_inspect/time"
6
+ require "value_inspect/date" if defined? Date
7
+ require "value_inspect/values" if defined? Value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: value_inspect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojtek Mach
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-23 00:00:00.000000000 Z
11
+ date: 2016-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,11 @@ files:
81
81
  - README.md
82
82
  - Rakefile
83
83
  - lib/value_inspect.rb
84
+ - lib/value_inspect/bigdecimal.rb
85
+ - lib/value_inspect/date.rb
86
+ - lib/value_inspect/struct.rb
87
+ - lib/value_inspect/time.rb
88
+ - lib/value_inspect/values.rb
84
89
  - lib/value_inspect/version.rb
85
90
  - value_inspect.gemspec
86
91
  homepage: https://github.com/wojtekmach/value_inspect