lurker 0.6.0 → 0.6.1

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.
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ M��%"��K4�+��X=� ,����d�����|ϥ������0��SR͜�z�c��E�⑅ ���ڟ�o'��U
2
+ �P+R*�l`хsʉyv�.(D �\�C&2��p���̩���N,��"��b�I���ͱ�ͅk��Pa��\pĚ�KJ6��-��hۯUKZ6αM�(�o5�����C4�v4�mD�K���yG�Q2,J��zoH=�L]�}�>��/��2�l�%=�D����j�[����̭A�2�U
checksums.yaml.gz.asc DELETED
@@ -1,12 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG v1
3
- Comment: GPGTools - http://gpgtools.org
4
-
5
- iQEcBAABCgAGBQJTc6u3AAoJENcoxKfNVdjbPFQH/2AlxmZv3HxGqTBWHwEa8X0W
6
- B/BQWPNQa0TmSLb0gwMBIakmZskLEF78AoiqEsgWVjxzaUqzrfsPfF3PaEfn2dFn
7
- qyblC25Tzo55a4GNafZBfR9oLd1Z3T0feVsmS1z54dZRtVTnEIeJgDw8pGUOuLRm
8
- GhBwzwPyl1yKCfJ9iTMCB9QsoiGrJipOzYULDoXoP9BV2v1iYbVVoJj4r2JWay8B
9
- XIYQZEYMBjwIxa6IBAYP5wOoWJjf3rizveXpXGFGvUxYA28AEVfDagAyfbxn/Lvv
10
- ifO5ww5p8+VqY4Hf8TxL9YLfZHXDf8oi9hKKtjE86FypjvcuYN0WBwmAjtF6aCM=
11
- =TtxC
12
- -----END PGP SIGNATURE-----
data.tar.gz.asc DELETED
@@ -1,12 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG v1
3
- Comment: GPGTools - http://gpgtools.org
4
-
5
- iQEcBAABCgAGBQJTc6u0AAoJENcoxKfNVdjbXtoH+gOMyCvf2MRKtlx7mBadLRj9
6
- 6ei4q21BvhC60iTD9yiIg4WuREZhec+2LqiFhsEspKZbhDlyLR7/abc568P54FrZ
7
- 7kfXBW5/J8/1PuiYVpaYovExiVg8ttIqqHfpN2X3dHJ2fvKHPrDwGK+UpPKKIjvg
8
- 0pPuQAKx0YljMKlg+vDampb8JYXM+E74zpVQ2OM/lUE96ZriQNz+YEKI3t9NXLR8
9
- vDZ8u2BCovqLdLy7tqcxhvsvZHtHvTffWMLpykP3sik+WYvjma4FocfJ9QOsvUFx
10
- lwlZMfN9EGdKDw8mvNqcub0E2yGsv+Z6nZcQsD9qpLns+nDs/49baRDuJ9UXvWI=
11
- =w69M
12
- -----END PGP SIGNATURE-----
@@ -1,135 +0,0 @@
1
- # EndpointScaffolds aggregate input to guess at the structure of an API
2
- # endpoint. The #consume_* methods can modify the structure of the
3
- # in-memory endpoint, to save the results to the file system, call #persist!
4
- class Lurker::EndpointScaffold < Lurker::Endpoint
5
- def initialize(endpoint_path, extensions={}, service=Lurker::Service.default_service)
6
- if File.exist?(endpoint_path)
7
- super
8
- else
9
- @endpoint_path = endpoint_path
10
- @schema = Lurker::Schema.new(
11
- {
12
- "prefix" => "",
13
- "description" => "",
14
- "responseCodes" => []
15
- },
16
- stringify_keys(extensions)
17
- )
18
- @service = service
19
- @errors = []
20
- @extensions = extensions
21
- end
22
- end
23
-
24
- def persist!
25
- schema.ordered!.write_to(endpoint_path)
26
- end
27
-
28
- def consume_request(params, successful = true)
29
- scaffold_schema(request_parameters, stringify_keys(params), {
30
- :root_object => true
31
- })
32
- end
33
-
34
- def consume_response(params, status_code, successful=true)
35
- if successful
36
- scaffold_schema(response_parameters, stringify_keys(params), {
37
- :root_object => true
38
- })
39
- end
40
-
41
- response_code = response_codes.find do
42
- |rc| rc["status"] == status_code && rc["successful"] == successful
43
- end
44
-
45
- if !response_code
46
- response_codes << {
47
- "status" => status_code,
48
- "successful" => successful,
49
- "description" => ""
50
- }
51
- end
52
- end
53
-
54
- protected
55
-
56
- def scaffold_schema(schema, params, options = {:root_object => false})
57
- unless options[:root_object]
58
- schema["description"] ||= ""
59
- end
60
-
61
- if params.kind_of? Hash
62
- scaffold_hash(schema, params, options)
63
- elsif params.kind_of? Array
64
- scaffold_array(schema, params, options)
65
- else
66
- scaffold_atom(schema, params, options)
67
- end
68
- end
69
-
70
- def scaffold_hash(schema, params, options = {})
71
- schema["description"] ||= ""
72
- schema["type"] ||= "object"
73
- schema["additionalProperties"] = false if schema["additionalProperties"].nil?
74
- schema["required"] ||= []
75
- schema["properties"] ||= {}
76
-
77
- params.each do |key, value|
78
- unless schema[key]
79
- schema["properties"][key] ||= {}
80
- sub_options = options.merge(:root_object => false)
81
- scaffold_schema(schema["properties"][key], value, sub_options)
82
- end
83
- end
84
- end
85
-
86
- def scaffold_array(schema, params, options = {})
87
- schema["type"] ||= "array"
88
- schema["items"] ||= {}
89
- params.each do |arr_value|
90
- sub_options = options.merge(:root_object => false)
91
- scaffold_schema(schema["items"], arr_value, options.merge(sub_options))
92
- end
93
- end
94
-
95
- def scaffold_atom(schema, params, options = {})
96
- value = params
97
- schema["type"] ||= guess_type(params)
98
- if format = guess_format(params)
99
- schema["format"] ||= format
100
- end
101
- schema["example"] ||= value
102
- end
103
-
104
- def guess_type(value)
105
- in_type = value.class.to_s
106
- type_map = {
107
- "Fixnum" => "integer",
108
- "Float" => "number",
109
- "Hash" => "object",
110
- "Time" => "string",
111
- "TrueClass" => "boolean",
112
- "FalseClass" => "boolean",
113
- "NilClass" => "null"
114
- }
115
- type_map[in_type] || in_type.downcase
116
- end
117
-
118
- def guess_format(value)
119
- if value.kind_of? Time
120
- "date-time"
121
- elsif value.kind_of? String
122
- if value.start_with? "http://"
123
- "uri"
124
- elsif value.match(/\#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?\b/)
125
- "color"
126
- else
127
- begin
128
- "date-time" if Time.iso8601(value)
129
- rescue
130
- nil
131
- end
132
- end
133
- end
134
- end
135
- end
metadata.gz.asc DELETED
@@ -1,12 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG v1
3
- Comment: GPGTools - http://gpgtools.org
4
-
5
- iQEcBAABCgAGBQJTc6uwAAoJENcoxKfNVdjbBysIAKPht7dFcw1FVZGq+D3t3Gxu
6
- oLvyRB4VbdDKFVnqNy+cflqIllyCmCuVAjVepNS+te7UFnqoPkDpF21dob8JT2+h
7
- ybx9dspdr5Z3+CFy+mU7ya+GFoDolKDEzv277f3S7kGRws7C02TkR7uGr204Jyos
8
- Ckm/9c6MwT16pt+8VcTn3wUwYdDBWpLrvn2+apkPldyOPI5HI9ohgFosqDiTYRsi
9
- ObcmJRPISPYxpE4ej26h+p5flxsFridrW8NBKRWdVpjgBVeH02bGSCmQ79yMWVY2
10
- DqfZollFgztt1Fw4A90cAA5SPhCb5pfbgLiJ2GgMBZimQumpl6hQ6pJZwMTIVgA=
11
- =MIHv
12
- -----END PGP SIGNATURE-----