nucleo-client 0.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.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.env.sample +2 -0
  3. data/.gitignore +16 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +31 -0
  7. data/Rakefile +37 -0
  8. data/lib/nucleo/client.rb +172 -0
  9. data/lib/nucleo/client/version.rb +5 -0
  10. data/lib/nucleo/configuration.rb +83 -0
  11. data/lib/nucleo/configurations.rb +6 -0
  12. data/lib/nucleo/configurations/default.rb +100 -0
  13. data/lib/nucleo/connection.rb +44 -0
  14. data/lib/nucleo/errors.rb +7 -0
  15. data/lib/nucleo/errors/invalid_uri_error.rb +6 -0
  16. data/lib/nucleo/errors/record_not_found.rb +6 -0
  17. data/lib/nucleo/logger.rb +36 -0
  18. data/lib/nucleo/models.rb +50 -0
  19. data/lib/nucleo/models/change_types.rb +10 -0
  20. data/lib/nucleo/models/change_types/base.rb +81 -0
  21. data/lib/nucleo/models/change_types/seo.rb +13 -0
  22. data/lib/nucleo/models/change_types/seo/base.rb +50 -0
  23. data/lib/nucleo/models/change_types/seo/meta_description.rb +10 -0
  24. data/lib/nucleo/models/change_types/seo/page_title.rb +10 -0
  25. data/lib/nucleo/models/changes.rb +50 -0
  26. data/lib/nucleo/models/check_js.rb +41 -0
  27. data/lib/nucleo/models/check_types.rb +11 -0
  28. data/lib/nucleo/models/check_types/base.rb +25 -0
  29. data/lib/nucleo/models/check_types/count.rb +26 -0
  30. data/lib/nucleo/models/check_types/length.rb +26 -0
  31. data/lib/nucleo/models/check_types/not_exists.rb +8 -0
  32. data/lib/nucleo/models/checks.rb +56 -0
  33. data/lib/nucleo/models/concerns.rb +7 -0
  34. data/lib/nucleo/models/concerns/count.rb +57 -0
  35. data/lib/nucleo/models/concerns/length.rb +57 -0
  36. data/lib/nucleo/models/date_range.rb +66 -0
  37. data/lib/nucleo/models/element.rb +40 -0
  38. data/lib/nucleo/models/elements.rb +47 -0
  39. data/lib/nucleo/models/feed.rb +141 -0
  40. data/lib/nucleo/models/feed_types.rb +11 -0
  41. data/lib/nucleo/models/feed_types/analytics.rb +18 -0
  42. data/lib/nucleo/models/feed_types/analytics/base.rb +12 -0
  43. data/lib/nucleo/models/feed_types/analytics/page/channels.rb +61 -0
  44. data/lib/nucleo/models/feed_types/analytics/page/pages.rb +58 -0
  45. data/lib/nucleo/models/feed_types/analytics/page/referrers.rb +61 -0
  46. data/lib/nucleo/models/feed_types/analytics/page/social.rb +61 -0
  47. data/lib/nucleo/models/feed_types/analytics/site/channels.rb +61 -0
  48. data/lib/nucleo/models/feed_types/analytics/site/pages.rb +61 -0
  49. data/lib/nucleo/models/feed_types/analytics/site/referrers.rb +61 -0
  50. data/lib/nucleo/models/feed_types/analytics/site/social.rb +61 -0
  51. data/lib/nucleo/models/feed_types/base.rb +182 -0
  52. data/lib/nucleo/models/feed_types/seo.rb +22 -0
  53. data/lib/nucleo/models/feed_types/seo/page/base.rb +47 -0
  54. data/lib/nucleo/models/feed_types/seo/page/img_alt.rb +90 -0
  55. data/lib/nucleo/models/feed_types/seo/page/meta_description.rb +49 -0
  56. data/lib/nucleo/models/feed_types/seo/page/meta_robots.rb +48 -0
  57. data/lib/nucleo/models/feed_types/seo/page/page_title.rb +48 -0
  58. data/lib/nucleo/models/feed_types/seo/page/seo_summary.rb +53 -0
  59. data/lib/nucleo/models/feed_types/seo/page/summary.rb +52 -0
  60. data/lib/nucleo/models/feed_types/seo/site/base.rb +22 -0
  61. data/lib/nucleo/models/feed_types/seo/site/img_alt.rb +14 -0
  62. data/lib/nucleo/models/feed_types/seo/site/meta_description.rb +14 -0
  63. data/lib/nucleo/models/feed_types/seo/site/meta_robots.rb +14 -0
  64. data/lib/nucleo/models/feed_types/seo/site/page_title.rb +14 -0
  65. data/lib/nucleo/models/feeds.rb +126 -0
  66. data/lib/nucleo/models/metric.rb +54 -0
  67. data/lib/nucleo/models/metric_period.rb +97 -0
  68. data/lib/nucleo/models/metric_period_row.rb +125 -0
  69. data/lib/nucleo/models/metric_period_rows.rb +34 -0
  70. data/lib/nucleo/models/metric_period_totals.rb +121 -0
  71. data/lib/nucleo/models/metric_periods.rb +78 -0
  72. data/lib/nucleo/models/metric_periods_comparison.rb +80 -0
  73. data/lib/nucleo/models/metric_periods_comparisons.rb +73 -0
  74. data/lib/nucleo/models/metric_periods_totals.rb +58 -0
  75. data/lib/nucleo/models/page.rb +147 -0
  76. data/lib/nucleo/models/page_alerts.rb +27 -0
  77. data/lib/nucleo/models/page_metric.rb +58 -0
  78. data/lib/nucleo/models/page_rank.rb +28 -0
  79. data/lib/nucleo/models/pages.rb +40 -0
  80. data/lib/nucleo/models/seo_score.rb +28 -0
  81. data/lib/nucleo/models/site_feed.rb +82 -0
  82. data/lib/nucleo/models/tag.rb +48 -0
  83. data/lib/nucleo/models/tags.rb +35 -0
  84. data/lib/nucleo/requests.rb +14 -0
  85. data/lib/nucleo/requests/analyzer.rb +35 -0
  86. data/lib/nucleo/requests/check_js.rb +56 -0
  87. data/lib/nucleo/requests/feed.rb +58 -0
  88. data/lib/nucleo/requests/page.rb +113 -0
  89. data/lib/nucleo/requests/page_alerts.rb +36 -0
  90. data/lib/nucleo/requests/page_changes.rb +44 -0
  91. data/lib/nucleo/requests/site.rb +26 -0
  92. data/lib/nucleo/requests/site_changes.rb +56 -0
  93. data/lib/nucleo/requests/site_feed.rb +41 -0
  94. data/lib/nucleo/response.rb +52 -0
  95. data/lib/nucleo/utilities.rb +7 -0
  96. data/lib/nucleo/utilities/status_code_mapper.rb +53 -0
  97. data/lib/nucleo/webhook.rb +26 -0
  98. data/nucleo-client.gemspec +35 -0
  99. data/spec/data/models/feed_types/seo/heading_tag_length.json +55 -0
  100. data/spec/data/models/feed_types/seo/internal_link_count.json +149 -0
  101. data/spec/data/models/feed_types/seo/no_follow_link_count.json +142 -0
  102. data/spec/spec_helper.rb +15 -0
  103. data/spec/unit/nucleo/models/concerns/count_spec.rb +103 -0
  104. data/spec/unit/nucleo/models/concerns/length_spec.rb +79 -0
  105. data/spec/unit/nucleo/models/feed_types/analytics/site/pages_no_data_spec.rb +39 -0
  106. data/spec/unit/nucleo/models/metric_periods_comparison_spec.rb +50 -0
  107. data/spec/unit/nucleo/models/metric_periods_comparisons_spec.rb +58 -0
  108. metadata +341 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28f0fb4588cdd64759b7cee6f5dec135ddedb46a
