qiniu-kit 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +0 -6
- data/lib/qiniu/kit.rb +7 -8
- data/lib/qiniu/kit/version.rb +1 -1
- data/qiniu-kit.gemspec +1 -1
- data/spec/qiniu/kit_spec.rb +7 -6
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZGQwMjYyZmM4OTkyMjkxMzc2ZWE0NzJkZjkyOGI4NGVhODIyYzZhOQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb6ee3c5786e37bffdd844d03bc775b536003f0d
|
4
|
+
data.tar.gz: 17a1c985d25594d7ccbfd9491973ae608ac1f53d
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NTYyYzYxNmRhYTY3MWI1ZTA3Mzc3ZjU5OWRjZjZlODdhMDYyMGYxNTY1YjI5
|
11
|
-
MGEzMzA3MTNhYTliMGViYmRmOWM1OGUyZTk5YzQ4YTFmZjRjNzM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
N2RjNTQ3YTkyY2Y5MGRjNDFlODE4MmQ0NmYxZmZhZmMyZTlmYWEzYmM1ZjM4
|
14
|
-
MDkxZWU5YmM1ZDg2YWEyNWIxMzA1ODY1ZmEzMjZmZTg3MzFhZDQ2YjllMDRi
|
15
|
-
MjVjNzBlODkwZTA3M2U4MmQzMTQ2ZjkyZGU0ZDlmYTZjMTgwNjI=
|
6
|
+
metadata.gz: bec12b8ca01bdc887e3bcbabe263eff0ddcef0592fd6d4c9a0ea8147938b471c8b36c7d2c464130109e16f6517bd14e6d7439e9c78d14e7dc602d74d61b55254
|
7
|
+
data.tar.gz: 2761b75d757fa2313f755fc4583f9cc7b1d5a9f53973ca5c83411f2b756b3e67ef596939e6b0888bb3b75e639fffd8fa86284ee4782d601b7acf5b6d7300860f
|
data/README.md
CHANGED
@@ -31,15 +31,9 @@ require 'qiniu-kit'
|
|
31
31
|
Qiniu::Kit.decode_json('{"abc":"def"}')
|
32
32
|
#=> {"abc" => "def"}
|
33
33
|
|
34
|
-
Qiniu::Kit.decode_json('{"abc":"def"}', :symbolize_keys => true)
|
35
|
-
#=> {:abc => "def"}
|
36
|
-
|
37
34
|
Qiniu::Kit.encode_json({:abc => 'def'})
|
38
35
|
# convert Ruby back to JSON
|
39
36
|
|
40
|
-
Qiniu::Kit.encode_json({:abc => 'def'}, :pretty => true)
|
41
|
-
# encoded in a pretty form (if supported by the coder)
|
42
|
-
|
43
37
|
|
44
38
|
Qiniu::Kit.base64_url_encode("bucket:key")
|
45
39
|
#=> "YnVja2V0OmtleQ=="
|
data/lib/qiniu/kit.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
3
|
+
require 'base64'
|
4
|
+
require 'json'
|
6
5
|
|
7
6
|
module Qiniu
|
8
7
|
module Kit
|
@@ -22,14 +21,14 @@ module Qiniu
|
|
22
21
|
base64_url_encode(entry_uri)
|
23
22
|
end
|
24
23
|
|
25
|
-
def decode_json(
|
26
|
-
|
27
|
-
rescue
|
24
|
+
def decode_json(encoded)
|
25
|
+
JSON.parse(encoded)
|
26
|
+
rescue JSON::ParserError
|
28
27
|
raise Qiniu::Errors::JSONDecodeError.new("Invalid segment encoding")
|
29
28
|
end
|
30
29
|
|
31
|
-
def encode_json(
|
32
|
-
|
30
|
+
def encode_json(raw)
|
31
|
+
JSON.generate(raw)
|
33
32
|
end
|
34
33
|
|
35
34
|
end
|
data/lib/qiniu/kit/version.rb
CHANGED
data/qiniu-kit.gemspec
CHANGED
@@ -18,7 +18,7 @@ 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 "
|
21
|
+
spec.add_runtime_dependency "json", "~> 1.8"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.5"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.1"
|
data/spec/qiniu/kit_spec.rb
CHANGED
@@ -12,17 +12,18 @@ describe Qiniu::Kit do
|
|
12
12
|
|
13
13
|
context '.decode_json' do
|
14
14
|
it 'should works' do
|
15
|
-
Qiniu::Kit.decode_json('{"
|
16
|
-
Qiniu::Kit.decode_json('{"abc":"def"}', :symbolize_keys => true).should eq({:abc => "def"})
|
15
|
+
Qiniu::Kit.decode_json('{"deadline":0,"scope":"my_bucket"}').should eq({"deadline"=>0, "scope"=>"my_bucket"})
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
19
|
context '.encode_json' do
|
21
20
|
it 'should works' do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
expected_result =[
|
22
|
+
'{"deadline":0,"scope":"my_bucket"}',
|
23
|
+
'{"scope":"my_bucket","deadline":0}'
|
24
|
+
]
|
25
|
+
result = Qiniu::Kit.encode_json({"deadline"=>0, "scope"=>"my_bucket"})
|
26
|
+
expected_result.include?(result).should be_true
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiniu-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- why404
|
@@ -11,59 +11,59 @@ cert_chain: []
|
|
11
11
|
date: 2014-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.5'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.14'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.14'
|
69
69
|
description: Qiniu basic for setup other libraries, also can be used independently.
|
@@ -73,9 +73,9 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .rspec
|
78
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE
|
81
81
|
- README.md
|
@@ -101,12 +101,12 @@ require_paths:
|
|
101
101
|
- lib
|
102
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|