ruby_sokmil 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2f10d56b017ef650cfc1a7563e8038aa5ff0d50d4009c109e1e79fb510c5ec2d
4
+ data.tar.gz: 28ce8d930e4b45705b6ce512fde853e4ce37df631cc744926171cd890e976096
5
+ SHA512:
6
+ metadata.gz: 3bdb733e1e097f5a7dbe25389ef1f02135a194d95879eb5fe6316c7a903f2d97e1d23c8a1d39309104bf05c29371005c8ed70e8f964e197c7c448b1147530fe1
7
+ data.tar.gz: 54b0b573cb2dcbf9caac7560483bdbcef6f15c8a22e998754fce6e55a158a4cbc6793970f73276db89e9aff97437494a49259ba80b736d22e655e34591511214
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Style/FrozenStringLiteralComment:
19
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-05-12
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ruby_sokmil.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby_sokmil (0.1.0)
5
+ faraday
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ faraday (2.7.4)
12
+ faraday-net_http (>= 2.0, < 3.1)
13
+ ruby2_keywords (>= 0.0.4)
14
+ faraday-net_http (3.0.2)
15
+ json (2.6.3)
16
+ minitest (5.18.0)
17
+ parallel (1.23.0)
18
+ parser (3.2.2.1)
19
+ ast (~> 2.4.1)
20
+ rainbow (3.1.1)
21
+ rake (13.0.6)
22
+ regexp_parser (2.8.0)
23
+ rexml (3.2.5)
24
+ rubocop (1.50.2)
25
+ json (~> 2.3)
26
+ parallel (~> 1.10)
27
+ parser (>= 3.2.0.0)
28
+ rainbow (>= 2.2.2, < 4.0)
29
+ regexp_parser (>= 1.8, < 3.0)
30
+ rexml (>= 3.2.5, < 4.0)
31
+ rubocop-ast (>= 1.28.0, < 2.0)
32
+ ruby-progressbar (~> 1.7)
33
+ unicode-display_width (>= 2.4.0, < 3.0)
34
+ rubocop-ast (1.28.1)
35
+ parser (>= 3.2.1.0)
36
+ ruby-progressbar (1.13.0)
37
+ ruby2_keywords (0.0.5)
38
+ unicode-display_width (2.4.2)
39
+
40
+ PLATFORMS
41
+ x86_64-linux
42
+
43
+ DEPENDENCIES
44
+ minitest (~> 5.0)
45
+ rake (~> 13.0)
46
+ rubocop (~> 1.21)
47
+ ruby_sokmil!
48
+
49
+ BUNDLED WITH
50
+ 2.4.10
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 duga_bot
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,70 @@
1
+ # RubySokmil
2
+
3
+ TODO: Delete this and the text below, and describe your gem
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/ruby_sokmil`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `ruby_sokmil` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add ruby_sokmil
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install ruby_sokmil
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ cli = RubySokmil.new(app_key: "YOUR_APP_KEY", affiliate_id: "YOUR_AFFILIATE_ID")
23
+ response = cli.item(keyword: "杉原杏璃", category: 'idol')
24
+ response.body[:result][:items].map {|x| x[:title]}
25
+ =>
26
+ ["Last Kiss ~杉原杏璃ファイナルイメージ 杉原杏璃",
27
+ "東京アンリ 杉原杏璃",
28
+ "となりのアンリ 杉原杏璃",
29
+ "白珠杏蜜 杉原杏璃",
30
+ "アンリ先生 杉原杏璃",
31
+ "フェアリー・テール 杉原杏璃",
32
+ "なまアンリ、ゆめアンリ 杉原杏璃",
33
+ "アンリの日記 杉原杏璃",
34
+ "必撮!まるごと☆杉原杏璃2",
35
+ "杏乳 杉原杏璃",
36
+ "ヤングマガジンDVD 透覗 See Through Mode 杉原杏璃",
37
+ "杏limited 杉原杏璃",
38
+ "亜細亜の恋 杉原杏璃",
39
+ "夢の世界へ 杉原杏璃",
40
+ "杏璃~夏ものがたり 杉原杏璃",
41
+ "じーっとみつめて・・・ 杉原杏璃",
42
+ "必撮!まるごと☆杉原杏璃",
43
+ "ボクのアンリ 杉原杏璃",
44
+ "アンブロシア ~美味しいアンリ 杉原杏璃",
45
+ "みすど mis*dol 杉原杏璃2",
46
+ "杏Lover 杉原杏璃",
47
+ "みすど mis*dol 杉原杏璃",
48
+ "本当にデカップ 杉原杏璃",
49
+ "杏Sweet 杉原杏璃",
50
+ "杏璃色 杉原杏璃",
51
+ "「杏蜜」 ~An-mitsu~ 杉原杏璃"]
52
+ ```
53
+
54
+ Refer to [Sokmil site](https://sokmil-ad.com/member/api) for API details.
55
+
56
+ Now the APIs for Item, Maker, Label, Series, Genre, Director and Actor are supported. As of May 12, 2023, Label and Series seem not working due to "DATABASE ERROR".
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dugabot0/ruby_sokmil.
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
@@ -0,0 +1,59 @@
1
+ require "faraday"
2
+ require_relative "response"
3
+ require_relative "version"
4
+
5
+ module RubySokmil
6
+ class Client
7
+ BASE_URL = "https://sokmil-ad.com/api/v1/".freeze
8
+ DEFAULT_AFFILIATE_ID = "20131-001".freeze
9
+
10
+ def initialize(options = {})
11
+ @api_key = (ENV["SOKMIL_API_ID"] || options[:api_key])
12
+ @affiliate_id = (ENV["SOKMIL_AFFILIATE_ID"] || options[:affiliate_id] || DEFAULT_AFFILIATE_ID)
13
+ end
14
+
15
+ API_MAP = {
16
+ item: "Item", # 商品検索
17
+ maker: "Maker", # メーカー検索
18
+ label: "Label", # レーベル検索
19
+ series: "Series", # シリーズ検索
20
+ genre: "Genre", # ジャンル検索
21
+ director: "Director", # 監督検索
22
+ actor: "Actor" # 出演者検索
23
+ }.freeze
24
+
25
+ API_MAP.each do |method, path|
26
+ define_method method do |params = {}|
27
+ get(path, must.merge(params))
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def must
34
+ {
35
+ api_key: @api_key,
36
+ affiliate_id: @affiliate_id,
37
+ output: "json"
38
+ }
39
+ end
40
+
41
+ def get(path, options = {})
42
+ Response.new(connection.get(path, options))
43
+ end
44
+
45
+ def connection
46
+ @connection ||= Faraday.new(faraday_options) do |faraday|
47
+ faraday.adapter :net_http
48
+ faraday.request :url_encoded
49
+ faraday.response :json
50
+ end
51
+ end
52
+
53
+ def faraday_options
54
+ {
55
+ url: BASE_URL
56
+ }
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,23 @@
1
+ require "active_support/core_ext/hash/keys"
2
+
3
+ module RubySokmil
4
+ class Response
5
+ def initialize(faraday_response)
6
+ @original_response = faraday_response
7
+ end
8
+
9
+ attr_reader :original_response
10
+
11
+ def body
12
+ @body ||= original_response.body.deep_symbolize_keys
13
+ end
14
+
15
+ def headers
16
+ original_response.headers
17
+ end
18
+
19
+ def status
20
+ original_response.status
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubySokmil
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ruby_sokmil/version"
4
+ require_relative "ruby_sokmil/client"
5
+
6
+ module RubySokmil
7
+ class Error < StandardError; end
8
+
9
+ def self.new(options = {})
10
+ RubySokmil::Client.new(options)
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ module RubySokmil
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_sokmil
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - duga_bot
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-05-12 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
+ description: Client for the Sokmil Web Service API
28
+ email:
29
+ - duga_bot@pm.me
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rubocop.yml"
35
+ - CHANGELOG.md
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - lib/ruby_sokmil.rb
42
+ - lib/ruby_sokmil/client.rb
43
+ - lib/ruby_sokmil/response.rb
44
+ - lib/ruby_sokmil/version.rb
45
+ - sig/ruby_sokmil.rbs
46
+ homepage: https://github.com/dugabot0/ruby_sokmil
47
+ licenses:
48
+ - MIT
49
+ metadata:
50
+ homepage_uri: https://github.com/dugabot0/ruby_sokmil
51
+ source_code_uri: https://github.com/dugabot0/ruby_sokmil
52
+ changelog_uri: https://github.com/dugabot0/ruby_sokmil
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.3.20
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Client for the Sokmil Web Service API
72
+ test_files: []