jikan.rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '098873c3d87b219dd5c77c292913347ec28d5780ac5bf46e41674e84a58e5909'
4
+ data.tar.gz: 257119827597b7ffa12b8db033a24c5941ad6d3288c63b7966be0d49ce3eb545
5
+ SHA512:
6
+ metadata.gz: 66e2efa11330d262d301f2782fae6f1ebab30b9eaa0c8bae4ce45dc54cccdaa348decec9e8c79c1d23e3379acb5eee4c4c2dee61b6d5b374be00ecade8a69190
7
+ data.tar.gz: a557f123bdc392f1f3509e0a5b3a4966b3ab8c26187ea350a79701e9ecca9bfbee24314fe6c6bf0512bbfeae670c0e78ccc397152fd9c5b1cf4f094858fadd18
@@ -0,0 +1,14 @@
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
+ # swap files
14
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -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 slaveration@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,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in jikan.gemspec
6
+ gemspec
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jikan (0.0.1)
5
+ http (~> 3.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.2)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ coderay (1.1.2)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ diff-lcs (1.3)
16
+ domain_name (0.5.20170404)
17
+ unf (>= 0.0.5, < 1.0.0)
18
+ hashdiff (0.3.7)
19
+ http (3.0.0)
20
+ addressable (~> 2.3)
21
+ http-cookie (~> 1.0)
22
+ http-form_data (>= 2.0.0.pre.pre2, < 3)
23
+ http_parser.rb (~> 0.6.0)
24
+ http-cookie (1.0.3)
25
+ domain_name (~> 0.5)
26
+ http-form_data (2.0.0)
27
+ http_parser.rb (0.6.0)
28
+ method_source (0.9.0)
29
+ pry (0.11.3)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.9.0)
32
+ public_suffix (3.0.1)
33
+ rake (10.5.0)
34
+ rspec (3.7.0)
35
+ rspec-core (~> 3.7.0)
36
+ rspec-expectations (~> 3.7.0)
37
+ rspec-mocks (~> 3.7.0)
38
+ rspec-core (3.7.1)
39
+ rspec-support (~> 3.7.0)
40
+ rspec-expectations (3.7.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.7.0)
43
+ rspec-mocks (3.7.0)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.7.0)
46
+ rspec-support (3.7.0)
47
+ safe_yaml (1.0.4)
48
+ unf (0.1.4)
49
+ unf_ext
50
+ unf_ext (0.0.7.4)
51
+ vcr (4.0.0)
52
+ webmock (3.3.0)
53
+ addressable (>= 2.3.6)
54
+ crack (>= 0.3.2)
55
+ hashdiff
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ bundler (~> 1.16)
62
+ jikan!
63
+ pry
64
+ rake (~> 10.0)
65
+ rspec (~> 3.0)
66
+ vcr
67
+ webmock
68
+
69
+ BUNDLED WITH
70
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Zerocchi
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,130 @@
1
+ # Jikan.rb
2
+
3
+ This is a thin Ruby wrapper for [jikan.me](http://jikan.me) inspired by [JikanPy](https://github.com/AWConant/jikanpy). For more information, please refer to [Jikan.ME documentation](https://jikan.me/docs).
4
+
5
+ ## Installation
6
+
7
+ **NOTE: This does not work yet until the gem is uploaded.**
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'jikan'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jikan
22
+
23
+ ## Usage
24
+
25
+ **Get anime and manga information based on their ID**
26
+
27
+ ```ruby
28
+ # https://myanimelist.net/anime/34798/Yuru_Camp
29
+ >> qry = Jikan::Query.new
30
+ => #<Jikan::Query:0x026ed9d0>
31
+
32
+ >> yurucamp = qry.anime_id 34798 # manga_id for manga
33
+ # You can also specify flag as second parameter
34
+ # >> yurucamp = qry.anime_id 34798, :episodes
35
+ # All flags are symbol, please refer https://jikan.me/docs#chaining-methods to see all available flags
36
+ => <Jikan::Anime:0x0168c4e0>
37
+
38
+ >> yurucamp.raw
39
+ =>{
40
+ "mal_id"=>34798,
41
+ "link_canonical"=>"https://myanimelist.net/anime/34798/Yuru_Camp△",
42
+ "title"=>"Yuru Camp△",
43
+ "title_english"=>"Laid-Back Camp",
44
+ "title_japanese"=>"ゆるキャン△",
45
+ "title_synonyms"=>"Yurukyan, Laid-Back Camp△",
46
+ ...
47
+ }
48
+
49
+ >> yurucamp.title
50
+ => "Yuru Camp△"
51
+
52
+ >> yurucamp.rating
53
+ => "PG-13 - Teens 13 or older"
54
+ ```
55
+
56
+ **Get character and people information based on their ID**
57
+
58
+ ```ruby
59
+ # https://myanimelist.net/character/16521/Kagome_Ikaruga
60
+ >> qry = Jikan::Query.new
61
+ => #<Jikan::Query:0x027554b8>
62
+
63
+ >> ikaruga = qry.character_id 16521
64
+ => #<Jikan::Character:0x0134b080>
65
+
66
+ >> ikaruga.raw # only raw method is available for now for both character and people
67
+ =>{
68
+ "mal_id"=>16521,
69
+ "link_canonical"=>"https://myanimelist.net/character/16521/Kagome_Ikaruga",
70
+ "name"=>"Kagome Ikaruga",
71
+ "name_kanji"=>"(斑鳩かごめ)",
72
+ "nicknames"=>"Kagome Ikaruga",
73
+ "about"=>
74
+ "10 years old and the youngest of the Ikaruga sisters. She has bigger breast than Ayame so she covers them. She seems to like Masashi.",
75
+ ...
76
+ }
77
+ ```
78
+
79
+ **Search**
80
+ ``` ruby
81
+ >> qry = Jikan::Query.new
82
+ => #<Jikan::Query:0x027d70e8>
83
+
84
+ >> railgun = qry.search("railgun", :anime) # other parameter tokens are :manga, :character, :person
85
+ => #<Jikan::Search:0x016fd760>
86
+
87
+ >> railgun.raw # only raw method is available for now
88
+ =>{"result"=>
89
+ [
90
+ {
91
+ "id"=>6213,
92
+ "url"=>"https://myanimelist.net/anime/6213/Toaru_Kagaku_no_Railgun",
93
+ "image_url"=>
94
+ "https://myanimelist.cdn-dena.com/r/100x140/images/anime/8/53581.jpg?s=4003b92ef0e723389087b69a8a08d742",
95
+ "title"=>"Toaru Kagaku no Railgun",
96
+ ...
97
+ },
98
+ {
99
+ "id"=>16049,
100
+ "url"=>"https://myanimelist.net/anime/16049/Toaru_Kagaku_no_Railgun_S",
101
+ "image_url"=>
102
+ "https://myanimelist.cdn-dena.com/r/100x140/images/anime/7/75610.jpg?s=ca85d87b5ff134c73f03184d111604c0",
103
+ "title"=>"Toaru Kagaku no Railgun S"
104
+ ...
105
+ }
106
+ ]
107
+ }
108
+ ```
109
+
110
+ ## To-Do
111
+ - [X] Add test suites
112
+ - [X] Add search feature
113
+ - [ ] Refactoring
114
+ - [X] Break down hashes into consumable classes
115
+
116
+ ## Development
117
+
118
+ 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.
119
+
120
+ ## Contributing
121
+
122
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Zerocchi/jikan.rb. 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.
123
+
124
+ ## License
125
+
126
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
127
+
128
+ ## Code of Conduct
129
+
130
+ Everyone interacting in the Jikan project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Zerocchi/jikan/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jikan"
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
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
12
+
13
+ # require "irb"
14
+ # IRB.start(__FILE__)
@@ -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,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "jikan/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jikan.rb"
8
+ spec.version = Jikan::VERSION
9
+ spec.authors = ["Zerocchi"]
10
+ spec.email = ["slaveration@gmail.com"]
11
+
12
+ spec.summary = %q{A simple Ruby wrapper for jikan.me API.}
13
+ spec.description = %q{This is a wrapper for unofficial MyAnimeList API, Jikan.me.
14
+ Consult Jikan.me documentation to learn more. }
15
+ spec.homepage = "https://github.com/Zerocchi/jikan.rb"
16
+ spec.license = "MIT"
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+ else
23
+ raise "RubyGems 2.0 or newer is required to protect against " \
24
+ "public gem pushes."
25
+ end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_runtime_dependency "http", "~> 3.0.0"
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.16"
37
+ spec.add_development_dependency "pry"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rspec", "~> 3.0"
40
+ spec.add_development_dependency "vcr"
41
+ spec.add_development_dependency "webmock"
42
+ end
@@ -0,0 +1,17 @@
1
+ require 'jikan/query'
2
+
3
+ module Jikan
4
+ class FlagError < StandardError; end
5
+ class ClientError < StandardError; end
6
+
7
+ BASE_URL = "http://api.jikan.me"
8
+ BASE_URL_SSL = "https://api.jikan.me"
9
+
10
+ FLAGS = {
11
+ 'anime' => [ :episodes, :characters_staff, :news, :pictures, :videos, :stats ],
12
+ 'manga' => [ :character, :news, :pictures, :stats ],
13
+ 'character' => [ :pictures ],
14
+ 'person' => [ :pictures ],
15
+ 'search' => [:anime, :manga, :person, :character]
16
+ }
17
+ end
@@ -0,0 +1,66 @@
1
+ require 'jikan/entity'
2
+
3
+ module Jikan
4
+ class Anime < MediaEntity
5
+
6
+ def aired
7
+ raw['aired']
8
+ end
9
+
10
+ def adaptation
11
+ raw['related']['adaptation']
12
+ end
13
+
14
+ def background
15
+ raw['background']
16
+ end
17
+
18
+ def broadcast
19
+ raw['broadcast']
20
+ end
21
+
22
+ def duration
23
+ raw['duration']
24
+ end
25
+
26
+ def ending
27
+ raw['ending-theme']
28
+ end
29
+
30
+ def episodes
31
+ raw['episodes']
32
+ end
33
+
34
+ def eps_list
35
+ raw['episode']
36
+ end
37
+
38
+ def licensor
39
+ raw['licensor']
40
+ end
41
+
42
+ def opening
43
+ raw['opening-theme']
44
+ end
45
+
46
+ def premiered
47
+ raw['premiered']
48
+ end
49
+
50
+ def producer
51
+ raw['producer']
52
+ end
53
+
54
+ def related
55
+ raw['related']
56
+ end
57
+
58
+ def side_story
59
+ raw['side_story']
60
+ end
61
+
62
+ def studio
63
+ raw['studio']
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,55 @@
1
+ require "http"
2
+ require "json"
3
+
4
+ module Jikan
5
+ class API
6
+
7
+ def initialize(use_ssl=true)
8
+ @endpoint = ""
9
+ @id = nil
10
+ @flag = nil
11
+ @selected_base = if use_ssl then Jikan::BASE_URL_SSL else Jikan::BASE_URL end
12
+ end
13
+
14
+ def get(endpoint, id, flag=nil, qry='')
15
+ @endpoint = endpoint
16
+ @id = id
17
+ @flag = flag
18
+ @query = qry
19
+
20
+ construct_url
21
+ get_data
22
+ end
23
+
24
+ private
25
+
26
+ def construct_url
27
+ @end_url = "#{@selected_base}/#{@endpoint}"
28
+ @url = "#{@end_url}/#{@id}"
29
+
30
+ if @endpoint.eql?('search')
31
+ unless Jikan::FLAGS[@endpoint].include? @flag
32
+ raise Jikan::FlagError, 'Flag not supported'
33
+ else
34
+ @url = "#{@end_url}/#{@flag.to_s}/#{@query}/#{@id}"
35
+ end
36
+ end
37
+
38
+ unless @flag.nil? || @endpoint.eql?('search')
39
+ unless Jikan::FLAGS[@endpoint].include? @flag
40
+ raise Jikan::FlagError, 'Flag not supported'
41
+ end
42
+ @url << "/#{@flag.to_s}"
43
+ end
44
+ end
45
+
46
+ def get_data
47
+ res = HTTP.get(@url)
48
+ if res.status >= 400
49
+ raise ClientError, "#{res.status}: error on endpoint #{@endpoint}"
50
+ end
51
+
52
+ JSON.parse(res.body)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module Jikan
2
+ class Character < BaseEntity
3
+
4
+ end
5
+ end
@@ -0,0 +1,86 @@
1
+ module Jikan
2
+ class BaseEntity
3
+
4
+ attr_reader :raw
5
+
6
+ def initialize(json)
7
+ @raw = json
8
+ end
9
+
10
+ end
11
+
12
+ class MediaEntity < BaseEntity
13
+
14
+ def favorites
15
+ raw['favorites']
16
+ end
17
+
18
+ def genre
19
+ raw['genre']
20
+ end
21
+
22
+ def image
23
+ raw['image']
24
+ end
25
+
26
+ def members
27
+ raw['members']
28
+ end
29
+
30
+ def popularity
31
+ raw['popularity']
32
+ end
33
+
34
+ def ranked
35
+ raw['ranked']
36
+ end
37
+
38
+ def rating
39
+ raw['rating']
40
+ end
41
+
42
+ def status
43
+ raw['status']
44
+ end
45
+
46
+ def score
47
+ raw['score']
48
+ end
49
+
50
+ def source
51
+ raw['source']
52
+ end
53
+
54
+ def synonyms
55
+ raw['synonyms']
56
+ end
57
+
58
+ def synopsis
59
+ raw['synopsis']
60
+ end
61
+
62
+ def link
63
+ raw['link_canonical']
64
+ end
65
+
66
+ def title
67
+ raw['title']
68
+ end
69
+
70
+ def title_en
71
+ raw['title_english']
72
+ end
73
+
74
+ def title_jp
75
+ raw['japanese']
76
+ end
77
+
78
+ def title_synonyms
79
+ raw['title_synonyms']
80
+ end
81
+
82
+ def type
83
+ raw['type']
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,21 @@
1
+ module Jikan
2
+ class Manga < MediaEntity
3
+
4
+ def author
5
+ raw['author']
6
+ end
7
+
8
+ def chapters
9
+ raw['chapters']
10
+ end
11
+
12
+ def published
13
+ raw['published']
14
+ end
15
+
16
+ def volumes
17
+ raw['volumes']
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ module Jikan
2
+ class Person < BaseEntity
3
+
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ require 'jikan/anime'
2
+ require 'jikan/api'
3
+ require 'jikan/character'
4
+ require 'jikan/manga'
5
+ require 'jikan/person'
6
+ require 'jikan/search'
7
+
8
+ module Jikan
9
+ class Query
10
+
11
+ def initialize
12
+ @json = nil
13
+ end
14
+
15
+ def anime_id(id, flag=nil)
16
+ @json = Jikan::API.new.get("anime", id, flag)
17
+ Jikan::Anime.new(@json)
18
+ end
19
+
20
+ def manga_id(id, flag=nil)
21
+ @json = Jikan::API.new.get("manga", id, flag)
22
+ Jikan::Manga.new(@json)
23
+ end
24
+
25
+ def character_id(id, flag=nil)
26
+ @json = Jikan::API.new.get("character", id, flag)
27
+ Jikan::Character.new(@json)
28
+ end
29
+
30
+ def person_id(id, flag=nil)
31
+ @json = Jikan::API.new.get("person", id, flag)
32
+ Jikan::Person.new(@json)
33
+ end
34
+
35
+ def search(title, type=:anime, page=1)
36
+ @json = Jikan::API.new.get("search", page, type, title)
37
+ Jikan::Search.new(@json)
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,24 @@
1
+ module Jikan
2
+ class Search < BaseEntity
3
+
4
+ def id
5
+ iter('id')
6
+ end
7
+
8
+ def title
9
+ iter('title')
10
+ end
11
+
12
+ def url
13
+ iter('url')
14
+ end
15
+
16
+ private
17
+
18
+ def iter(key)
19
+ @raw['result'].map do |item|
20
+ item[key]
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module Jikan
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jikan.rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Zerocchi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
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.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: "This is a wrapper for unofficial MyAnimeList API, Jikan.me. \n Consult
112
+ Jikan.me documentation to learn more. "
113
+ email:
114
+ - slaveration@gmail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - jikan.gemspec
131
+ - lib/jikan.rb
132
+ - lib/jikan/anime.rb
133
+ - lib/jikan/api.rb
134
+ - lib/jikan/character.rb
135
+ - lib/jikan/entity.rb
136
+ - lib/jikan/manga.rb
137
+ - lib/jikan/person.rb
138
+ - lib/jikan/query.rb
139
+ - lib/jikan/search.rb
140
+ - lib/jikan/version.rb
141
+ homepage: https://github.com/Zerocchi/jikan.rb
142
+ licenses:
143
+ - MIT
144
+ metadata:
145
+ allowed_push_host: https://rubygems.org
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.7.3
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: A simple Ruby wrapper for jikan.me API.
166
+ test_files: []