gutsy 1.0.3 → 1.1.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/CHANGELOG.md +5 -0
- data/examples/config.yml +1 -1
- data/lib/gutsy/generator/api_version_state.rb +2 -2
- data/lib/gutsy/generator/heroics.rb +1 -9
- data/lib/gutsy/version.rb +1 -1
- data/templates/app_client/lib/app_client.rb.erb +1 -29
- data/templates/app_client/lib/app_client/api_version/adapter.rb.erb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 261800a946f412cfe776f19051edddf5cfd296e3
|
4
|
+
data.tar.gz: 72dcb72e7f2318575aab5fca18bb5caa9586e9f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0cac6d2341bdeec70616f17fb2b6513b55858a40bbc34ba96138f61306ec2d9e682fcfcdc7e96dd680a8ba8a6550f6ef6b1e4c59382458dde25cad3b0698727
|
7
|
+
data.tar.gz: daf9052b6a53e5f89c3f27f12e48e6ddb8c9429ffdfc922c39c60deff823bbfcf3b09633fb405e28dc3e5fcb34d6efd3441a921a810e506ca7de2d7e6f20a545
|
data/CHANGELOG.md
CHANGED
data/examples/config.yml
CHANGED
@@ -15,5 +15,5 @@ gutsy:
|
|
15
15
|
gem_version: 0.2.0 # Gem version
|
16
16
|
versions:
|
17
17
|
- name: v1
|
18
|
-
|
18
|
+
namespace_path: api/features/v1 # (optional) for additional URL namespacing. Would default to `api/v1` in this example
|
19
19
|
schema_path: docs/api/v1/schema.json
|
@@ -3,14 +3,14 @@ module Gutsy
|
|
3
3
|
class ApiVersionState
|
4
4
|
extend Forwardable
|
5
5
|
|
6
|
-
attr_reader :name, :schema, :schema_path, :
|
6
|
+
attr_reader :name, :schema, :schema_path, :namespace_path
|
7
7
|
|
8
8
|
def_delegators :gem_state, :gem_name_pascal, :gem_name_snake, :app_name, :base_url
|
9
9
|
|
10
10
|
def initialize(api_version_config, gem_state)
|
11
11
|
@name = api_version_config[:name]
|
12
12
|
@schema_path = api_version_config[:schema_path]
|
13
|
-
@
|
13
|
+
@namespace_path = api_version_config[:namespace_path] || "api/#{@name.downcase}"
|
14
14
|
@gem_state = gem_state
|
15
15
|
end
|
16
16
|
|
@@ -27,15 +27,7 @@ module Gutsy
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def api_url
|
30
|
-
@api_url ||= "#{api_version_state.base_url}
|
31
|
-
end
|
32
|
-
|
33
|
-
def resource_namespace
|
34
|
-
if api_version_state.resource_namespace
|
35
|
-
"#{api_version_state.resource_namespace}/"
|
36
|
-
else
|
37
|
-
''
|
38
|
-
end
|
30
|
+
@api_url ||= "#{api_version_state.base_url}/#{api_version_state.namespace_path}"
|
39
31
|
end
|
40
32
|
|
41
33
|
def client_output_path
|
data/lib/gutsy/version.rb
CHANGED
@@ -37,34 +37,6 @@ module <%= gem_name_pascal %>
|
|
37
37
|
end
|
38
38
|
|
39
39
|
class Configuration
|
40
|
-
attr_accessor :access_token, :api_key, :api_secret,
|
41
|
-
:base_url, :options,
|
42
|
-
:adapter_factory, :api_version
|
43
|
-
|
44
|
-
def options
|
45
|
-
@options ||= {}
|
46
|
-
end
|
47
|
-
|
48
|
-
def api_version
|
49
|
-
@api_version ||= '<%= api_versions.first.name %>'
|
50
|
-
end
|
51
|
-
|
52
|
-
def api_version=(version)
|
53
|
-
options[:url] = "#{base_url}/api/#{resource_namespace}#{version}"
|
54
|
-
@api_version = version
|
55
|
-
end
|
56
|
-
|
57
|
-
def adapter_factory
|
58
|
-
@adapter_factory ||= <%= gem_name_pascal %>.const_get("#{api_version.upcase}")::Adapters::Http
|
59
|
-
end
|
60
|
-
|
61
|
-
def base_url=(url)
|
62
|
-
options[:url] = "#{url}/api/#{resource_namespace}#{api_version}"
|
63
|
-
@base_url = url
|
64
|
-
end
|
65
|
-
|
66
|
-
def resource_namespace
|
67
|
-
'<%= "#{api_versions.first.resource_namespace}/" if api_versions.first.resource_namespace %>'
|
68
|
-
end
|
40
|
+
attr_accessor :access_token, :api_key, :api_secret, :base_url
|
69
41
|
end
|
70
42
|
end
|
@@ -18,16 +18,18 @@ module <%= gem_name_pascal %>
|
|
18
18
|
access_token ||= config.access_token
|
19
19
|
api_key ||= config.api_key
|
20
20
|
api_secret ||= config.api_secret
|
21
|
-
|
21
|
+
url = "#{config.base_url}/<%= namespace_path %>"
|
22
22
|
|
23
23
|
# Workaround issue with some TLS setups (haproxy)
|
24
24
|
# Prevents :443 being added to hostname for TLS
|
25
25
|
Excon.defaults[:omit_default_port] = true
|
26
26
|
|
27
|
+
options = { url: url }.merge(options)
|
28
|
+
|
27
29
|
if access_token
|
28
|
-
|
30
|
+
Adapters::Http.connect_oauth(access_token, options)
|
29
31
|
elsif api_key && api_secret
|
30
|
-
|
32
|
+
Adapters::Http.connect(api_secret, options.merge!({
|
31
33
|
user: config.api_key
|
32
34
|
}))
|
33
35
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gutsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iora Health
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heroics
|