songlink 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aa1ac77f4b0749c9bd18cc382f49f77f44d9fa0b549ba8e0e8118c89cefba869
4
+ data.tar.gz: 61d378d93023c2916e529af88018b6345272fddc6d3bcee37fa23d97a7422bda
5
+ SHA512:
6
+ metadata.gz: 5d1c0b41599b78a2fca038acb2536bb4229ee9f0217a4e7f211178d73af0ec7c245815a73f8c11c5be74725fdbaf4a46fec8e82c560b6b3ad870e693e8999d5f
7
+ data.tar.gz: 25a8b81db3c45f9a64382887e33793768c03c1814cafd5cbc75b06472e900b349dcd2c4fbc7c22d7f3c9453c3100196cd748583276c1534aca13d7965ecff165
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ vendor/
10
+ Gemfile.lock
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,43 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ Exclude:
4
+ - spec/**/*
5
+ - vendor/**/*
6
+ Style/Documentation:
7
+ Enabled: false
8
+
9
+ Style/AccessModifierDeclarations:
10
+ EnforcedStyle: inline
11
+
12
+ Layout/EmptyLinesAroundAttributeAccessor:
13
+ Enabled: true
14
+
15
+ Layout/SpaceAroundMethodCallOperator:
16
+ Enabled: true
17
+
18
+ Lint/DeprecatedOpenSSLConstant:
19
+ Enabled: true
20
+
21
+ Lint/RaiseException:
22
+ Enabled: true
23
+
24
+ Lint/StructNewOverride:
25
+ Enabled: true
26
+
27
+ Style/ExponentialNotation:
28
+ Enabled: true
29
+
30
+ Style/HashEachMethods:
31
+ Enabled: true
32
+
33
+ Style/HashTransformKeys:
34
+ Enabled: true
35
+
36
+ Style/HashTransformValues:
37
+ Enabled: true
38
+
39
+ Style/SlicingWithRange:
40
+ Enabled: true
41
+
42
+ Metrics/MethodLength:
43
+ Max: 15
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5
5
+ - 2.6
6
+ - 2.7
7
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in songlink.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Hondallica
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.
@@ -0,0 +1,47 @@
1
+ # Songlink
2
+
3
+ Songlink API client library.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'songlink'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install songlink
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'songlink'
25
+
26
+ songlink = Songlink.new
27
+ res = songlink.request({ url: 'spotify:track:0BKR0dFPDmhREewiiqGArC', userCountry: 'JP' })
28
+ ```
29
+
30
+ ### Setting API key
31
+ API key is optional.
32
+
33
+ Please refer to the [official API documentation](https://github.com/songlink/docs/blob/master/api-v1-alpha.1.md) on how to get API key.
34
+
35
+ ```ruby
36
+ songlink = Songlink.new('your_api_key')
37
+ ```
38
+
39
+ If environment variable SONGLINK_API_KEY is set in .bash_profile etc, no argument is necessary.
40
+
41
+ ```
42
+ export SONGLINK_API_KEY=your_api_key
43
+ ```
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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
@@ -0,0 +1,42 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ Exclude:
4
+ - spec/**/*
5
+ Style/Documentation:
6
+ Enabled: false
7
+
8
+ Style/MethodLength:
9
+ Max: 15
10
+
11
+ Style/AccessModifierDeclarations:
12
+ EnforcedStyle: inline
13
+
14
+ Layout/EmptyLinesAroundAttributeAccessor:
15
+ Enabled: true
16
+
17
+ Layout/SpaceAroundMethodCallOperator:
18
+ Enabled: true
19
+
20
+ Lint/DeprecatedOpenSSLConstant:
21
+ Enabled: true
22
+
23
+ Lint/RaiseException:
24
+ Enabled: true
25
+
26
+ Lint/StructNewOverride:
27
+ Enabled: true
28
+
29
+ Style/ExponentialNotation:
30
+ Enabled: true
31
+
32
+ Style/HashEachMethods:
33
+ Enabled: true
34
+
35
+ Style/HashTransformKeys:
36
+ Enabled: true
37
+
38
+ Style/HashTransformValues:
39
+ Enabled: true
40
+
41
+ Style/SlicingWithRange:
42
+ Enabled: true
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'songlink'
6
+ require 'pry'
7
+
8
+ Pry.start
@@ -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,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'songlink/version'
4
+ require 'songlink/request'
5
+
6
+ class Songlink
7
+ include Version
8
+ include Request
9
+ attr_accessor :api_key, :url, :version, :api_version
10
+
11
+ def initialize(api_key = ENV['SONGLINK_API_KEY'])
12
+ @version = Version.version
13
+ @api_version = Version.api_version
14
+ @api_key = api_key
15
+ @url = Request.base_url
16
+ end
17
+
18
+ def request(params = {})
19
+ http.get("/#{api_version}/links", _params(params))
20
+ end
21
+
22
+ def _params(params)
23
+ params['key'] = @api_key
24
+ params['format'] = 'json'
25
+ params
26
+ end
27
+ private :_params
28
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+
6
+ module Request
7
+ def base_url(url = 'https://api.song.link')
8
+ url
9
+ end
10
+
11
+ def http
12
+ Faraday.new(url: base_url) do |f|
13
+ f.response :mashify
14
+ f.response :json
15
+ f.request :url_encoded
16
+ f.request :retry, max: 5, interval: 1.0
17
+ f.options[:open_timeout] = 2
18
+ f.options[:timeout] = 5
19
+ f.headers['Accept'] = 'application/json'
20
+ f.headers['User-Agent'] = "ruby-songlink/#{version}"
21
+ f.adapter :net_http
22
+ end
23
+ end
24
+
25
+ module_function :base_url
26
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Version
4
+ def version
5
+ '0.1.0'
6
+ end
7
+
8
+ def api_version(api_version = 'v1-alpha.1')
9
+ api_version
10
+ end
11
+
12
+ module_function :version, :api_version
13
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/songlink/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'songlink'
7
+ spec.version = Version.version
8
+ spec.authors = ['Hondallica']
9
+ spec.email = ['hondallica@gmail.com']
10
+
11
+ spec.summary = 'songlink API client library'
12
+ spec.homepage = 'https://github.com/hondallica/ruby-songlink'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = spec.homepage
18
+
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_dependency 'faraday', '~> 1.0.1'
27
+ spec.add_dependency 'faraday_middleware', '~> 1.0.0'
28
+ spec.add_dependency 'hashie', '~> 4.1.0'
29
+
30
+ spec.add_development_dependency 'bundler', '~>2.1.4'
31
+ spec.add_development_dependency 'pry', '~> 0.13.1'
32
+ spec.add_development_dependency 'rake', '~> 13.0.1'
33
+ spec.add_development_dependency 'rspec', '~> 3.9.0'
34
+ spec.add_development_dependency 'rubocop', '~> 0.84.0'
35
+ spec.add_development_dependency 'webmock', '~> 3.8.3'
36
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: songlink
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hondallica
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-30 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: 1.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.1.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.1.4
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.13.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.13.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 13.0.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 13.0.1
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.9.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.9.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.84.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.84.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 3.8.3
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 3.8.3
139
+ description:
140
+ email:
141
+ - hondallica@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".rubocop.yml"
149
+ - ".travis.yml"
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/.rubocop.yml
155
+ - bin/console
156
+ - bin/setup
157
+ - lib/songlink.rb
158
+ - lib/songlink/request.rb
159
+ - lib/songlink/version.rb
160
+ - songlink.gemspec
161
+ homepage: https://github.com/hondallica/ruby-songlink
162
+ licenses:
163
+ - MIT
164
+ metadata:
165
+ homepage_uri: https://github.com/hondallica/ruby-songlink
166
+ source_code_uri: https://github.com/hondallica/ruby-songlink
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: 2.5.0
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubygems_version: 3.1.2
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: songlink API client library
186
+ test_files: []