Anilistrb 0.1.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: c37a6753d90d70d087b38858e589abce6689a838143b3ff2852f6a3ef6b72a3d
4
+ data.tar.gz: 462513dd66c5238b157f5430cff80cde02d9145c86bc67e8f7e6990019289dcd
5
+ SHA512:
6
+ metadata.gz: 7add3af6ab606fc248ae43b7470288725d824718e46abdfd1a62c29f2c5da7fb8706fb51ee2ad891a0fd5078ee96bbf17c1735b2196c86b38019df64b4ba36f1
7
+ data.tar.gz: fdba066e48d239829c198ffebcc5d885d4b92de029e58ad83a45966a48e3ceae435efeec723f7159db72c56cdd801bbd773649f0355d374cb395611269990ccc
@@ -0,0 +1 @@
1
+ FROM ruby:2.6.1-alpine3.8
@@ -0,0 +1,12 @@
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
+ *.gem
@@ -0,0 +1,13 @@
1
+ image: ruby:2.6.1-alpine3.8
2
+
3
+ cache:
4
+ paths:
5
+ - vendor/
6
+
7
+ before_script:
8
+ - bundle install --path vendor
9
+
10
+ deploy:
11
+ stage: deploy
12
+ script:
13
+ - bundle exec rake
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,60 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Layout/AlignHash:
5
+ Enabled: false
6
+
7
+ Layout/EndOfLine:
8
+ Enabled: false
9
+
10
+ Layout/LeadingCommentSpace:
11
+ Enabled: false
12
+
13
+ Layout/TrailingWhitespace:
14
+ Enabled: false
15
+
16
+ Layout/SpaceInsideArrayLiteralBrackets:
17
+ Enabled: false
18
+
19
+ Metrics/BlockLength:
20
+ Max: 30
21
+
22
+ Metrics/CyclomaticComplexity:
23
+ Max: 10
24
+
25
+ Metrics/LineLength:
26
+ Max: 90
27
+
28
+ Metrics/MethodLength:
29
+ Max: 25
30
+
31
+ Naming/FileName:
32
+ Enabled: false
33
+
34
+ Naming/VariableName:
35
+ Enabled: false
36
+
37
+ Naming/UncommunicativeMethodParamName:
38
+ Enabled: false
39
+
40
+ Style/BracesAroundHashParameters:
41
+ Enabled: false
42
+
43
+ Style/Documentation:
44
+ Enabled: false
45
+
46
+ Style/ExpandPathArguments:
47
+ Enabled: false
48
+
49
+ Style/FrozenStringLiteralComment:
50
+ Enabled: false
51
+
52
+ Style/HashSyntax:
53
+ Exclude:
54
+ - 'Rakefile'
55
+
56
+ Style/NumericLiterals:
57
+ Enabled: false
58
+
59
+ Style/RedundantSelf:
60
+ Enabled: false
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'Anilistrb/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'Anilistrb'
7
+ spec.version = Anilistrb::VERSION
8
+ spec.authors = ['barrettotte']
9
+ spec.email = ['barrettotte@gmail.com']
10
+ spec.summary = 'A simple API wrapper for AniList\'s GraphQL API'
11
+ spec.description = 'A simple API wrapper for AniList\'s GraphQL API'
12
+ spec.homepage = 'https://github.com/barrettotte/Anilist-Ruby'
13
+ spec.license = 'MIT'
14
+
15
+ if spec.respond_to?(:metadata)
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+ else
18
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
19
+ 'public gem pushes.'
20
+ end
21
+
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.required_ruby_version = '>= 2.6'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.17'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ spec.add_development_dependency 'rubocop', '~> 0.65.0'
36
+
37
+ spec.add_runtime_dependency 'httparty', '>= 0.13.7'
38
+ spec.add_runtime_dependency 'json', '>= 2.2'
39
+ end
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ Anilistrb (0.1.0)
5
+ httparty (>= 0.13.7)
6
+ json (>= 2.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.0)
12
+ diff-lcs (1.3)
13
+ httparty (0.16.4)
14
+ mime-types (~> 3.0)
15
+ multi_xml (>= 0.5.2)
16
+ jaro_winkler (1.5.2)
17
+ json (2.2.0)
18
+ mime-types (3.2.2)
19
+ mime-types-data (~> 3.2015)
20
+ mime-types-data (3.2018.0812)
21
+ multi_xml (0.6.0)
22
+ parallel (1.14.0)
23
+ parser (2.6.0.0)
24
+ ast (~> 2.4.0)
25
+ powerpack (0.1.2)
26
+ psych (3.1.0)
27
+ rainbow (3.0.0)
28
+ rake (10.5.0)
29
+ rspec (3.8.0)
30
+ rspec-core (~> 3.8.0)
31
+ rspec-expectations (~> 3.8.0)
32
+ rspec-mocks (~> 3.8.0)
33
+ rspec-core (3.8.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-expectations (3.8.2)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.8.0)
38
+ rspec-mocks (3.8.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.8.0)
41
+ rspec-support (3.8.0)
42
+ rubocop (0.65.0)
43
+ jaro_winkler (~> 1.5.1)
44
+ parallel (~> 1.10)
45
+ parser (>= 2.5, != 2.5.1.1)
46
+ powerpack (~> 0.1)
47
+ psych (>= 3.1.0)
48
+ rainbow (>= 2.2.2, < 4.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (~> 1.4.0)
51
+ ruby-progressbar (1.10.0)
52
+ unicode-display_width (1.4.1)
53
+
54
+ PLATFORMS
55
+ x64-mingw32
56
+
57
+ DEPENDENCIES
58
+ Anilistrb!
59
+ bundler (~> 1.17)
60
+ rake (~> 10.0)
61
+ rspec (~> 3.0)
62
+ rubocop (~> 0.65.0)
63
+
64
+ BUNDLED WITH
65
+ 1.17.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 barrettotte
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,60 @@
1
+ # Anilistrb
2
+
3
+ A simple API wrapper for AniList's GraphQL APIv2
4
+
5
+ This is a small side project for a practical introduction to both Ruby and GraphQL,
6
+ so its not perfect
7
+
8
+ Also learned some of the basics of Rubocop, Rspec, Rake
9
+
10
+
11
+ ## Installation
12
+ * Put in gemfile: ```gem 'Anilistrb```
13
+ * Execute: ```$ bundle```
14
+ * or manually ```$ gem install Anilistrb```
15
+
16
+
17
+ ## API Wrapper - https://graphql.anilist.co
18
+ * get_anime(id)
19
+ * get_manga(id)
20
+ * get_animelist(userId)
21
+ * get_mangalist(userId)
22
+ * search_anime(search)
23
+ * search_manga(search)
24
+ * search_anime_paged(search, perPage, page)
25
+ * search_manga_paged(search, perPage, page)
26
+ * search_user(search)
27
+ * gql_request(query string, variables struct)
28
+
29
+
30
+ ## Development
31
+ * ```bundle install``` to install dependencies
32
+ * ```rake spec``` run tests
33
+ * ```bundle exec rake install``` install locally
34
+
35
+ ## Building/Publishing
36
+ * commit + push all changes
37
+ * ```gem build Anilistrb.gemspec```
38
+ * ```gem push Anilistrb-0.1.0.gem```
39
+
40
+ ## To Do
41
+ - [x] GraphQL Client and basic get_media(id)
42
+ - [x] Rubocop, Unit tests
43
+ - [x] All get by id functions
44
+ - [x] All search functions
45
+ - [x] Test gem usage in a simple program
46
+ - [x] Documentation
47
+ - [x] Publish gem
48
+
49
+ ## Scrapped out of laziness
50
+ * Dockerize, GitLab CI/CD
51
+
52
+
53
+ ## Sources
54
+ * GraphQL Introduction https://graphql.org/learn/
55
+ * AniList https://anilist.co/home
56
+ * AniList APIv2 Docs https://anilist.gitbook.io/anilist-apiv2-docs/
57
+ * Anilist APIv2 Schema Documentation https://anilist.github.io/ApiV2-GraphQL-Docs/
58
+ * Ruby Gems https://rubygems.org/
59
+ * Ruby Docker https://hub.docker.com/_/ruby
60
+ * Publish a Ruby gem https://guides.rubygems.org/publishing/
@@ -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 'Anilistrb'
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,87 @@
1
+ query ($id: Int, $type: MediaType) {
2
+ Media (id: $id, type: $type) {
3
+ id
4
+ title {
5
+ romaji
6
+ english
7
+ native
8
+ }
9
+ type
10
+ format
11
+ status
12
+ description
13
+ startDate {
14
+ year
15
+ month
16
+ day
17
+ }
18
+ endDate {
19
+ year
20
+ month
21
+ day
22
+ }
23
+ season
24
+ episodes
25
+ duration
26
+ chapters
27
+ volumes
28
+ countryOfOrigin
29
+ isLicensed
30
+ source
31
+ hashtag
32
+ trailer {
33
+ id
34
+ site
35
+ }
36
+ updatedAt
37
+ coverImage {
38
+ large
39
+ medium
40
+ }
41
+ bannerImage
42
+ genres
43
+ synonyms
44
+ averageScore
45
+ meanScore
46
+ popularity
47
+ trending
48
+ tags {
49
+ id
50
+ name
51
+ description
52
+ category
53
+ rank
54
+ isGeneralSpoiler
55
+ isMediaSpoiler
56
+ isAdult
57
+ }
58
+ isAdult
59
+ nextAiringEpisode {
60
+ timeUntilAiring
61
+ episode
62
+ }
63
+ externalLinks {
64
+ id
65
+ url
66
+ site
67
+ }
68
+ streamingEpisodes {
69
+ title
70
+ thumbnail
71
+ url
72
+ site
73
+ }
74
+ rankings {
75
+ id
76
+ rank
77
+ type
78
+ format
79
+ year
80
+ season
81
+ allTime
82
+ context
83
+ }
84
+ siteUrl
85
+ modNotes
86
+ }
87
+ }
@@ -0,0 +1,6 @@
1
+
2
+ POST https://graphql.anilist.co HTTP/1.1
3
+ Accept: application/json
4
+ Content-Type: application/json
5
+
6
+ > ./anilist-test.gql
@@ -0,0 +1,233 @@
1
+ {
2
+ "data": {
3
+ "Media": {
4
+ "id": 33,
5
+ "title": {
6
+ "romaji": "Kenpuu Denki Berserk",
7
+ "english": "Berserk",
8
+ "native": "\\u5263\\u98a8\\u4f1d\\u5947\\u30d9\\u30eb\\u30bb\\u30eb\\u30af"
9
+ },
10
+ "type": "ANIME",
11
+ "format": "TV",
12
+ "status": "FINISHED",
13
+ "description": "A brave young warrior named Guts fights for his fortune as a mercenary on the front lines. A fated encounter unites Guts with the charismatic and deadly young man named Griffith. Leading the rogue soldiers known as the Band of the Hawk, Griffith wields his formidable force like no other. Driven by a quest for status, the Hawks exert military and social prowess the likes of which have never been seen before. The armies of Midland will quake with fear as Griffith and Guts set off on a path that will bring the world to its knees.<br><br>\\n(Source: Season One Complete DVD Collection Back Cover)",
14
+ "startDate": {
15
+ "year": 1997,
16
+ "month": 10,
17
+ "day": 7
18
+ },
19
+ "endDate": {
20
+ "year": 1998,
21
+ "month": 3,
22
+ "day": 31
23
+ },
24
+ "season": "FALL",
25
+ "episodes": 25,
26
+ "duration": 25,
27
+ "chapters": null,
28
+ "volumes": null,
29
+ "countryOfOrigin": "JP",
30
+ "isLicensed": true,
31
+ "source": "MANGA",
32
+ "hashtag": null,
33
+ "trailer": null,
34
+ "updatedAt": 1552244513,
35
+ "coverImage": {
36
+ "large": "https:\\/\\/s4.anilist.co\\/file\\/anilistcdn\\/media\\/anime\\/cover\\/medium\\/nx33-2SMoVxygnhcy.jpg",
37
+ "medium": "https:\\/\\/s4.anilist.co\\/file\\/anilistcdn\\/media\\/anime\\/cover\\/small\\/nx33-2SMoVxygnhcy.jpg"
38
+ },
39
+ "bannerImage": "https:\\/\\/s4.anilist.co\\/file\\/anilistcdn\\/media\\/anime\\/banner\\/n33-H5u82ZzMDmKn.jpg",
40
+ "genres": [
41
+ "Action",
42
+ "Adventure",
43
+ "Drama",
44
+ "Fantasy",
45
+ "Horror"
46
+ ],
47
+ "synonyms": [
48
+ "Kenfu Denki Berserk",
49
+ "Sword-Wind Chronicle Berserk"
50
+ ],
51
+ "averageScore": 82,
52
+ "meanScore": 82,
53
+ "popularity": 19958,
54
+ "trending": 2,
55
+ "tags": [
56
+ {
57
+ "id": 85,
58
+ "name": "Tragedy",
59
+ "description": "Centers around tragic events and unhappy endings.",
60
+ "category": "Theme-Drama",
61
+ "rank": 92,
62
+ "isGeneralSpoiler": true,
63
+ "isMediaSpoiler": true,
64
+ "isAdult": false
65
+ },
66
+ {
67
+ "id": 50,
68
+ "name": "Seinen",
69
+ "description": "Target demographic is adult males.",
70
+ "category": "Demographic",
71
+ "rank": 86,
72
+ "isGeneralSpoiler": false,
73
+ "isMediaSpoiler": false,
74
+ "isAdult": false
75
+ },
76
+ {
77
+ "id": 111,
78
+ "name": "War",
79
+ "description": "Partly or completely set during wartime.",
80
+ "category": "Theme-Other",
81
+ "rank": 85,
82
+ "isGeneralSpoiler": false,
83
+ "isMediaSpoiler": false,
84
+ "isAdult": false
85
+ },
86
+ {
87
+ "id": 43,
88
+ "name": "Swordplay",
89
+ "description": "Prominently features the use of swords in combat.",
90
+ "category": "Theme-Action",
91
+ "rank": 82,
92
+ "isGeneralSpoiler": false,
93
+ "isMediaSpoiler": false,
94
+ "isAdult": false
95
+ },
96
+ {
97
+ "id": 34,
98
+ "name": "Military",
99
+ "description": "Centered around the life and activities of military personnel.",
100
+ "category": "Theme-Other-Organisations",
101
+ "rank": 80,
102
+ "isGeneralSpoiler": false,
103
+ "isMediaSpoiler": false,
104
+ "isAdult": false
105
+ },
106
+ {
107
+ "id": 104,
108
+ "name": "Anti-Hero",
109
+ "description": "Features a protagonist who lacks conventional heroic attributes and may be considered a borderline villain.",
110
+ "category": "Cast-Main Cast",
111
+ "rank": 77,
112
+ "isGeneralSpoiler": false,
113
+ "isMediaSpoiler": false,
114
+ "isAdult": false
115
+ },
116
+ {
117
+ "id": 82,
118
+ "name": "Male Protagonist",
119
+ "description": "Main character is male.",
120
+ "category": "Cast-Main Cast",
121
+ "rank": 76,
122
+ "isGeneralSpoiler": false,
123
+ "isMediaSpoiler": false,
124
+ "isAdult": false
125
+ },
126
+ {
127
+ "id": 94,
128
+ "name": "Gore",
129
+ "description": "Prominently features graphic bloodshed and violence.",
130
+ "category": "Theme-Other",
131
+ "rank": 75,
132
+ "isGeneralSpoiler": false,
133
+ "isMediaSpoiler": false,
134
+ "isAdult": false
135
+ },
136
+ {
137
+ "id": 15,
138
+ "name": "Demons",
139
+ "description": "Prominently features malevolent otherworldly creatures.",
140
+ "category": "Cast-Traits",
141
+ "rank": 74,
142
+ "isGeneralSpoiler": false,
143
+ "isMediaSpoiler": false,
144
+ "isAdult": false
145
+ },
146
+ {
147
+ "id": 155,
148
+ "name": "Rape",
149
+ "description": "Features non-consensual sexual penetration.",
150
+ "category": "Sexual Content",
151
+ "rank": 60,
152
+ "isGeneralSpoiler": false,
153
+ "isMediaSpoiler": true,
154
+ "isAdult": true
155
+ },
156
+ {
157
+ "id": 252,
158
+ "name": "Revenge",
159
+ "description": "Prominently features a character who aims to exact punishment in a resentful or vindictive manner.",
160
+ "category": "Theme-Drama",
161
+ "rank": 52,
162
+ "isGeneralSpoiler": false,
163
+ "isMediaSpoiler": false,
164
+ "isAdult": false
165
+ },
166
+ {
167
+ "id": 226,
168
+ "name": "Fugitive",
169
+ "description": "Prominently features a character evading capture by an individual or organization.",
170
+ "category": "Theme-Action",
171
+ "rank": 30,
172
+ "isGeneralSpoiler": false,
173
+ "isMediaSpoiler": false,
174
+ "isAdult": false
175
+ }
176
+ ],
177
+ "isAdult": false,
178
+ "nextAiringEpisode": null,
179
+ "externalLinks": [
180
+ {
181
+ "id": 7628,
182
+ "url": "https:\\/\\/www.animelab.com\\/shows\\/berserk",
183
+ "site": "Animelab"
184
+ }
185
+ ],
186
+ "streamingEpisodes": [],
187
+ "rankings": [
188
+ {
189
+ "id": 91,
190
+ "rank": 91,
191
+ "type": "RATED",
192
+ "format": "TV",
193
+ "year": null,
194
+ "season": null,
195
+ "allTime": true,
196
+ "context": "highest rated all time"
197
+ },
198
+ {
199
+ "id": 827,
200
+ "rank": 327,
201
+ "type": "POPULAR",
202
+ "format": "TV",
203
+ "year": null,
204
+ "season": null,
205
+ "allTime": true,
206
+ "context": "most popular all time"
207
+ },
208
+ {
209
+ "id": 1313,
210
+ "rank": 1,
211
+ "type": "RATED",
212
+ "format": "TV",
213
+ "year": 1997,
214
+ "season": null,
215
+ "allTime": false,
216
+ "context": "highest rated"
217
+ },
218
+ {
219
+ "id": 1340,
220
+ "rank": 1,
221
+ "type": "POPULAR",
222
+ "format": "TV",
223
+ "year": 1997,
224
+ "season": null,
225
+ "allTime": false,
226
+ "context": "most popular"
227
+ }
228
+ ],
229
+ "siteUrl": "https:\\/\\/anilist.co\\/anime\\/33",
230
+ "modNotes": null
231
+ }
232
+ }
233
+ }