hphones-ruby 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25c61ef3e11a0f877c8ec0af76a6f06bf90d2894
4
+ data.tar.gz: a8e4ef5f8e023996fb7f1466e8ef5f680e01061d
5
+ SHA512:
6
+ metadata.gz: 4ec366fd27a90871e0f2ebd0163759f0aa1cb3ca4cb98e163acc0d8f75c2eb6a07de9a4752f7a1123f6173201f7b816ce8e38830a87fc2b95433ed17e182e9b7
7
+ data.tar.gz: b4643d98c4eb0abcb32b2ee48666da54fb38cf5d1a8e4f2055c8e3969dabded10933eb43bcc47a662f3b2b0d4c8a926d65e4492b3f63bd19b59f4fa9e637a3ec
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ .env
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'spec/**/*'
4
+ - 'bin/**/*'
5
+
6
+ # Metrics
7
+
8
+ Metrics/LineLength:
9
+ Max: 120
10
+
11
+ # Layout
12
+
13
+ Layout/MultilineMethodCallIndentation:
14
+ EnforcedStyle: indented
15
+
16
+ Layout/MultilineOperationIndentation:
17
+ EnforcedStyle: indented
18
+
19
+ # Style
20
+
21
+ Style/DoubleNegation:
22
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.2
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tyguillen@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in hphones-ruby.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hphones-ruby (0.0.1)
5
+ faraday
6
+ hashie
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.1.2)
12
+ diff-lcs (1.3)
13
+ dotenv (2.2.1)
14
+ faraday (0.13.1)
15
+ multipart-post (>= 1.2, < 3)
16
+ hashie (3.5.6)
17
+ method_source (0.9.0)
18
+ multipart-post (2.0.0)
19
+ pry (0.11.3)
20
+ coderay (~> 1.1.0)
21
+ method_source (~> 0.9.0)
22
+ rake (10.5.0)
23
+ rspec (3.7.0)
24
+ rspec-core (~> 3.7.0)
25
+ rspec-expectations (~> 3.7.0)
26
+ rspec-mocks (~> 3.7.0)
27
+ rspec-core (3.7.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-expectations (3.7.0)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-mocks (3.7.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.7.0)
35
+ rspec-support (3.7.0)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ bundler (~> 1.16)
42
+ dotenv
43
+ hphones-ruby!
44
+ pry
45
+ rake (~> 10.0)
46
+ rspec (~> 3.0)
47
+
48
+ BUNDLED WITH
49
+ 1.16.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Tyler Guillen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Hphones
2
+
3
+ [![Build Status](https://travis-ci.org/aastronautss/hphones-ruby.svg?branch=master)](https://travis-ci.org/aastronautss/hphones-ruby)
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/hphones`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ TODO: Delete this and the text above, and describe your gem
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'hphones-ruby'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install hphones-ruby
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hphones-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
42
+
43
+ ## Code of Conduct
44
+
45
+ Everyone interacting in the Hphones::Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/hphones-ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'hphones'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,224 @@
1
+ get_index:
2
+ method: get
3
+ params:
4
+ - key: cmd
5
+ value: getIndex
6
+ get_artist:
7
+ method: get
8
+ params:
9
+ - key: cmd
10
+ value: getArtist
11
+ - key: id
12
+ required: true
13
+ get_album:
14
+ method: get
15
+ params:
16
+ - key: cmd
17
+ value: getAlbum
18
+ - key: id
19
+ required: true
20
+ get_upcoming:
21
+ method: get
22
+ params:
23
+ - key: cmd
24
+ value: getUpcoming
25
+ get_wanted:
26
+ method: get
27
+ params:
28
+ - key: cmd
29
+ value: getWanted
30
+ get_similar:
31
+ method: get
32
+ params:
33
+ - key: cmd
34
+ value: getSimilar
35
+ get_history:
36
+ method: get
37
+ params:
38
+ - key: cmd
39
+ value: getHistory
40
+ # NOT WORKING YET
41
+ # get_logs:
42
+ # method: get
43
+ # params:
44
+ # - key: cmd
45
+ # value: getLogs
46
+ find_artist:
47
+ method: get
48
+ params:
49
+ - key: cmd
50
+ value: findArtist
51
+ - key: name
52
+ required: true
53
+ - key: limit
54
+ required: false
55
+ find_album:
56
+ method: get
57
+ params:
58
+ - key: cmd
59
+ value: findAlbum
60
+ - key: name
61
+ required: true
62
+ - key: limit
63
+ required: false
64
+ add_artist:
65
+ method: get
66
+ params:
67
+ - key: cmd
68
+ value: addArtist
69
+ - key: id
70
+ required: true
71
+ add_album:
72
+ method: get
73
+ params:
74
+ - key: cmd
75
+ value: addAlbum
76
+ - key: id
77
+ required: true
78
+ del_artist:
79
+ method: get
80
+ params:
81
+ - key: cmd
82
+ value: delArtist
83
+ - key: id
84
+ required: true
85
+ pause_artist:
86
+ method: get
87
+ params:
88
+ - key: cmd
89
+ value: pauseArtist
90
+ - key: id
91
+ required: true
92
+ resume_artist:
93
+ method: get
94
+ params:
95
+ - key: cmd
96
+ value: resumeArtist
97
+ - key: id
98
+ required: true
99
+ refresh_artist:
100
+ method: get
101
+ params:
102
+ - key: cmd
103
+ value: refreshArtist
104
+ - key: id
105
+ required: true
106
+ queue_album:
107
+ method: get
108
+ params:
109
+ - key: cmd
110
+ value: queueAlbum
111
+ - key: id
112
+ required: true
113
+ - key: new
114
+ required: false
115
+ - key: lossless
116
+ required: false
117
+ unqueue_album:
118
+ method: get
119
+ params:
120
+ - key: cmd
121
+ value: unqueueAlbum
122
+ - key: id
123
+ required: true
124
+ force_search:
125
+ method: get
126
+ params:
127
+ - key: cmd
128
+ value: forceSearch
129
+ force_process:
130
+ method: get
131
+ params:
132
+ - key: cmd
133
+ value: forceProcess
134
+ - key: dir
135
+ required: false
136
+ force_active_artists_update:
137
+ method: get
138
+ params:
139
+ - key: cmd
140
+ value: forceActiveArtistsUpdate
141
+ get_version:
142
+ method: get
143
+ params:
144
+ - key: cmd
145
+ value: getVersion
146
+ check_github:
147
+ method: get
148
+ params:
149
+ - key: cmd
150
+ value: checkGithub
151
+ shutdown:
152
+ method: get
153
+ params:
154
+ - key: cmd
155
+ value: shutdown
156
+ restart:
157
+ method: get
158
+ params:
159
+ - key: cmd
160
+ value: restart
161
+ update:
162
+ method: get
163
+ params:
164
+ - key: cmd
165
+ value: update
166
+ get_artist_art:
167
+ method: get
168
+ params:
169
+ - key: cmd
170
+ value: getArtistArt
171
+ - key: id
172
+ required: true
173
+ get_artist_info:
174
+ method: get
175
+ params:
176
+ - key: cmd
177
+ value: getArtistInfo
178
+ - key: id
179
+ required: true
180
+ get_album_info:
181
+ method: get
182
+ params:
183
+ - key: cmd
184
+ value: getAlbumInfo
185
+ - key: id
186
+ required: true
187
+ get_artist_thumb:
188
+ method: get
189
+ params:
190
+ - key: cmd
191
+ value: getArtistThumb
192
+ - key: id
193
+ required: true
194
+ get_album_thumb:
195
+ method: get
196
+ params:
197
+ - key: cmd
198
+ value: getAlbumThumb
199
+ - key: id
200
+ required: true
201
+ choose_specific_download:
202
+ method: get
203
+ params:
204
+ - key: cmd
205
+ value: choose_specific_download
206
+ - key: id
207
+ required: true
208
+ download_specific_release:
209
+ method: get
210
+ params:
211
+ - key: cmd
212
+ value: download_specific_release
213
+ - key: id
214
+ required: true
215
+ - key: title
216
+ required: true
217
+ - key: size
218
+ required: true
219
+ - key: url
220
+ required: true
221
+ - key: provider
222
+ required: true
223
+ - key: kind
224
+ required: true
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'hphones/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'hphones-ruby'
9
+ spec.version = Hphones::VERSION
10
+ spec.authors = ['Tyler Guillen']
11
+ spec.email = ['tyguillen@gmail.com']
12
+
13
+ spec.summary = 'A Ruby wrapper for the Headphones API.'
14
+ spec.description = 'A Ruby wrapper for the Headphones API.'
15
+ spec.homepage = 'https://github.com/aastronautss/hphones-ruby'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_runtime_dependency 'faraday'
26
+ spec.add_runtime_dependency 'hashie'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.16'
29
+ spec.add_development_dependency 'dotenv'
30
+ spec.add_development_dependency 'pry'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
33
+ end
data/lib/hphones.rb ADDED
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hphones/version'
4
+ require 'hphones/endpoint'
5
+ require 'hphones/request'
6
+ require 'hphones/response'
7
+
8
+ require 'faraday'
9
+
10
+ ##
11
+ # Base class for Hphones. Contains API data and acts as a central place to call methods on.
12
+ #
13
+ class Hphones
14
+ # The root path of the Headphones API.
15
+ ROOT_PATH = 'api'
16
+
17
+ attr_reader :api_key
18
+
19
+ # @param host [String] the hostname of the Headphones server
20
+ # @param port [String, Integer] the port of the Headphones server
21
+ # @param api_key [String] the API key generated by Headphones
22
+ # @param protocol [String] the protocol being used (usually 'http' or 'https')
23
+ # @param http_root [String] the optional root path set in Headphones
24
+ def initialize(host:, port:, api_key:, protocol: 'http', http_root: nil)
25
+ @host = host
26
+ @port = port
27
+ @protocol = protocol
28
+ @http_root = decorate_http_root(http_root)
29
+
30
+ @api_key = api_key
31
+ end
32
+
33
+ # Connection and URL stuff
34
+
35
+ def connection
36
+ @connection ||= Faraday.new(url: url)
37
+ end
38
+
39
+ def url
40
+ @url ||= "#{protocol}://#{host}:#{port}"
41
+ end
42
+
43
+ def base_path
44
+ @base_path ||= "#{http_root}/#{ROOT_PATH}"
45
+ end
46
+
47
+ # Methods to pass to Endpoint
48
+
49
+ def method_missing(mth, *args, &blk)
50
+ return fetch_from_endpoint(mth, *args) if lookup_endpoint(mth)
51
+
52
+ super
53
+ end
54
+
55
+ def respond_to_missing?(mth)
56
+ !!lookup_endpoint(mth) || super
57
+ end
58
+
59
+ private
60
+
61
+ attr_reader :host, :port, :protocol, :http_root
62
+
63
+ def lookup_endpoint(endpoint)
64
+ Endpoint.lookup endpoint
65
+ end
66
+
67
+ def fetch_from_endpoint(endpoint, params = {})
68
+ Endpoint.new(endpoint, self, params).fetch
69
+ end
70
+
71
+ def decorate_http_root(http_root)
72
+ if http_root =~ %r{^\/} || http_root.nil?
73
+ http_root
74
+ else
75
+ "/#{http_root}"
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'hashie/mash'
5
+
6
+ class Hphones
7
+ ##
8
+ # Stores information for endpoints.
9
+ #
10
+ class Endpoint
11
+ class MissingParameterError < StandardError; end
12
+
13
+ # The path to the endpoints file.
14
+ ENDPOINTS_PATH = File.join('data', 'endpoints.yml')
15
+
16
+ class << self
17
+ def lookup(key)
18
+ !endpoints[key.to_s].nil?
19
+ end
20
+
21
+ def endpoints
22
+ @endpoints ||= load_endpoints_from_file
23
+ end
24
+
25
+ private
26
+
27
+ def load_endpoints_from_file
28
+ YAML.load_file ENDPOINTS_PATH
29
+ end
30
+ end
31
+
32
+ def initialize(key, api, params = {})
33
+ @key = key.to_s
34
+ @api = api
35
+ @params = Hashie::Mash.new params
36
+ end
37
+
38
+ def fetch
39
+ api_params = compile_params
40
+ req = Hphones::Request.new(api)
41
+ req.send endpoint_info['method'], api_params
42
+ end
43
+
44
+ private
45
+
46
+ attr_reader :key, :api, :params
47
+
48
+ def endpoint_info
49
+ @endpoint_info ||= self.class.endpoints[key]
50
+ end
51
+
52
+ def compile_params
53
+ param_specs = endpoint_info['params']
54
+ pairs = param_specs.map { |spec| compile_pair spec }
55
+ Hash[pairs.compact]
56
+ end
57
+
58
+ def compile_pair(spec)
59
+ spec['value'] ? default_pair_for(spec) : merged_pair_for(spec)
60
+ end
61
+
62
+ def default_pair_for(spec)
63
+ [spec['key'], spec['value']]
64
+ end
65
+
66
+ def merged_pair_for(spec)
67
+ key = spec['key']
68
+ spec['required'] ? required_pair_for(key) : optional_pair_for(key)
69
+ end
70
+
71
+ def required_pair_for(key)
72
+ params[key] ? [key, params[key]] : raise(MissingParameterError, "Parameter missing: #{key}")
73
+ end
74
+
75
+ def optional_pair_for(key)
76
+ params[key] ? [key, params[key]] : nil
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Hphones
4
+ ##
5
+ # Represents an API request
6
+ #
7
+ class Request
8
+ attr_reader :api
9
+
10
+ def initialize(api)
11
+ @api = api
12
+ end
13
+
14
+ def get(params = {})
15
+ conn = api.connection
16
+ compiled_params = params.merge('apikey' => api.api_key)
17
+ Hphones::Response.new(conn.get(api.base_path, compiled_params))
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'hashie/mash'
5
+
6
+ class Hphones
7
+ ##
8
+ # Represents an API response
9
+ #
10
+ class Response
11
+ def initialize(http_response)
12
+ @http_response = http_response
13
+ end
14
+
15
+ def data
16
+ @data ||= parse_json http_response.body
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :http_response
22
+
23
+ def parse_json(json_str)
24
+ JSON.parse json_str
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Hphones
4
+ VERSION = '0.0.1'
5
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hphones-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tyler Guillen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dotenv
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ description: A Ruby wrapper for the Headphones API.
112
+ email:
113
+ - tyguillen@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".rubocop.yml"
121
+ - ".ruby-version"
122
+ - ".travis.yml"
123
+ - CODE_OF_CONDUCT.md
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - data/endpoints.yml
132
+ - hphones-ruby.gemspec
133
+ - lib/hphones.rb
134
+ - lib/hphones/endpoint.rb
135
+ - lib/hphones/request.rb
136
+ - lib/hphones/response.rb
137
+ - lib/hphones/version.rb
138
+ homepage: https://github.com/aastronautss/hphones-ruby
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.6.13
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: A Ruby wrapper for the Headphones API.
162
+ test_files: []