color_me_rad 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 873bd6302e7db5866f957328800779b60d057a84d59154c1b68b43e8c0892940
4
- data.tar.gz: d2fb6fea049a8c7c1d76d5a12a3a018beeb56ced20e12228d9a3cf40653966e2
3
+ metadata.gz: f30775f5a4680cd649e7fc3c2bc1504b4a88dd38432e52c96e50e4e849522959
4
+ data.tar.gz: c09e70fa9a859ca58848e8548bfb0d11524f6b97534cc8061867477614363ad0
5
5
  SHA512:
6
- metadata.gz: a0bb9304e57ee33e4273a4880d9cfc30c0d78f97368f5d018a4877cb40de89c5a6bb67ab5391146a561152ddc065488abbf6b211781f333babac71a7b78c064d
7
- data.tar.gz: 3ce39b8a330237f4abce3aea63d333cc0dbb759d282d8692b792f420ef25d9c8983034a44b0a17b5d26490bcb9776f80e32a6242a2524371d10499b56fd95b47
6
+ metadata.gz: 660d1550339e087225f83eca19ab68c4ad2ac73b7b91ecdb2452dd4168e79849c5a19b6027382d5889f791cfa718e96a2164bd6889252f39daa55aecf6eb785a
7
+ data.tar.gz: 8c71988f29a9b4c8296781aa1330e797f5d0b525c4b9d241e015ba35e9058462d23d6ba450e07f1931200d20cc548ae57c673be741ab452a97100803c7dc7436
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- color_me_rad (0.0.2)
4
+ color_me_rad (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1 @@
1
+ ca2662805789ab17b6deee4f6af9b487
@@ -0,0 +1 @@
1
+ eb70724964427ecd99e9ef42be7e0de5f1334b922ce99613e8400905c585f513
@@ -0,0 +1 @@
1
+ 46b2754dc744c0ef68acba3f8ab6efffc7796f117e2bb0405eda1e3ae32587c2c2bc1be53b358836341f49eb5d387df58835ba9c155744950a477e1f7018f188
data/color_me_rad.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'color_me_rad'
3
- spec.version = '0.0.2'
3
+ spec.version = '0.0.3'
4
4
  spec.authors = ['Travis Herrick']
5
5
  spec.email = ['tthetoad@gmail.com']
6
6
 
@@ -35,7 +35,9 @@ module ColorMeRad
35
35
  end
36
36
 
37
37
  def ruby_ivars(data)
38
- as_object(data) do
38
+ method = data.is_a?(Module) ? :as_module : :as_object
39
+
40
+ send(method, data) do
39
41
  map_ivars data
40
42
  end
41
43
  end
@@ -47,19 +49,37 @@ module ColorMeRad
47
49
  end
48
50
 
49
51
  def as_object(data, &block)
50
- string = data.to_s
51
- strings = string.match(/(#<)(\S+)(:)(\w+)(>)/)
52
+ # this is the method ruby uses to 'encode' the object id shown by #to_s
53
+ # shift the bit (multiply by 2) and use the hex representation
54
+ id = (data.object_id << 1).to_s(16)
52
55
 
53
56
  '%s%s%s%s %s%s' % [
54
- key(strings[1], :syntax),
55
- key(strings[2], :constant),
56
- key(strings[3], :syntax),
57
- key(strings[4], 'Integer'),
57
+ syntax_constructs[:leader],
58
+ key(data.class.to_s, :constant),
59
+ syntax_constructs[:colon],
60
+ key("0x#{id}", 'Integer'),
61
+ yield,
62
+ syntax_constructs[:closer],
63
+ ]
64
+ end
65
+
66
+ def as_module(data, &block)
67
+ '%s%s %s%s' % [
68
+ syntax_constructs[:leader],
69
+ key(data.to_s, :constant),
58
70
  yield,
59
- key(strings[5], :syntax),
71
+ syntax_constructs[:closer],
60
72
  ]
61
73
  end
62
74
 
75
+ def syntax_constructs
76
+ @syntax_constructs ||= {
77
+ :leader => key('#<', :syntax),
78
+ :closer => key('>', :syntax),
79
+ :colon => key(':', :syntax),
80
+ }
81
+ end
82
+
63
83
  def colorize_data(data)
64
84
  color ||= color_for_data_class(data)
65
85
  data = data.inspect if [String].include?(data.class)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_me_rad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Herrick
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-24 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -96,6 +96,9 @@ files:
96
96
  - checksum/color_me_rad-0.0.1.gem.md5
97
97
  - checksum/color_me_rad-0.0.1.gem.sha256
98
98
  - checksum/color_me_rad-0.0.1.gem.sha512
99
+ - checksum/color_me_rad-0.0.2.gem.md5
100
+ - checksum/color_me_rad-0.0.2.gem.sha256
101
+ - checksum/color_me_rad-0.0.2.gem.sha512
99
102
  - color_me_rad.gemspec
100
103
  - lib/color_me_rad.rb
101
104
  - lib/color_me_rad/color_helper.rb