json2yaml 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/bin/json2yaml +3 -1
- data/bin/yaml2json +3 -1
- data/json2yaml.gemspec +2 -0
- data/lib/json2yaml.rb +13 -5
- data/lib/json2yaml/version.rb +1 -1
- data/spec/json2yaml_spec.rb +25 -7
- metadata +30 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e46194deb17804a4272e56ed0bd0b3b07886d9fe
|
4
|
+
data.tar.gz: 03533791357b43d1abcedeadbc6072bda1334921
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb1e19c2b1eb75b24a9066deecae9d73695d6f979861680a0a962abe318ee43c4f5f8d2318427510415c5675460698d969f468d3fe9d4cc5d1c2690f07e5f16
|
7
|
+
data.tar.gz: dd940815742d9a40863d8c93307190cb132ddfd8f7bd44cd146db27203609064fc8a6e150a3438460d22ced74b9e3862a398dda1cf3fb797d0b6ff00920f3f35
|
data/.travis.yml
CHANGED
data/bin/json2yaml
CHANGED
data/bin/yaml2json
CHANGED
data/json2yaml.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_runtime_dependency "yajl-ruby"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
24
|
spec.add_development_dependency "rake"
|
23
25
|
spec.add_development_dependency "rspec"
|
data/lib/json2yaml.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
require "json2yaml/version"
|
2
|
-
require '
|
2
|
+
require 'yajl/json_gem'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
module Json2yaml
|
6
|
-
def self.to_yaml(
|
7
|
-
|
6
|
+
def self.to_yaml(json_stream)
|
7
|
+
Enumerator.new do |yielder|
|
8
|
+
Yajl::Parser.new.parse(json_stream) do |d|
|
9
|
+
yielder.yield d.to_yaml
|
10
|
+
end
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
|
-
def self.to_json(
|
11
|
-
|
14
|
+
def self.to_json(yaml_stream)
|
15
|
+
Enumerator.new do |yielder|
|
16
|
+
YAML.load_stream(yaml_stream) do |d|
|
17
|
+
yielder.yield d.to_json + "\n"
|
18
|
+
end
|
19
|
+
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/json2yaml/version.rb
CHANGED
data/spec/json2yaml_spec.rb
CHANGED
@@ -1,13 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Json2yaml do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
context "with single data" do
|
5
|
+
let(:json_str) { "{\"a\":\"b\"}\n" }
|
6
|
+
let(:yaml_str) { "---\na: b\n" }
|
7
|
+
let(:json_io) { StringIO.new(json_str, "r") }
|
8
|
+
let(:yaml_io) { StringIO.new(yaml_str, "r") }
|
9
|
+
context '.to_json' do
|
10
|
+
it { expect(Json2yaml.to_yaml(json_io).reduce(&:+)).to eq(yaml_str) }
|
11
|
+
end
|
12
|
+
|
13
|
+
context '.to_yaml' do
|
14
|
+
it { expect(Json2yaml.to_json(yaml_io).reduce(&:+)).to eq(json_str) }
|
15
|
+
end
|
8
16
|
end
|
9
17
|
|
10
|
-
context
|
11
|
-
|
18
|
+
context "with multiple data" do
|
19
|
+
let(:json_str) { "{\"a\":\"b\"}\n{\"c\":\"d\"}\n{\"e\":\"f\"}\n" }
|
20
|
+
let(:yaml_str) { "---\na: b\n---\nc: d\n---\ne: f\n" }
|
21
|
+
let(:json_io) { StringIO.new(json_str, "r") }
|
22
|
+
let(:yaml_io) { StringIO.new(yaml_str, "r") }
|
23
|
+
context '.to_json' do
|
24
|
+
it { expect(Json2yaml.to_yaml(json_io).reduce(&:+)).to eq(yaml_str) }
|
25
|
+
end
|
26
|
+
|
27
|
+
context '.to_yaml' do
|
28
|
+
it { expect(Json2yaml.to_json(yaml_io).reduce(&:+)).to eq(json_str) }
|
29
|
+
end
|
12
30
|
end
|
13
|
-
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json2yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fukayatsu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: yajl-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - ~>
|
31
|
+
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: '1.3'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - ~>
|
38
|
+
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
description: Convert between JSON and YAML in CLI
|
@@ -61,10 +75,10 @@ executables:
|
|
61
75
|
extensions: []
|
62
76
|
extra_rdoc_files: []
|
63
77
|
files:
|
64
|
-
- .coveralls.yml
|
65
|
-
- .gitignore
|
66
|
-
- .rspec
|
67
|
-
- .travis.yml
|
78
|
+
- ".coveralls.yml"
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- ".travis.yml"
|
68
82
|
- Gemfile
|
69
83
|
- LICENSE.txt
|
70
84
|
- README.md
|
@@ -86,20 +100,21 @@ require_paths:
|
|
86
100
|
- lib
|
87
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
102
|
requirements:
|
89
|
-
- -
|
103
|
+
- - ">="
|
90
104
|
- !ruby/object:Gem::Version
|
91
105
|
version: '0'
|
92
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
requirements: []
|
98
112
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.2.2
|
100
114
|
signing_key:
|
101
115
|
specification_version: 4
|
102
116
|
summary: Convert between JSON and YAML in CLI
|
103
117
|
test_files:
|
104
118
|
- spec/json2yaml_spec.rb
|
105
119
|
- spec/spec_helper.rb
|
120
|
+
has_rdoc:
|