gutsy 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5963cf88c6a7dcb3b18da8262c68823c33093fa8
4
- data.tar.gz: 2407339cb81184ee02333253302ac6f8af9160be
3
+ metadata.gz: 261800a946f412cfe776f19051edddf5cfd296e3
4
+ data.tar.gz: 72dcb72e7f2318575aab5fca18bb5caa9586e9f7
5
5
  SHA512:
6
- metadata.gz: a968f381f49cf8a8c2af6be6a7d4d96f9568a5462d1a0955c717a55361411ede9e0031c19f50814a6d3e9a4a2f77661421b7e493e5b7af49c2e937269916125a
7
- data.tar.gz: 0c3a94133ee40fd29fc7951e98a5cea5352f95b8c3c638c6d3175b495b9c5b34447af2706068c439f2b7aff30364955df4f0366c1704e6d5810739372d2c4cd9
6
+ metadata.gz: f0cac6d2341bdeec70616f17fb2b6513b55858a40bbc34ba96138f61306ec2d9e682fcfcdc7e96dd680a8ba8a6550f6ef6b1e4c59382458dde25cad3b0698727
7
+ data.tar.gz: daf9052b6a53e5f89c3f27f12e48e6ddb8c9429ffdfc922c39c60deff823bbfcf3b09633fb405e28dc3e5fcb34d6efd3441a921a810e506ca7de2d7e6f20a545
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Gutsy Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ * Supports multiple API versions. `namespace_path` configuration replaced the
6
+ short-lived `resource_namespace` config
7
+
3
8
  ## 1.0.3
4
9
 
5
10
  * Adds `resource_namespace` configuration
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
- resource_namespace: features # (optional) additional URL namespacing
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, :resource_namespace
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
- @resource_namespace = api_version_config[:resource_namespace]
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}/api/#{resource_namespace}#{api_version_state.name.downcase}"
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
@@ -1,3 +1,3 @@
1
1
  module Gutsy
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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
- options = config.options.merge!(options)
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
- config.adapter_factory.connect_oauth(access_token, options)
30
+ Adapters::Http.connect_oauth(access_token, options)
29
31
  elsif api_key && api_secret
30
- config.adapter_factory.connect(api_secret, options.merge!({
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.3
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-09-21 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heroics