stack_path 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Humidifier
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Top Level Namespace
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="StackPath.html" title="StackPath (module)">StackPath</a></span>
86
+
87
+
88
+
89
+
90
+ </p>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ </div>
101
+
102
+ <div id="footer">
103
+ Generated on Wed Aug 23 13:10:22 2017 by
104
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
+ 0.9.9 (ruby-2.4.1).
106
+ </div>
107
+
108
+ </div>
109
+ </body>
110
+ </html>
@@ -0,0 +1,67 @@
1
+ module StackPath
2
+ # Represents an error in the response from StackPath
3
+ class APIError < StandardError; end
4
+
5
+ # An API client that allows querying StackPath
6
+ class Client
7
+ # The constant headers that are sent with each request
8
+ HEADERS = {
9
+ 'User-Agent' => 'Ruby StackPath CDN API Client',
10
+ 'Content-Type' => 'application/json'
11
+ }.freeze
12
+
13
+ attr_reader :base_url, :oauth_client
14
+
15
+ def initialize(options = {})
16
+ @base_url = "https://api.stackpath.com/v1/#{options[:company_alias]}"
17
+ @oauth_client =
18
+ Signet::OAuth1::Client.new(
19
+ client_credential_key: options[:client_key],
20
+ client_credential_secret: options[:client_secret],
21
+ two_legged: true
22
+ )
23
+ end
24
+
25
+ # Send a GET request to the StackPath API
26
+ def get(path, params = {})
27
+ path = "#{path}?#{URI.encode_www_form(params)}" if params.any?
28
+ request(:get, path)
29
+ end
30
+
31
+ # Send a POST request to the StackPath API
32
+ def post(path, params = {})
33
+ request(:post, path, params)
34
+ end
35
+
36
+ # Send a PUT request to the StackPath API
37
+ def put(path, params = {})
38
+ request(:put, path, params)
39
+ end
40
+
41
+ # Send a DELETE request to the StackPath API
42
+ def delete(path, params = {})
43
+ request(:delete, path, params)
44
+ end
45
+
46
+ private
47
+
48
+ def response_from(options)
49
+ response = oauth_client.fetch_protected_resource(options)
50
+ if response.status != 200
51
+ raise APIError, "Error requesting #{options[:uri]}: " \
52
+ "#{response.to_hash[:reason_phrase]}"
53
+ end
54
+ response
55
+ end
56
+
57
+ def request(method, path, params = {})
58
+ options = {
59
+ method: method,
60
+ uri: "#{base_url}#{path}",
61
+ headers: HEADERS
62
+ }
63
+ options[:body] = JSON.dump(params) if params.any?
64
+ JSON.parse(response_from(options).body)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,4 @@
1
+ module StackPath
2
+ # The current version number of the gem
3
+ VERSION = '0.0.1'.freeze
4
+ end
data/lib/stack_path.rb ADDED
@@ -0,0 +1,14 @@
1
+ require 'json'
2
+ require 'signet/oauth_1/client'
3
+ require 'uri'
4
+
5
+ require 'stack_path/client'
6
+ require 'stack_path/version'
7
+
8
+ # A package for querying the StackPath API
9
+ module StackPath
10
+ # Build a new Client with the given options and return it
11
+ def self.build_client(options = {})
12
+ Client.new(options)
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'stack_path/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'stack_path'
9
+ spec.version = StackPath::VERSION
10
+ spec.authors = ['Localytics']
11
+ spec.email = ['oss@localytics.com']
12
+
13
+ spec.summary = 'A Ruby client for the StackPath CDN API'
14
+ spec.homepage = 'https://github.com/localytics/stack_path'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features|doc)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'signet', '~> 0.7.3'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.15'
27
+ spec.add_development_dependency 'coveralls', '~> 0.8'
28
+ spec.add_development_dependency 'rake', '~> 12.0'
29
+ spec.add_development_dependency 'minitest', '~> 5.10'
30
+ spec.add_development_dependency 'rubocop', '~> 0.49'
31
+ spec.add_development_dependency 'simplecov', '~> 0.14'
32
+ spec.add_development_dependency 'yard', '~> 0.9.9'
33
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stack_path
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Localytics
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: signet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.7.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '12.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '12.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.49'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.49'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.9.9
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.9.9
125
+ description:
126
+ email:
127
+ - oss@localytics.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rubocop.yml"
134
+ - ".travis.yml"
135
+ - ".yardopts"
136
+ - Gemfile
137
+ - LICENSE
138
+ - README.md
139
+ - Rakefile
140
+ - bin/console
141
+ - bin/setup
142
+ - docs/StackPath.html
143
+ - docs/StackPath/APIError.html
144
+ - docs/StackPath/Client.html
145
+ - docs/_index.html
146
+ - docs/class_list.html
147
+ - docs/css/common.css
148
+ - docs/css/full_list.css
149
+ - docs/css/style.css
150
+ - docs/file.LICENSE.html
151
+ - docs/file.README.html
152
+ - docs/file_list.html
153
+ - docs/frames.html
154
+ - docs/index.html
155
+ - docs/js/app.js
156
+ - docs/js/full_list.js
157
+ - docs/js/jquery.js
158
+ - docs/method_list.html
159
+ - docs/top-level-namespace.html
160
+ - lib/stack_path.rb
161
+ - lib/stack_path/client.rb
162
+ - lib/stack_path/version.rb
163
+ - stack_path.gemspec
164
+ homepage: https://github.com/localytics/stack_path
165
+ licenses:
166
+ - MIT
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubyforge_project:
184
+ rubygems_version: 2.6.11
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: A Ruby client for the StackPath CDN API
188
+ test_files: []