4
+ data.tar.gz: 49c64dd421a6cdb6a90a96dfac485a5cbd22b8ca
5
+ SHA512:
6
+ metadata.gz: 90641445aa873945cd638637d1bb58d433787c7ea4e77d637662772414e9710e243b9075dcd49486a7feefd2c651e40271e2f59f43fedfccd803e93a51dfc72b
7
+ data.tar.gz: 94dca77dad3b290e2de9774765b15748e6962e7762bdf43a66546abe4587fae4396030668b24cad354e0278b0cc63a146c75f4132f17f91285e54a5278a2d9b9
@@ -0,0 +1,2 @@
1
+ export NUCLEO_API_HOST=''
2
+ export NUCLEO_API_TOKEN=''
@@ -0,0 +1,16 @@
1
+ .DS_Store
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ .env
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nucleo-client.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Nate Klaiber
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Nucleo::Client
2
+
3
+ Ruby client for interacting with the Nucleo Service
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'nucleo-client'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install nucleo-client
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/quicksprout/nucleo-client/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,37 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "yard"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ YARD::Rake::YardocTask.new do |t|
8
+ t.files = Dir["lib/**/*.rb"]
9
+ end
10
+
11
+ desc "Run tests"
12
+ task default: [:spec]
13
+
14
+ desc "Document the Library"
15
+ task doc: [:yard]
16
+
17
+ desc "List out API Routes"
18
+ task(:routes) do
19
+ require 'nucleo/client'
20
+ require 'terminal-table'
21
+
22
+ route_definitions = Nucleo::Client.routes
23
+
24
+ row_display = ->(row) do
25
+ [row.name, row.path]
26
+ end
27
+
28
+ title = "Nucleo API Routes"
29
+ headings = ['Route Name', 'Route']
30
+ rows = route_definitions.map { |r| row_display.call(r) }
31
+
32
+ table = Terminal::Table.new(title: title, headings: headings, rows: rows)
33
+ puts "\n"
34
+ puts table.to_s
35
+ puts "\n"
36
+ end
37
+
@@ -0,0 +1,172 @@
1
+ require 'dotenv'
2
+ require 'json'
3
+ require 'logger'
4
+ require 'multi_json'
5
+ require 'restless_router'
6
+
7
+ Dotenv.load
8
+
9
+ require File.expand_path('../../nucleo/client/version', __FILE__)
10
+
11
+ require File.expand_path('../../nucleo/logger', __FILE__)
12
+ require File.expand_path('../../nucleo/configuration', __FILE__)
13
+ require File.expand_path('../../nucleo/connection', __FILE__)
14
+ require File.expand_path('../../nucleo/requests', __FILE__)
15
+ require File.expand_path('../../nucleo/response', __FILE__)
16
+ require File.expand_path('../../nucleo/errors', __FILE__)
17
+
18
+ require File.expand_path('../../nucleo/utilities', __FILE__)
19
+
20
+ require File.expand_path('../../nucleo/models', __FILE__)
21
+
22
+ require File.expand_path('../configuration', __FILE__)
23
+
24
+
25
+ module Nucleo
26
+ class Client
27
+
28
+ # Class accessor methods to be
29
+ # utilities throughout the client.
30
+ class << self
31
+ attr_accessor :configuration
32
+ attr_accessor :routes
33
+ end
34
+
35
+ # Create a default configuration to use
36
+ #
37
+ # @return [Nucleo::Configuration]
38
+ def self.configuration
39
+ @configuration ||= Nucleo::Configuration.new
40
+ end
41
+
42
+ # Specify configuration options. This will be
43
+ # applied to our memoized Configuration.
44
+ #
45
+ # @return [Nucleo::Configuration]
46
+ def self.configure
47
+ yield(self.configuration)
48
+ end
49
+
50
+ # Helper method to access the Connection object
51
+ #
52
+ # @return [Nucleo::Connection]
53
+ def self.connection
54
+ @connection ||= Nucleo::Connection.new(url: self.configuration.api_host) do |builder|
55
+ builder.use(:gzip)
56
+
57
+ builder.response(:json, content_type: /\bjson$/)
58
+
59
+ builder.response(:logger, self.configuration.request_logger)
60
+ builder.response(:detailed_logger, self.configuration.detailed_logger)
61
+
62
+ builder.request(:retry, max: 10, interval: 1, interval_randomness: 0.5, backoff_factor: 2)
63
+
64
+ builder.options[:timeout] = 600
65
+
66
+ builder.adapter(Nucleo::Connection.default_adapter)
67
+ end
68
+
69
+ # Inject the Authorization via the API key
70
+ @connection.headers['x-api-key'] = self.configuration.access_token
71
+
72
+ # Merge in the default headers
73
+ @connection.headers.merge!(self.configuration.connection_options[:headers])
74
+
75
+ @connection
76
+ end
77
+
78
+ # Helper method to perform a GET request
79
+ #
80
+ # @return [Nucleo::Response] Faraday Response Delegator
81
+ def self.get(url, data={}, headers={})
82
+ request = self.connection.get(url, data, headers)
83
+
84
+ Nucleo::Response.new(request)
85
+ end
86
+
87
+ # Helper method to perform a HEAD request
88
+ #
89
+ # @return [Nucleo::Response] Faraday Response Delegator
90
+ def self.head(url, data={}, headers={})
91
+ request = self.connection.head(url, data, headers)
92
+
93
+ Nucleo::Response.new(request)
94
+ end
95
+
96
+ # Helper method to perform an OPTIONS request
97
+ #
98
+ # @return [Nucleo::Response] Faraday Response Delegator
99
+ def self.options(url, headers={})
100
+ request = self.connection.http_options(url, nil, headers)
101
+
102
+ Nucleo::Response.new(request)
103
+ end
104
+
105
+ # Helper method to perform an POST request
106
+ #
107
+ # @return [Nucleo::Response] Faraday Response Delegator
108
+ def self.post(url, data={}, headers={})
109
+ request = self.connection.post(url, data, headers)
110
+
111
+ Nucleo::Response.new(request)
112
+ end
113
+
114
+ # Helper method to perform an PUT request
115
+ #
116
+ # @return [Nucleo::Response] Faraday Response Delegator
117
+ def self.put(url, data={}, headers={})
118
+ request = self.connection.put(url, data, headers)
119
+
120
+ Nucleo::Response.new(request)
121
+ end
122
+
123
+ # Helper method to perform an PATCh request
124
+ #
125
+ # @return [Nucleo::Response] Faraday Response Delegator
126
+ def self.patch(url, data={}, headers={})
127
+ request = self.connection.patch(url, data, headers)
128
+
129
+ Nucleo::Response.new(request)
130
+ end
131
+
132
+ # Helper method to perform an DELETE request
133
+ #
134
+ # @return [Nucleo::Response] Faraday Response Delegator
135
+ def self.delete(url, data={}, headers={})
136
+ request = self.connection.delete(url, data, headers)
137
+
138
+ Nucleo::Response.new(request)
139
+ end
140
+
141
+ # Define the API routes. This will return a collection of
142
+ # available routes.
143
+ def self.routes
144
+ return @routes if @routes
145
+
146
+ @routes = RestlessRouter::Routes.new
147
+
148
+ @routes.add_route(RestlessRouter::Route.new('analyzer', ("%sanalyzer" % [self.api_host])))
149
+ @routes.add_route(RestlessRouter::Route.new('analyzer-site-page', ("%sanalyzer/sites/{site_id}/pages/{id}" % [self.api_host]), templated: true))
150
+ @routes.add_route(RestlessRouter::Route.new('sites', ("%ssites" % [self.api_host])))
151
+ @routes.add_route(RestlessRouter::Route.new('site', ("%ssites/{id}{?includes,metrics.per_page,metrics.page,alerts.per_page,alerts.page,pages.per_page,pages.page,changes.per_page,changes.page}" % [self.api_host]), templated: true))
152
+ @routes.add_route(RestlessRouter::Route.new('site-process', ("%ssites/{id}/process" % [self.api_host]), templated: true))
153
+ @routes.add_route(RestlessRouter::Route.new('site-pages', ("%ssites/{id}/pages" % [self.api_host]), templated: true))
154
+ @routes.add_route(RestlessRouter::Route.new('site-page-detail', ("%ssites/{site_id}/pages/{id}" % [self.api_host]), templated: true))
155
+ @routes.add_route(RestlessRouter::Route.new('site-page-alerts', ("%ssites/{site_id}/alerts/{type}" % [self.api_host]), templated: true))
156
+ @routes.add_route(RestlessRouter::Route.new('site-feed', ("%ssites/{id}/feed{?max_feed_items}" % [self.api_host]), templated: true))
157
+ @routes.add_route(RestlessRouter::Route.new('site-page-changes', ("%ssites/{site_id}/pages/{page_id}/changes" % [self.api_host]), templated: true))
158
+ @routes.add_route(RestlessRouter::Route.new('site-changes-batch', ("%ssites/{site_id}/changes/batch" % [self.api_host]), templated: true))
159
+ @routes.add_route(RestlessRouter::Route.new('site-changes', ("%ssites/{site_id}/changes" % [self.api_host]), templated: true))
160
+ @routes.add_route(RestlessRouter::Route.new('util-checkjs', ("%sutil/checkjs?url={url}" % [self.api_host]), templated: true))
161
+
162
+ @routes
163
+ end
164
+
165
+ # Helper method to return the API host
166
+ #
167
+ # @return [String] API Base URL
168
+ def self.api_host
169
+ self.configuration.api_host
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,5 @@
1
+ module Nucleo
2
+ class Client
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,83 @@
1
+ require File.expand_path('../configurations', __FILE__)
2
+
3
+ module Nucleo
4
+ class Configuration
5
+ # Connection
6
+ attr_accessor :api_host
7
+ attr_accessor :access_token
8
+ attr_accessor :connection_options
9
+
10
+ # Request
11
+ attr_accessor :user_agent
12
+ attr_accessor :media_type
13
+ attr_accessor :content_type
14
+
15
+ # Logging
16
+ attr_accessor :detailed_logger
17
+ attr_accessor :request_logger
18
+ attr_accessor :cache_logger
19
+ attr_accessor :logger
20
+
21
+ # Returns the set of allowed configuration
22
+ # options
23
+ #
24
+ # @return [Array<Symbol>] Configuration Keys
25
+ def self.keys
26
+ @keys ||= [
27
+ :api_host,
28
+ :access_token,
29
+ :connection_options,
30
+ :user_agent,
31
+ :media_type,
32
+ :content_type,
33
+ :request_logger,
34
+ :detailed_logger,
35
+ :cache_logger,
36
+ :logger
37
+ ]
38
+ end
39
+
40
+ # Create a new instance of the Configuration Object
41
+ #
42
+ # @param attributes [Hash] Hash of configuration keys and values
43
+ #
44
+ # @return [Nucleo::Configuration] Instance of the object
45
+ def initialize(attributes={})
46
+ self.class.keys.each do |key|
47
+ instance_variable_set(:"@#{key}", (attributes[key] || Nucleo::Configurations::Default.options[key]))
48
+ end
49
+ end
50
+
51
+ # The final set of connection options
52
+ #
53
+ # @return [Hash] Connection options
54
+ def connection_options
55
+ {
56
+ :headers => {
57
+ :accept => self.media_type,
58
+ :user_agent => self.user_agent,
59
+ :content_type => self.content_type
60
+ }
61
+ }
62
+ end
63
+
64
+ # Allows you to configure the object after it's been
65
+ # initialized.
66
+ #
67
+ # @return [Nucleo::Configuration] The configuration instance
68
+ def configure(&block)
69
+ yield(self)
70
+ end
71
+
72
+ # Allows you to reset your configuration back to the default
73
+ # state.
74
+ #
75
+ # @return [Nucleo::Configuration] The configuration with Defaults applied
76
+ def reset!
77
+ self.class.keys.each do |key|
78
+ instance_variable_set(:"@#{key}", Nucleo::Configurations::Default.options[key])
79
+ end
80
+ end
81
+ alias :setup :reset!
82
+ end
83
+ end
@@ -0,0 +1,6 @@
1
+ require File.expand_path('../configurations/default', __FILE__)
2
+
3
+ module Nucleo
4
+ module Configurations
5
+ end
6
+ end
@@ -0,0 +1,100 @@
1
+ require File.expand_path('../../logger', __FILE__)
2
+ require File.expand_path('../../client', __FILE__)
3
+
4
+ module Nucleo
5
+ module Configurations
6
+ module Default
7
+ API_HOST = "https//api.quicksprout.com".freeze
8
+ USER_AGENT = ("Nucleo Web Application Gem %s" % [Nucleo::Client::VERSION]).freeze
9
+ MEDIA_TYPE = "application/json".freeze
10
+ CONTENT_TYPE = "application/json".freeze
11
+
12
+ # Return the collection of default options and values
13
+ #
14
+ # @return [Hash] Keys and values of default configuration
15
+ def self.options
16
+ Hash[Nucleo::Configuration.keys.map { |key| [key, __send__(key)] }]
17
+ end
18
+
19
+ # Return the ENV access token or nil
20
+ #
21
+ # @return [String, Nil]
22
+ def self.access_token
23
+ ENV['NUCLEO_ACCESS_TOKEN']
24
+ end
25
+
26
+ # Return the ENV API Host or the default production
27
+ # API host.
28
+ #
29
+ # @return [String]
30
+ def self.api_host
31
+ ENV.fetch('NUCLEO_API_HOST', API_HOST)
32
+ end
33
+
34
+ # Return the ENV Accept header or
35
+ # default constant.
36
+ #
37
+ # @return [String]
38
+ def self.media_type
39
+ ENV.fetch('NUCLEO_MEDIA_TYPE', MEDIA_TYPE)
40
+ end
41
+
42
+ # Return the ENV Content-Type header or
43
+ # default constant.
44
+ #
45
+ # @return [String]
46
+ def self.content_type
47
+ ENV.fetch('NUCLEO_CONTENT_TYPE', CONTENT_TYPE)
48
+ end
49
+
50
+ # REturn the ENV User-Agent header or
51
+ # default constant.
52
+ #
53
+ # @return [String]
54
+ def self.user_agent
55
+ ENV.fetch('NUCLEO_USER_AGENT', USER_AGENT)
56
+ end
57
+
58
+ # Return the default logger to STDOUT
59
+ #
60
+ # @return [Nucleo::Logger] Logger Delegator
61
+ def self.request_logger
62
+ Nucleo::Logger.new(STDOUT)
63
+ end
64
+
65
+ # Return the default logger to STDOUT
66
+ #
67
+ # @return [Nucleo::Logger] Logger Delegator
68
+ def self.detailed_logger
69
+ Nucleo::Logger.new(STDOUT)
70
+ end
71
+
72
+ # Return the default logger to STDOUT
73
+ #
74
+ # @return [Nucleo::Logger] Logger Delegator
75
+ def self.cache_logger
76
+ Nucleo::Logger.new(STDOUT)
77
+ end
78
+
79
+ # Return the default logger to STDOUT
80
+ #
81
+ # @return [Nucleo::Logger] Logger Delegator
82
+ def self.logger
83
+ Nucleo::Logger.new(STDOUT)
84
+ end
85
+
86
+ # Returns a set of default connection options
87
+ #
88
+ # @return [Hash] Connection Options
89
+ def self.connection_options
90
+ {
91
+ :headers => {
92
+ :accept => self.media_type,
93
+ :user_agent => self.user_agent,
94
+ :content_type => self.content_type
95
+ }
96
+ }
97
+ end
98
+ end
99
+ end
100
+ end