ruby-development-toolbox 1.3.1 → 1.3.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 +4 -4
- data/VERSION +1 -1
- data/lib/toolbox/boolean.rb +57 -45
- data/lib/toolbox/gem_specification.rb +15 -11
- data/lib/toolbox/hash_diff.rb +33 -29
- data/ruby-development-toolbox.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 910138d99d7862d7ce2725e50334afc5bbc51565
|
4
|
+
data.tar.gz: 6fe90a88dd79fb5e49ec65b9ffca2836eb3c811d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2a6894e4d066e35a9fb3963e2b8b03d9f00c7ed79da652f4e3090760d9165776dd39623263dd46619e1588bd823899a04c50214fd48aebdf1c6f1a8a53c2b32
|
7
|
+
data.tar.gz: f91363877803840ded559ef939f2d88298c1ce65e81ceaee7152796ed7c7206e64342f9ab13c2e2e7a0960297bf065410732e8cf0783a6f0091502bafb04008d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.2
|
data/lib/toolbox/boolean.rb
CHANGED
@@ -1,70 +1,82 @@
|
|
1
|
-
##
|
2
|
-
# Extending String function to be able to convert a String 'true' or 'false' to a boolean true/false.
|
3
|
-
# See the Boolean module for usage
|
4
|
-
#
|
5
1
|
class String
|
2
|
+
|
3
|
+
##
|
4
|
+
# Extending String function to be able to convert a String 'true' or 'false' to a boolean true/false.
|
5
|
+
# See the Boolean module for usage
|
6
|
+
#
|
6
7
|
def to_bool
|
7
8
|
(self =~ /^true$/i) == 0
|
8
9
|
end
|
10
|
+
|
9
11
|
end
|
10
12
|
|
11
|
-
##
|
12
|
-
# Implementing to_bool operation that returns self.
|
13
|
-
# See the Boolean module for usage
|
14
|
-
#
|
15
13
|
class TrueClass
|
14
|
+
|
15
|
+
##
|
16
|
+
# Implementing to_bool operation that returns self.
|
17
|
+
# See the Boolean module for usage
|
18
|
+
#
|
16
19
|
def to_bool
|
17
20
|
self
|
18
21
|
end
|
22
|
+
|
19
23
|
end
|
20
24
|
|
21
|
-
##
|
22
|
-
# Implementing to_bool operation that returns self.
|
23
|
-
# See the Boolean module for usage
|
24
|
-
#
|
25
25
|
class FalseClass
|
26
|
+
|
27
|
+
##
|
28
|
+
# Implementing to_bool operation that returns self.
|
29
|
+
# See the Boolean module for usage
|
30
|
+
#
|
26
31
|
def to_bool
|
27
32
|
self
|
28
33
|
end
|
34
|
+
|
29
35
|
end
|
30
36
|
|
31
|
-
##
|
32
|
-
# Implementing to_bool operation that returns self.
|
33
|
-
# See the Boolean module for usage
|
34
|
-
#
|
35
37
|
class NilClass
|
38
|
+
|
39
|
+
##
|
40
|
+
# Implementing to_bool operation that returns self.
|
41
|
+
# See the Boolean module for usage
|
42
|
+
#
|
36
43
|
def to_bool
|
37
44
|
self
|
38
45
|
end
|
46
|
+
|
39
47
|
end
|
40
48
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
# '
|
58
|
-
# '
|
59
|
-
# '
|
60
|
-
# '
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
|
49
|
+
module Toolbox
|
50
|
+
|
51
|
+
##
|
52
|
+
# The main application of the Boolean module is to
|
53
|
+
# support reading boolean values from a String (e.g.
|
54
|
+
# while reading a configuration value) and having the
|
55
|
+
# ability to convert it back to a boolean true/false
|
56
|
+
# for easier evaluation in your Ruby code
|
57
|
+
#
|
58
|
+
# == Usage
|
59
|
+
#
|
60
|
+
# Working with Boolean module can be very simple, for example:
|
61
|
+
#
|
62
|
+
# require 'toolbox/boolean'
|
63
|
+
#
|
64
|
+
# list_of_values = [
|
65
|
+
# 'true',
|
66
|
+
# 'True',
|
67
|
+
# 'TRUE',
|
68
|
+
# 'false',
|
69
|
+
# 'False',
|
70
|
+
# 'FALSE',
|
71
|
+
# nil,
|
72
|
+
# ]
|
73
|
+
#
|
74
|
+
# list_of_values.each do |string|
|
75
|
+
# puts "This evaluated to true" if string.to_bool
|
76
|
+
# puts "This evaluated to false or was nil" unless string.to_bool
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
module Boolean
|
80
|
+
end
|
81
|
+
|
70
82
|
end
|
@@ -19,15 +19,19 @@ module Gem
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
|
22
|
+
module Toolbox
|
23
|
+
|
24
|
+
##
|
25
|
+
# Extends the functionality of a Gem::Specification to be able to retrieve the latest version of gems
|
26
|
+
# currently on your system.
|
27
|
+
#
|
28
|
+
# == Usage
|
29
|
+
#
|
30
|
+
# Gem::Specification.latest_versions.each do |spec|
|
31
|
+
# puts "#{spec.name} (#{spec.version})"
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
module GemSpecification
|
35
|
+
end
|
36
|
+
|
33
37
|
end
|
data/lib/toolbox/hash_diff.rb
CHANGED
@@ -121,33 +121,37 @@ class Hash
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
# :
|
139
|
-
# :
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
# :
|
146
|
-
# :
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
|
124
|
+
module Toolbox
|
125
|
+
|
126
|
+
##
|
127
|
+
# Extends the functionality of a Hash to be able to perform (i) diff and (ii) similarity operations
|
128
|
+
# For implementation details, see the Hash class for the extended functions
|
129
|
+
#
|
130
|
+
# == Usage
|
131
|
+
#
|
132
|
+
# Working with HashDiff module can be very simple, for example:
|
133
|
+
#
|
134
|
+
# require 'toolbox/hash_diff'
|
135
|
+
# require 'yaml'
|
136
|
+
#
|
137
|
+
# hash1 = {
|
138
|
+
# :foo => 'bar',
|
139
|
+
# :bar => 'hello',
|
140
|
+
# :hello => 'world',
|
141
|
+
# :this => { :exists => 'yay!' }
|
142
|
+
# }
|
143
|
+
#
|
144
|
+
# hash2 = {
|
145
|
+
# :foo => 'bar',
|
146
|
+
# :hello => 'Hi',
|
147
|
+
# :this => { :exists => 'yay!' },
|
148
|
+
# :hey => { :this => "Doesn't exist", :but => "oh well" }
|
149
|
+
# }
|
150
|
+
#
|
151
|
+
# puts hash1.diff(hash2).to_yaml
|
152
|
+
# puts hash1.similarity(hash2).to_yaml
|
153
|
+
#
|
154
|
+
module HashDiff
|
155
|
+
end
|
156
|
+
|
153
157
|
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ruby-development-toolbox 1.3.
|
5
|
+
# stub: ruby-development-toolbox 1.3.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ruby-development-toolbox"
|
9
|
-
s.version = "1.3.
|
9
|
+
s.version = "1.3.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|