ruby-development-toolbox 1.2.0 → 1.3.0
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/integer.rb +7 -1
- data/lib/toolbox/json.rb +41 -0
- data/ruby-development-toolbox.gemspec +6 -4
- data/test/test_toolbox-integer.rb +5 -0
- data/test/test_toolbox_json.rb +26 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42d8f788aa52a983b13a9296566e985e5ede304c
|
4
|
+
data.tar.gz: c546fb5c85dfbbeb996938636c4344e81a24c2a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ed4e05493bb3454c8ed026954d89c7dfe28ed796562aaf550b6e8b51c8578dacd757e03cdab382bbe6bfc1901804cbb91ccc1bf904a69e765363fccbea03dbb
|
7
|
+
data.tar.gz: 80a8d35c52b3ffe980ccd887b5edd707079b9d0d731f8f20dec8e0caf704387bbd362a17fd0293e26a67ba732a5b51a971ecd07b7b5e85c7f58ae99ac2a2a37c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/lib/toolbox/integer.rb
CHANGED
data/lib/toolbox/json.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class Array
|
4
|
+
|
5
|
+
##
|
6
|
+
# Adds in-line ability to pretty-print an Array to JSON using entity.pretty_generate
|
7
|
+
#
|
8
|
+
def to_json_pp
|
9
|
+
JSON.pretty_generate(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
class Hash
|
15
|
+
|
16
|
+
##
|
17
|
+
# Adds in-line ability to pretty-print a Hash to JSON using entity.pretty_generate
|
18
|
+
#
|
19
|
+
def to_json_pp
|
20
|
+
JSON.pretty_generate(self)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Toolbox
|
25
|
+
|
26
|
+
##
|
27
|
+
# Extends the functionality of String to support pretty_printing json.
|
28
|
+
# This is really a natural extension of the basic String type to support
|
29
|
+
# JSON.pretty_generate(string).
|
30
|
+
#
|
31
|
+
# == Usage
|
32
|
+
#
|
33
|
+
# puts %w{ foo bar hello world }.to_json_pp
|
34
|
+
# puts [{:hello => 'world',:find => 'waldo'}].to_json_pp
|
35
|
+
# puts {:foo => 'bar', :hello => 'world'}.to_json_pp
|
36
|
+
# puts {:foo => 'bar', :hello => ['world']}.to_json_pp
|
37
|
+
#
|
38
|
+
module Json
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -2,16 +2,16 @@
|
|
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.
|
5
|
+
# stub: ruby-development-toolbox 1.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ruby-development-toolbox"
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.3.0"
|
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"]
|
13
13
|
s.authors = ["Peter Salas"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-06-21"
|
15
15
|
s.description = "A collection of useful utilities and libraries for Ruby development (not Rails)"
|
16
16
|
s.email = "psalas+github@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -33,10 +33,12 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/toolbox/gem_specification.rb",
|
34
34
|
"lib/toolbox/hash_diff.rb",
|
35
35
|
"lib/toolbox/integer.rb",
|
36
|
+
"lib/toolbox/json.rb",
|
36
37
|
"lib/toolbox/uuid.rb",
|
37
38
|
"ruby-development-toolbox.gemspec",
|
38
39
|
"test/helper.rb",
|
39
|
-
"test/test_toolbox-integer.rb"
|
40
|
+
"test/test_toolbox-integer.rb",
|
41
|
+
"test/test_toolbox_json.rb"
|
40
42
|
]
|
41
43
|
s.homepage = "http://github.com/gradeawarrior/ruby-development-toolbox"
|
42
44
|
s.licenses = ["MIT"]
|
@@ -15,6 +15,10 @@ class TestToolboxInteger < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
should 'An actual Integer.to_i should return true' do
|
19
|
+
assert_equal true, 1.is_i?
|
20
|
+
end
|
21
|
+
|
18
22
|
should 'String is a double value' do
|
19
23
|
['1.0', '-1.0', '3.1415'].each do |double|
|
20
24
|
assert_equal false, double.is_i?
|
@@ -26,4 +30,5 @@ class TestToolboxInteger < Test::Unit::TestCase
|
|
26
30
|
assert_equal false, string.is_i?
|
27
31
|
end
|
28
32
|
end
|
33
|
+
|
29
34
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'toolbox/json'
|
3
|
+
|
4
|
+
class TestToolboxJson < Test::Unit::TestCase
|
5
|
+
|
6
|
+
should 'be able to pretty-print an Array' do
|
7
|
+
assert_equal %Q|[\n\n]|, [].to_json_pp
|
8
|
+
assert_equal %Q|[\n "foo",\n "bar"\n]|, %w{ foo bar }.to_json_pp
|
9
|
+
end
|
10
|
+
|
11
|
+
should "be able to pretty-print an Array of Hash's" do
|
12
|
+
assert_equal %Q|[\n {\n }\n]|, [{}].to_json_pp
|
13
|
+
assert_equal %Q|[\n {\n "foo": "bar"\n }\n]|, [{:foo => 'bar'}].to_json_pp
|
14
|
+
end
|
15
|
+
|
16
|
+
should 'be able to pretty-print a Hash' do
|
17
|
+
assert_equal %Q|{\n}|, {}.to_json_pp
|
18
|
+
assert_equal %Q|{\n "foo": "bar",\n "hello": "world"\n}|, {:foo => 'bar', :hello => 'world'}.to_json_pp
|
19
|
+
end
|
20
|
+
|
21
|
+
should "be able to pretty-print a Hash containing Array's" do
|
22
|
+
assert_equal %Q|{\n "array": [\n\n ]\n}|, {:array => []}.to_json_pp
|
23
|
+
assert_equal %Q|{\n "array": [\n "hello"\n ]\n}|, {:array => ['hello']}.to_json_pp
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-development-toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Salas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|
@@ -117,10 +117,12 @@ files:
|
|
117
117
|
- lib/toolbox/gem_specification.rb
|
118
118
|
- lib/toolbox/hash_diff.rb
|
119
119
|
- lib/toolbox/integer.rb
|
120
|
+
- lib/toolbox/json.rb
|
120
121
|
- lib/toolbox/uuid.rb
|
121
122
|
- ruby-development-toolbox.gemspec
|
122
123
|
- test/helper.rb
|
123
124
|
- test/test_toolbox-integer.rb
|
125
|
+
- test/test_toolbox_json.rb
|
124
126
|
homepage: http://github.com/gradeawarrior/ruby-development-toolbox
|
125
127
|
licenses:
|
126
128
|
- MIT
|