patchboard 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/patchboard/api.rb +14 -3
- data/lib/patchboard/resource.rb +13 -0
- data/lib/patchboard/schema_manager.rb +1 -0
- data/lib/patchboard.rb +11 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 145c3036d351832f6a590800eaa9df5d4efc9cc0
|
4
|
+
data.tar.gz: 80dc8017be3bed7cd90832c1556c827b11fcb5a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04d056ccbd097228d9762913b6e86d60a46b7faef5352d59f90e1d5057ff72de239bfbcc6c2ef8a2885864a2ea21f75092c3edd77789b4313af4b9b4930bda00
|
7
|
+
data.tar.gz: 77d65a4918a44dec680c6551f4d0117b89171e84a9f0e87dfc877365b215000f5e4e08abea1b46989e62f96d4ed5403dacea89974dc394929503d2523bf8e55f
|
data/lib/patchboard/api.rb
CHANGED
@@ -28,6 +28,14 @@ class Patchboard
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
class ArrayResource < Array
|
32
|
+
attr_accessor :response
|
33
|
+
end
|
34
|
+
|
35
|
+
class HashResource < Hash
|
36
|
+
attr_accessor :response
|
37
|
+
end
|
38
|
+
|
31
39
|
def decorate(context, schema, data)
|
32
40
|
unless schema
|
33
41
|
return Hashie::Mash.new(data)
|
@@ -43,10 +51,10 @@ class Patchboard
|
|
43
51
|
when "array"
|
44
52
|
# TODO: handle the case where schema.items is an array, which
|
45
53
|
# signifies a tuple. schema.additionalItems then becomes important.
|
46
|
-
data.map! do |item|
|
54
|
+
array = data.map! do |item|
|
47
55
|
self.decorate(context, schema[:items], item)
|
48
56
|
end
|
49
|
-
|
57
|
+
data = ArrayResource.new(array)
|
50
58
|
when "object"
|
51
59
|
if schema[:properties]
|
52
60
|
schema[:properties].each do |key, prop_schema|
|
@@ -64,12 +72,15 @@ class Patchboard
|
|
64
72
|
end
|
65
73
|
end
|
66
74
|
data = Hashie::Mash.new data
|
75
|
+
else
|
76
|
+
if data.is_a? Hash
|
77
|
+
data = Hashie::Mash.new data
|
78
|
+
end
|
67
79
|
end
|
68
80
|
end
|
69
81
|
data
|
70
82
|
end
|
71
83
|
|
72
|
-
|
73
84
|
end
|
74
85
|
|
75
86
|
class Mapping
|
data/lib/patchboard/resource.rb
CHANGED
@@ -105,6 +105,19 @@ class Patchboard
|
|
105
105
|
|
106
106
|
|
107
107
|
def curl
|
108
|
+
raise "Unimplemented"
|
109
|
+
end
|
110
|
+
|
111
|
+
def values_at(*keys)
|
112
|
+
self.attributes.values_at(*keys)
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_hash
|
116
|
+
self.attributes
|
117
|
+
end
|
118
|
+
|
119
|
+
def to_json(*a)
|
120
|
+
self.to_hash.to_json(*a)
|
108
121
|
end
|
109
122
|
end
|
110
123
|
|
data/lib/patchboard.rb
CHANGED
@@ -18,6 +18,17 @@ require "http"
|
|
18
18
|
require "json"
|
19
19
|
require "hashie"
|
20
20
|
|
21
|
+
module Hashie
|
22
|
+
class Mash
|
23
|
+
|
24
|
+
# monkey patch to make #values_at work with symbols
|
25
|
+
def values_at(*args)
|
26
|
+
super *args.map {|arg| convert_key(arg)}
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
21
32
|
require_relative "patchboard/api"
|
22
33
|
require_relative "patchboard/util"
|
23
34
|
require_relative "patchboard/resource"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patchboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew King
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.8
|
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
|
-
version: 1.8
|
26
|
+
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: http
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.5
|
33
|
+
version: '0.5'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.5
|
40
|
+
version: '0.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hashie
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.0
|
47
|
+
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.0
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest-reporters
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0
|
61
|
+
version: '1.0'
|
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
|
-
version: 1.0
|
68
|
+
version: '1.0'
|
69
69
|
description:
|
70
70
|
email: automatthew@gmail.com
|
71
71
|
executables: []
|