jisho_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f084d032b9f636ddcf347b1eb71743ae70532c6e846c2e80892fbf4d173783f1
4
+ data.tar.gz: cbf0021ece4f5fe0ee1d434c121f3cee0ca08bde0eddf1ebbce513a23ff6fa61
5
+ SHA512:
6
+ metadata.gz: c4f1975c60a3c82f39d95b39a6382888b8c8298a5aeaadae4bc7ea4fa40a6241fb0031a8c311f204a553f0c5a5771c90968dc68b270466b697262734379dc77d
7
+ data.tar.gz: ee757dbaf087b7260e248903d3eb27c05ef6baf3cbed837b10287cce783460155201d7b0b7ee8cf538e492b5c74389204bd6db1cf62f86bf849a2f2efb893398
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # 0.1.0
2
+
3
+ - Initial commit
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'activesupport', '~> 6'
6
+
7
+ gem 'faraday', '~> 1'
8
+ gem 'httplog', '~> 1.4'
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jisho_api (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (6.0.0)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ zeitwerk (~> 2.1, >= 2.1.8)
15
+ concurrent-ruby (1.1.6)
16
+ faraday (1.0.0)
17
+ multipart-post (>= 1.2, < 3)
18
+ httplog (1.4.2)
19
+ rack (>= 1.0)
20
+ rainbow (>= 2.0.0)
21
+ i18n (1.6.0)
22
+ concurrent-ruby (~> 1.0)
23
+ minitest (5.14.0)
24
+ multipart-post (2.1.1)
25
+ rack (2.2.2)
26
+ rainbow (3.0.0)
27
+ rake (10.5.0)
28
+ thread_safe (0.3.6)
29
+ tzinfo (1.2.6)
30
+ thread_safe (~> 0.1)
31
+ zeitwerk (2.1.9)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ activesupport (~> 6)
38
+ bundler (~> 2.0)
39
+ faraday (~> 1)
40
+ httplog (~> 1.4)
41
+ jisho_api!
42
+ rake (~> 10.0)
43
+
44
+ BUNDLED WITH
45
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 tomholford
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,88 @@
1
+ # JishoAPI
2
+
3
+ An unofficial Ruby gem client for [Jisho](https://jisho.org), a Japanese dictionary.
4
+
5
+ For details about the API, check out [this thread](https://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api) by the [developer](https://github.com/Kimtaro).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'jisho_api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jisho_api
22
+
23
+ ## Usage
24
+
25
+ ### Querying
26
+
27
+ A search `query` is required, and can be set in a few ways:
28
+
29
+ ```ruby
30
+ require 'jisho_api'
31
+
32
+ # Class method
33
+ JishoAPI::JishoAPI.search('hamburger')
34
+ >> [{ ... }]
35
+
36
+ # Initializer
37
+ api = JishoAPI::JishoAPI.new(query: 'ピザ')
38
+
39
+ # Accessor
40
+ api.query = '#jlpt-n5'
41
+
42
+ # Instance method
43
+ api.search # will use the internally stored query
44
+ >> [{ ... }]
45
+
46
+ api.search(query: 'something else') # will override (but not set) the internally stored query
47
+ >> [{ ... }]
48
+
49
+ ```
50
+
51
+ ### Pagination
52
+
53
+ By default, the gem will fetch the first page of results. There are also a few ways to override this behavior:
54
+
55
+ ```ruby
56
+
57
+ # Initializer
58
+ api = JishoAPI::JishoAPI.new(query: 'ピザ', page: 2)
59
+
60
+ # Accessor
61
+ api.page = 3
62
+
63
+ # Instance methods
64
+ # Fetching a page for a given query
65
+ api.search(query: 'something else', page: 2)
66
+ >> [{ ... }]
67
+
68
+ # This increments the internal page counter and executes a request
69
+ api.next_page!
70
+ >> [{ ... }]
71
+
72
+ puts api.page
73
+ >> 4
74
+ ```
75
+
76
+ ## Development
77
+
78
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
79
+
80
+ 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).
81
+
82
+ ## Contributing
83
+
84
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tomholford/jisho-api.
85
+
86
+ ## License
87
+
88
+ 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,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/TODO ADDED
File without changes
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jisho_api"
5
+ require 'irb'
6
+
7
+ api = JishoAPI::JishoAPI.new(debug: true)
8
+
9
+ binding.irb
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