pump 0.7.0 → 0.8.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/.ruby-version +1 -1
- data/CHANGES.md +7 -1
- data/lib/pump/encoder.rb +4 -4
- data/lib/pump/json.rb +8 -0
- data/lib/pump/version.rb +1 -1
- data/spec/pump/json_spec.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d0dd2f7198902dcdd6c0e4236c9166b64258dc6
|
4
|
+
data.tar.gz: 6b170630416c2d34796d2b22a9c6ca62042fd535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d52c00ddd02e982c4de0b96d33aea84743a68684daf5b8d25be506c32fe980de16c8c2d8e7079f3a13fb83e200d5e176f139bd0153a058275720ddbaff4860
|
7
|
+
data.tar.gz: 24fd633bb52f054c5424e0f7e8fd5a4135e4e966f5e4eaec520022f0974e094a2fd6d3613955fe41c6e17f9209528eb0b42d16fa13f6f1dec45967380be77bbf
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.3
|
data/CHANGES.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
### dev
|
2
2
|
|
3
|
-
[full changelog](http://github.com/yolk/pump/compare/v0.
|
3
|
+
[full changelog](http://github.com/yolk/pump/compare/v0.8.0...master)
|
4
|
+
|
5
|
+
### 0.8.0 / 2012-12-18
|
6
|
+
|
7
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.7.0...v0.8.0)
|
8
|
+
|
9
|
+
* Added Pump::JSON#to_structs
|
4
10
|
|
5
11
|
### 0.7.0 / 2017-06-26
|
6
12
|
|
data/lib/pump/encoder.rb
CHANGED
@@ -45,11 +45,11 @@ module Pump
|
|
45
45
|
compile
|
46
46
|
end
|
47
47
|
|
48
|
-
# Encode a object or an array of objects to an
|
48
|
+
# Encode a object or an array of objects to an formatted string.
|
49
49
|
#
|
50
50
|
# @param [Object, Array<Object>] object object or an array of objects to
|
51
|
-
# encode to XML. The only requirement: The given objects must respond
|
52
|
-
# to all methods configured during initalization of the Pump::Xml instance.
|
51
|
+
# encode to XML or JSON. The only requirement: The given objects must respond
|
52
|
+
# to all methods configured during initalization of the Pump::Xml or Pump::JSON instance.
|
53
53
|
#
|
54
54
|
# @return [String]
|
55
55
|
def encode(object, options={})
|
@@ -125,4 +125,4 @@ module Pump
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
128
|
-
end
|
128
|
+
end
|
data/lib/pump/json.rb
CHANGED
@@ -20,6 +20,14 @@ module Pump
|
|
20
20
|
partial_main = build_main(:partial => true)
|
21
21
|
|
22
22
|
<<-EOV
|
23
|
+
def to_structs(object, options={})
|
24
|
+
#{main}
|
25
|
+
unless options[:exclude_root_in_json]
|
26
|
+
json = { :'#{format_name(root_name)}' => json }
|
27
|
+
end
|
28
|
+
json
|
29
|
+
end
|
30
|
+
|
23
31
|
def encode_single(object, options)
|
24
32
|
#{main}
|
25
33
|
unless options[:exclude_root_in_json]
|
data/lib/pump/version.rb
CHANGED
data/spec/pump/json_spec.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Pump::Json do
|
4
|
+
describe "#to_structs" do
|
5
|
+
let(:person) { Struct.new(:name, :age, :last_name).new('Benny', 9, 'Hellman') }
|
6
|
+
let(:json) { Pump::Json.new('person', [{:name => :name}]) }
|
7
|
+
|
8
|
+
it "returns json as structure" do
|
9
|
+
expect(json.to_structs(person)).to eql({:person=>{:name=>"Benny"}})
|
10
|
+
expect(json.to_structs(person, exclude_root_in_json: true)).to eql({:name=>"Benny"})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
describe "#encode" do
|
5
15
|
let(:person) { Struct.new(:name, :age, :last_name).new('Benny', 9, 'Hellman') }
|
6
16
|
let(:json) { Pump::Json.new('person', [{:name => :name}]) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Munz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.6.
|
137
|
+
rubygems_version: 2.6.14
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Fast but inflexible XML and JSON encoding for ruby objects.
|