synonymous 0.1.0

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: eed895bc363bd870ea81dd3cac60383036adff307cddc74b35197d0412662502
4
+ data.tar.gz: 86c2674c2c720e364df64e08a4fd449339de2d3f99e1bbfa66b23ad9082cf4f7
5
+ SHA512:
6
+ metadata.gz: 0e8e497c887a3ebbad13228f61d6c7cd00a9bfe674cc1ffd5bf96e15b8818bfeb84d5b409e2bf8654d0fccfcbe411c93aa95f251c8eaf4147f93243afe0ae019
7
+ data.tar.gz: 845ac280cdebb59604a0bcec2afed8fa18cbb3ac4db7e6fca5716c5af69597bb77d94dee855b6c98c5450c82a7c1321a871f4363bc65d3cc4365bbaa1bf59566
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.17.2
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 synonymous.gemspec
6
+ gemspec
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ synonymous (0.1.0)
5
+ faraday
6
+ faraday-raise-errors
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.6.0)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ faraday (0.15.4)
16
+ multipart-post (>= 1.2, < 3)
17
+ faraday-raise-errors (0.3.0)
18
+ faraday
19
+ hashdiff (0.3.7)
20
+ minitest (5.11.3)
21
+ multipart-post (2.1.1)
22
+ public_suffix (3.0.3)
23
+ rake (10.5.0)
24
+ safe_yaml (1.0.5)
25
+ shoulda-context (1.2.2)
26
+ vcr (5.0.0)
27
+ webmock (3.4.2)
28
+ addressable (>= 2.3.6)
29
+ crack (>= 0.3.2)
30
+ hashdiff
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.17)
37
+ minitest (~> 5.0)
38
+ rake (~> 10.0)
39
+ shoulda-context
40
+ synonymous!
41
+ vcr
42
+ webmock
43
+
44
+ BUNDLED WITH
45
+ 1.17.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Bob Lail
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,39 @@
1
+ # Synonymous
2
+
3
+ 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/synonymous`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'synonymous'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install synonymous
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/synonymous.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "synonymous"
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,84 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.dictionaryapi.com/api/v3/references/thesaurus/json/adaptable?key=<DICTIONARYAPI_KEY>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Mon, 17 Jun 2019 02:37:58 GMT
23
+ Server:
24
+ - Apache
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Content-Length:
28
+ - '2587'
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ body:
32
+ encoding: UTF-8
33
+ string: '[{"meta":{"id":"adaptable","uuid":"bb3ef944-bad5-4987-a75e-cc9b59b9e40c","src":"coll_thes","section":"alpha","target":{"tuuid":"c57d99e2-5fcd-455d-b8bc-a50483db752c","tsrc":"collegiate"},"stems":["adaptable","adaptabilities","adaptability"],"syns":[["all-around","protean","universal","versatile"],["adjustable","alterable","changeable","elastic","flexible","fluid","malleable","modifiable","pliable","variable"]],"ants":[["established","fixed","immutable","inelastic","inflexible","invariable","nonmalleable","ramrod","set","unadaptable","unalterable","unbudgeable","unchangeable"]],"offensive":false},"hwi":{"hw":"adaptable"},"fl":"adjective","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","able
34
+ to do many different kinds of things "],["vis",[{"t":"an activities director
35
+ who\u0027s {it}adaptable{\/it} to any kind of situation"}]]],"syn_list":[[{"wd":"all-around","wvrs":[{"wvl":"also","wva":"all-round"}]},{"wd":"protean"},{"wd":"universal"},{"wd":"versatile"}]],"rel_list":[[{"wd":"general-purpose"},{"wd":"mixed-use"},{"wd":"multipurpose"}],[{"wd":"well-rounded"}],[{"wd":"able"},{"wd":"ace"},{"wd":"adept"},{"wd":"experienced"},{"wd":"expert"},{"wd":"masterful"},{"wd":"proficient"},{"wd":"skilled"},{"wd":"skillful"}],[{"wd":"adjustable"},{"wd":"alterable"},{"wd":"changeable"},{"wd":"elastic"},{"wd":"flexible"},{"wd":"fluid"},{"wd":"malleable"},{"wd":"modifiable"},{"wd":"plastic"},{"wd":"pliable"},{"wd":"pliant"},{"wd":"supple"},{"wd":"variable"}]],"near_list":[[{"wd":"limited"}],[{"wd":"amateur"},{"wd":"inexperienced"}]]}]],[["sense",{"sn":"2","dt":[["text","capable
36
+ of being readily changed "],["vis",[{"t":"the caterer\u0027s menu is {it}adaptable{\/it}
37
+ to specific dietary needs, such as vegan, kosher, or low-fat"}]]],"syn_list":[[{"wd":"adjustable"},{"wd":"alterable"},{"wd":"changeable"},{"wd":"elastic"},{"wd":"flexible"},{"wd":"fluid"},{"wd":"malleable"},{"wd":"modifiable"},{"wd":"pliable"},{"wd":"variable"}]],"rel_list":[[{"wd":"changing"},{"wd":"fluctuating"},{"wd":"inconstant"},{"wd":"labile"},{"wd":"unstable"},{"wd":"unsteady"},{"wd":"varying"},{"wd":"versatile"}]],"near_list":[[{"wd":"constant"},{"wd":"stable"},{"wd":"steady"},{"wd":"unchanging"},{"wd":"uniform"},{"wd":"unvarying"}]],"ant_list":[[{"wd":"established"},{"wd":"fixed"},{"wd":"immutable"},{"wd":"inelastic"},{"wd":"inflexible"},{"wd":"invariable"},{"wd":"nonmalleable"},{"wd":"ramrod"},{"wd":"set"},{"wd":"unadaptable"},{"wd":"unalterable"},{"wd":"unbudgeable"},{"wd":"unchangeable"}]]}]]]}],"shortdef":["able
38
+ to do many different kinds of things","capable of being readily changed"]}]'
39
+ http_version:
40
+ recorded_at: Mon, 17 Jun 2019 02:37:58 GMT
41
+ - request:
42
+ method: get
43
+ uri: https://www.dictionaryapi.com/api/v3/references/thesaurus/json/adaptable?key=<DICTIONARYAPI_KEY>
44
+ body:
45
+ encoding: UTF-8
46
+ string: '[{"meta":{"id":"adaptable","uuid":"bb3ef944-bad5-4987-a75e-cc9b59b9e40c","src":"coll_thes","section":"alpha","target":{"tuuid":"c57d99e2-5fcd-455d-b8bc-a50483db752c","tsrc":"collegiate"},"stems":["adaptable","adaptabilities","adaptability"],"syns":[["all-around","protean","universal","versatile"],["adjustable","alterable","changeable","elastic","flexible","fluid","malleable","modifiable","pliable","variable"]],"ants":[["established","fixed","immutable","inelastic","inflexible","invariable","nonmalleable","ramrod","set","unadaptable","unalterable","unbudgeable","unchangeable"]],"offensive":false},"hwi":{"hw":"adaptable"},"fl":"adjective","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","able
47
+ to do many different kinds of things "],["vis",[{"t":"an activities director
48
+ who\u0027s {it}adaptable{\/it} to any kind of situation"}]]],"syn_list":[[{"wd":"all-around","wvrs":[{"wvl":"also","wva":"all-round"}]},{"wd":"protean"},{"wd":"universal"},{"wd":"versatile"}]],"rel_list":[[{"wd":"general-purpose"},{"wd":"mixed-use"},{"wd":"multipurpose"}],[{"wd":"well-rounded"}],[{"wd":"able"},{"wd":"ace"},{"wd":"adept"},{"wd":"experienced"},{"wd":"expert"},{"wd":"masterful"},{"wd":"proficient"},{"wd":"skilled"},{"wd":"skillful"}],[{"wd":"adjustable"},{"wd":"alterable"},{"wd":"changeable"},{"wd":"elastic"},{"wd":"flexible"},{"wd":"fluid"},{"wd":"malleable"},{"wd":"modifiable"},{"wd":"plastic"},{"wd":"pliable"},{"wd":"pliant"},{"wd":"supple"},{"wd":"variable"}]],"near_list":[[{"wd":"limited"}],[{"wd":"amateur"},{"wd":"inexperienced"}]]}]],[["sense",{"sn":"2","dt":[["text","capable
49
+ of being readily changed "],["vis",[{"t":"the caterer\u0027s menu is {it}adaptable{\/it}
50
+ to specific dietary needs, such as vegan, kosher, or low-fat"}]]],"syn_list":[[{"wd":"adjustable"},{"wd":"alterable"},{"wd":"changeable"},{"wd":"elastic"},{"wd":"flexible"},{"wd":"fluid"},{"wd":"malleable"},{"wd":"modifiable"},{"wd":"pliable"},{"wd":"variable"}]],"rel_list":[[{"wd":"changing"},{"wd":"fluctuating"},{"wd":"inconstant"},{"wd":"labile"},{"wd":"unstable"},{"wd":"unsteady"},{"wd":"varying"},{"wd":"versatile"}]],"near_list":[[{"wd":"constant"},{"wd":"stable"},{"wd":"steady"},{"wd":"unchanging"},{"wd":"uniform"},{"wd":"unvarying"}]],"ant_list":[[{"wd":"established"},{"wd":"fixed"},{"wd":"immutable"},{"wd":"inelastic"},{"wd":"inflexible"},{"wd":"invariable"},{"wd":"nonmalleable"},{"wd":"ramrod"},{"wd":"set"},{"wd":"unadaptable"},{"wd":"unalterable"},{"wd":"unbudgeable"},{"wd":"unchangeable"}]]}]]]}],"shortdef":["able
51
+ to do many different kinds of things","capable of being readily changed"]}]'
52
+ headers:
53
+ User-Agent:
54
+ - Faraday v0.15.4
55
+ Accept-Encoding:
56
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
+ Accept:
58
+ - "*/*"
59
+ response:
60
+ status:
61
+ code: 200
62
+ message: OK
63
+ headers:
64
+ Date:
65
+ - Tue, 18 Jun 2019 01:45:22 GMT
66
+ Server:
67
+ - Apache
68
+ Access-Control-Allow-Origin:
69
+ - "*"
70
+ Content-Length:
71
+ - '2587'
72
+ Content-Type:
73
+ - application/json; charset=utf-8
74
+ body:
75
+ encoding: UTF-8
76
+ string: '[{"meta":{"id":"adaptable","uuid":"bb3ef944-bad5-4987-a75e-cc9b59b9e40c","src":"coll_thes","section":"alpha","target":{"tuuid":"c57d99e2-5fcd-455d-b8bc-a50483db752c","tsrc":"collegiate"},"stems":["adaptable","adaptabilities","adaptability"],"syns":[["all-around","protean","universal","versatile"],["adjustable","alterable","changeable","elastic","flexible","fluid","malleable","modifiable","pliable","variable"]],"ants":[["established","fixed","immutable","inelastic","inflexible","invariable","nonmalleable","ramrod","set","unadaptable","unalterable","unbudgeable","unchangeable"]],"offensive":false},"hwi":{"hw":"adaptable"},"fl":"adjective","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","able
77
+ to do many different kinds of things "],["vis",[{"t":"an activities director
78
+ who\u0027s {it}adaptable{\/it} to any kind of situation"}]]],"syn_list":[[{"wd":"all-around","wvrs":[{"wvl":"also","wva":"all-round"}]},{"wd":"protean"},{"wd":"universal"},{"wd":"versatile"}]],"rel_list":[[{"wd":"general-purpose"},{"wd":"mixed-use"},{"wd":"multipurpose"}],[{"wd":"well-rounded"}],[{"wd":"able"},{"wd":"ace"},{"wd":"adept"},{"wd":"experienced"},{"wd":"expert"},{"wd":"masterful"},{"wd":"proficient"},{"wd":"skilled"},{"wd":"skillful"}],[{"wd":"adjustable"},{"wd":"alterable"},{"wd":"changeable"},{"wd":"elastic"},{"wd":"flexible"},{"wd":"fluid"},{"wd":"malleable"},{"wd":"modifiable"},{"wd":"plastic"},{"wd":"pliable"},{"wd":"pliant"},{"wd":"supple"},{"wd":"variable"}]],"near_list":[[{"wd":"limited"}],[{"wd":"amateur"},{"wd":"inexperienced"}]]}]],[["sense",{"sn":"2","dt":[["text","capable
79
+ of being readily changed "],["vis",[{"t":"the caterer\u0027s menu is {it}adaptable{\/it}
80
+ to specific dietary needs, such as vegan, kosher, or low-fat"}]]],"syn_list":[[{"wd":"adjustable"},{"wd":"alterable"},{"wd":"changeable"},{"wd":"elastic"},{"wd":"flexible"},{"wd":"fluid"},{"wd":"malleable"},{"wd":"modifiable"},{"wd":"pliable"},{"wd":"variable"}]],"rel_list":[[{"wd":"changing"},{"wd":"fluctuating"},{"wd":"inconstant"},{"wd":"labile"},{"wd":"unstable"},{"wd":"unsteady"},{"wd":"varying"},{"wd":"versatile"}]],"near_list":[[{"wd":"constant"},{"wd":"stable"},{"wd":"steady"},{"wd":"unchanging"},{"wd":"uniform"},{"wd":"unvarying"}]],"ant_list":[[{"wd":"established"},{"wd":"fixed"},{"wd":"immutable"},{"wd":"inelastic"},{"wd":"inflexible"},{"wd":"invariable"},{"wd":"nonmalleable"},{"wd":"ramrod"},{"wd":"set"},{"wd":"unadaptable"},{"wd":"unalterable"},{"wd":"unbudgeable"},{"wd":"unchangeable"}]]}]]]}],"shortdef":["able
81
+ to do many different kinds of things","capable of being readily changed"]}]'
82
+ http_version:
83
+ recorded_at: Tue, 18 Jun 2019 01:45:22 GMT
84
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.dictionaryapi.com/api/v3/references/thesaurus/json/asdf?key=<DICTIONARYAPI_KEY>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Sun, 23 Jun 2019 20:24:25 GMT
23
+ Server:
24
+ - Apache
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Content-Length:
28
+ - '80'
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ body:
32
+ encoding: UTF-8
33
+ string: '["aside","add","adds","ado","ads","aid","aide","aids","ashy","ask","asks","ass"]'
34
+ http_version:
35
+ recorded_at: Sun, 23 Jun 2019 20:24:25 GMT
36
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,76 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.dictionaryapi.com/api/v3/references/thesaurus/json/police+force?key=<DICTIONARYAPI_KEY>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Mon, 24 Jun 2019 01:25:12 GMT
23
+ Server:
24
+ - Apache
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Content-Length:
28
+ - '244'
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ body:
32
+ encoding: UTF-8
33
+ string: '["police force","counterforce","police forces","perforce","police officer","counterforces","police
34
+ officers","enforce","licence","licensor","licensors","police","policeman","policemen","politer","polychrome","reenforce","reinforce","workforce"]'
35
+ http_version:
36
+ recorded_at: Mon, 24 Jun 2019 01:25:12 GMT
37
+ - request:
38
+ method: get
39
+ uri: https://www.dictionaryapi.com/api/v3/references/thesaurus/json/police%20force?key=<DICTIONARYAPI_KEY>
40
+ body:
41
+ encoding: US-ASCII
42
+ string: ''
43
+ headers:
44
+ User-Agent:
45
+ - Faraday v0.15.4
46
+ Accept-Encoding:
47
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
48
+ Accept:
49
+ - "*/*"
50
+ response:
51
+ status:
52
+ code: 200
53
+ message: OK
54
+ headers:
55
+ Date:
56
+ - Mon, 24 Jun 2019 01:29:10 GMT
57
+ Server:
58
+ - Apache
59
+ Access-Control-Allow-Origin:
60
+ - "*"
61
+ Content-Length:
62
+ - '1081'
63
+ Content-Type:
64
+ - application/json; charset=utf-8
65
+ body:
66
+ encoding: UTF-8
67
+ string: '[{"meta":{"id":"police force","uuid":"17799531-e3bf-4865-8b6b-bdc6c41fdf9e","src":"coll_thes","section":"alpha","target":{"tuuid":"e4558596-b3ee-4e21-ba74-8c0438d7025c","tsrc":"collegiate"},"stems":["police
68
+ force","police forces"],"syns":[["constabulary","finest","force","fuzz","heat","man","police"]],"ants":[],"offensive":false},"hwi":{"hw":"police
69
+ force"},"fl":"noun","def":[{"sseq":[[["sense",{"dt":[["text","a body of officers
70
+ of the law "],["vis",[{"t":"mobilized practically the entire {it}police force{\/it}
71
+ to track down the escaped criminal"}]]],"syn_list":[[{"wd":"constabulary"},{"wd":"finest"},{"wd":"force"},{"wd":"fuzz"},{"wd":"heat","wsls":["slang"]},{"wd":"man"},{"wd":"police"}]],"rel_list":[[{"wd":"bluecoat"},{"wd":"bobby","wsls":["British"]},{"wd":"bull","wsls":["slang"]},{"wd":"constable"},{"wd":"cop"},{"wd":"copper"},{"wd":"gendarme"},{"wd":"officer"},{"wd":"peeler","wsls":["British"]},{"wd":"policeman"},{"wd":"police
72
+ officer"},{"wd":"policewoman"},{"wd":"shamus","wsls":["slang"]},{"wd":"trooper"}]]}]]]}],"shortdef":["a
73
+ body of officers of the law"]}]'
74
+ http_version:
75
+ recorded_at: Mon, 24 Jun 2019 01:29:10 GMT
76
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,129 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.dictionaryapi.com/api/v3/references/thesaurus/json/slice?key=<DICTIONARYAPI_KEY>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Mon, 17 Jun 2019 02:26:16 GMT
23
+ Server:
24
+ - Apache
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Content-Length:
28
+ - '4396'
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ body:
32
+ encoding: UTF-8
33
+ string: '[{"meta":{"id":"slice","uuid":"58b619bb-61ff-49e3-b2cd-9587f661e302","src":"coll_thes","section":"alpha","target":{"tuuid":"235e7e1a-4c43-4b48-9c94-81917924f96f","tsrc":"collegiate"},"stems":["slice","sliceable","sliced","slicer","slicers","slices","slicing"],"syns":[["sliver","splinter"],["cut","gash","incise","rip","shear","slash","slit"]],"ants":[],"offensive":false},"hwi":{"hw":"slice"},"fl":"verb","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","to
34
+ cut into long slender pieces "],["vis",[{"t":"{it}slice{\/it} the carrot into
35
+ tiny strips"}]]],"syn_list":[[{"wd":"sliver"},{"wd":"splinter"}]],"rel_list":[[{"wd":"chip"},{"wd":"chop"},{"wd":"dice"},{"wd":"hash"},{"wd":"julienne"},{"wd":"mince"}],[{"wd":"saw"},{"wd":"scissor"}],[{"wd":"cleave"},{"wd":"rive"},{"wd":"split"}],[{"wd":"gash"},{"wd":"incise"},{"wd":"rip"},{"wd":"slash"},{"wd":"slit"}]]}]],[["sense",{"sn":"2","dt":[["text","to
36
+ penetrate with a sharp edge (as a knife) "],["vis",[{"t":"the shard of glass
37
+ {it}sliced{\/it} my hand, and I started bleeding profusely"}]]],"syn_list":[[{"wd":"cut"},{"wd":"gash"},{"wd":"incise"},{"wd":"rip"},{"wd":"shear"},{"wd":"slash"},{"wd":"slit"}]],"rel_list":[[{"wd":"crosscut"},{"wd":"hacksaw"},{"wd":"saw"},{"wd":"scissor"}],[{"wd":"cleave"},{"wd":"rive"},{"wd":"split"}],[{"wd":"pierce"},{"wd":"stab"}],[{"wd":"bruise"},{"wd":"butcher"},{"wd":"hack"},{"wd":"haggle"},{"wd":"lacerate"},{"wd":"mangle"}],[{"wd":"rend"},{"wd":"tear"}],[{"wd":"carve"},{"wd":"chip"},{"wd":"chisel"},{"wd":"notch"}],[{"wd":"anatomize"},{"wd":"dissect"},{"wd":"section"}],[{"wd":"chop"},{"wd":"dice"},{"wd":"mince"}],[{"wd":"amputate"},{"wd":"cut
38
+ off"},{"wd":"sever"}]]}]]]}],"shortdef":["to cut into long slender pieces","to
39
+ penetrate with a sharp edge (as a knife)"]},{"meta":{"id":"slice","uuid":"72079058-1c30-4cdf-88fa-a134c9e6804a","src":"coll_thes","section":"alpha","target":{"tuuid":"a0e5de09-cce1-4f07-9eee-2a28671305fb","tsrc":"collegiate"},"stems":["slice","slices"],"syns":[["cross
40
+ section","sample","sampler","sampling","selection"],["cut","cutting"],["allotment","allowance","cut","end","part","piece","portion","proportion","quota","share","take"]],"ants":[],"offensive":false},"hwi":{"hw":"slice"},"fl":"noun","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","a
41
+ number of things selected from a group to stand for the whole "],["vis",[{"t":"the
42
+ novel\u0027s multitudinous array of characters constitute a veritable {it}slice{\/it}
43
+ of humanity"}]]],"syn_list":[[{"wd":"cross section"},{"wd":"sample"},{"wd":"sampler"},{"wd":"sampling"},{"wd":"selection"}]],"rel_list":[[{"wd":"case"},{"wd":"example"},{"wd":"exemplar"},{"wd":"exemplification"},{"wd":"illustration"},{"wd":"instance"},{"wd":"representative"},{"wd":"specimen"}],[{"wd":"archetype"},{"wd":"classic"},{"wd":"locus
44
+ classicus"},{"wd":"paradigm"},{"wd":"prototype"}],[{"wd":"microcosm"}]]}]],[["sense",{"sn":"2","dt":[["text","a
45
+ piece that has been separated from the whole by cutting "],["vis",[{"t":"took
46
+ a {it}slice{\/it} from the cake before passing it down the table"}]]],"syn_list":[[{"wd":"cut"},{"wd":"cutting"}]],"rel_list":[[{"wd":"chop"},{"wd":"cutlet"}],[{"wd":"length"},{"wd":"part"},{"wd":"portion"},{"wd":"section"},{"wd":"segment"}],[{"wd":"chunk"},{"wd":"hunk"},{"wd":"lump"}],[{"wd":"clipping"},{"wd":"paring"},{"wd":"shaving"},{"wd":"sliver"},{"wd":"snippet"},{"wd":"splinter"}]]}]],[["sense",{"sn":"3","dt":[["text","something
47
+ belonging to, due to, or contributed by an individual member of a group "],["vis",[{"t":"there\u0027s
48
+ a pile of money to be made on this land deal, and everybody\u0027s trying
49
+ to get their {it}slice{\/it}"}]]],"syn_list":[[{"wd":"allotment"},{"wd":"allowance"},{"wd":"cut"},{"wd":"end"},{"wd":"part"},{"wd":"piece"},{"wd":"portion"},{"wd":"proportion"},{"wd":"quota"},{"wd":"share"},{"wd":"take"}]],"rel_list":[[{"wd":"lot"},{"wd":"ration"}],[{"wd":"commission"},{"wd":"percentage"}],[{"wd":"member"},{"wd":"partition"},{"wd":"section"},{"wd":"segment"}]],"phrase_list":[[{"wd":"piece
50
+ of the action"}]],"near_list":[[{"wd":"aggregate"},{"wd":"composite"},{"wd":"compound"},{"wd":"pool"},{"wd":"sum"},{"wd":"total"},{"wd":"totality"}],[{"wd":"whole"}]]}]]]}],"shortdef":["a
51
+ number of things selected from a group to stand for the whole","a piece that
52
+ has been separated from the whole by cutting","something belonging to, due
53
+ to, or contributed by an individual member of a group"]}]'
54
+ http_version:
55
+ recorded_at: Mon, 17 Jun 2019 02:26:16 GMT
56
+ - request:
57
+ method: get
58
+ uri: https://www.dictionaryapi.com/api/v3/references/thesaurus/json/slice?key=<DICTIONARYAPI_KEY>
59
+ body:
60
+ encoding: UTF-8
61
+ string: '[{"meta":{"id":"slice","uuid":"58b619bb-61ff-49e3-b2cd-9587f661e302","src":"coll_thes","section":"alpha","target":{"tuuid":"235e7e1a-4c43-4b48-9c94-81917924f96f","tsrc":"collegiate"},"stems":["slice","sliceable","sliced","slicer","slicers","slices","slicing"],"syns":[["sliver","splinter"],["cut","gash","incise","rip","shear","slash","slit"]],"ants":[],"offensive":false},"hwi":{"hw":"slice"},"fl":"verb","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","to
62
+ cut into long slender pieces "],["vis",[{"t":"{it}slice{\/it} the carrot into
63
+ tiny strips"}]]],"syn_list":[[{"wd":"sliver"},{"wd":"splinter"}]],"rel_list":[[{"wd":"chip"},{"wd":"chop"},{"wd":"dice"},{"wd":"hash"},{"wd":"julienne"},{"wd":"mince"}],[{"wd":"saw"},{"wd":"scissor"}],[{"wd":"cleave"},{"wd":"rive"},{"wd":"split"}],[{"wd":"gash"},{"wd":"incise"},{"wd":"rip"},{"wd":"slash"},{"wd":"slit"}]]}]],[["sense",{"sn":"2","dt":[["text","to
64
+ penetrate with a sharp edge (as a knife) "],["vis",[{"t":"the shard of glass
65
+ {it}sliced{\/it} my hand, and I started bleeding profusely"}]]],"syn_list":[[{"wd":"cut"},{"wd":"gash"},{"wd":"incise"},{"wd":"rip"},{"wd":"shear"},{"wd":"slash"},{"wd":"slit"}]],"rel_list":[[{"wd":"crosscut"},{"wd":"hacksaw"},{"wd":"saw"},{"wd":"scissor"}],[{"wd":"cleave"},{"wd":"rive"},{"wd":"split"}],[{"wd":"pierce"},{"wd":"stab"}],[{"wd":"bruise"},{"wd":"butcher"},{"wd":"hack"},{"wd":"haggle"},{"wd":"lacerate"},{"wd":"mangle"}],[{"wd":"rend"},{"wd":"tear"}],[{"wd":"carve"},{"wd":"chip"},{"wd":"chisel"},{"wd":"notch"}],[{"wd":"anatomize"},{"wd":"dissect"},{"wd":"section"}],[{"wd":"chop"},{"wd":"dice"},{"wd":"mince"}],[{"wd":"amputate"},{"wd":"cut
66
+ off"},{"wd":"sever"}]]}]]]}],"shortdef":["to cut into long slender pieces","to
67
+ penetrate with a sharp edge (as a knife)"]},{"meta":{"id":"slice","uuid":"72079058-1c30-4cdf-88fa-a134c9e6804a","src":"coll_thes","section":"alpha","target":{"tuuid":"a0e5de09-cce1-4f07-9eee-2a28671305fb","tsrc":"collegiate"},"stems":["slice","slices"],"syns":[["cross
68
+ section","sample","sampler","sampling","selection"],["cut","cutting"],["allotment","allowance","cut","end","part","piece","portion","proportion","quota","share","take"]],"ants":[],"offensive":false},"hwi":{"hw":"slice"},"fl":"noun","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","a
69
+ number of things selected from a group to stand for the whole "],["vis",[{"t":"the
70
+ novel\u0027s multitudinous array of characters constitute a veritable {it}slice{\/it}
71
+ of humanity"}]]],"syn_list":[[{"wd":"cross section"},{"wd":"sample"},{"wd":"sampler"},{"wd":"sampling"},{"wd":"selection"}]],"rel_list":[[{"wd":"case"},{"wd":"example"},{"wd":"exemplar"},{"wd":"exemplification"},{"wd":"illustration"},{"wd":"instance"},{"wd":"representative"},{"wd":"specimen"}],[{"wd":"archetype"},{"wd":"classic"},{"wd":"locus
72
+ classicus"},{"wd":"paradigm"},{"wd":"prototype"}],[{"wd":"microcosm"}]]}]],[["sense",{"sn":"2","dt":[["text","a
73
+ piece that has been separated from the whole by cutting "],["vis",[{"t":"took
74
+ a {it}slice{\/it} from the cake before passing it down the table"}]]],"syn_list":[[{"wd":"cut"},{"wd":"cutting"}]],"rel_list":[[{"wd":"chop"},{"wd":"cutlet"}],[{"wd":"length"},{"wd":"part"},{"wd":"portion"},{"wd":"section"},{"wd":"segment"}],[{"wd":"chunk"},{"wd":"hunk"},{"wd":"lump"}],[{"wd":"clipping"},{"wd":"paring"},{"wd":"shaving"},{"wd":"sliver"},{"wd":"snippet"},{"wd":"splinter"}]]}]],[["sense",{"sn":"3","dt":[["text","something
75
+ belonging to, due to, or contributed by an individual member of a group "],["vis",[{"t":"there\u0027s
76
+ a pile of money to be made on this land deal, and everybody\u0027s trying
77
+ to get their {it}slice{\/it}"}]]],"syn_list":[[{"wd":"allotment"},{"wd":"allowance"},{"wd":"cut"},{"wd":"end"},{"wd":"part"},{"wd":"piece"},{"wd":"portion"},{"wd":"proportion"},{"wd":"quota"},{"wd":"share"},{"wd":"take"}]],"rel_list":[[{"wd":"lot"},{"wd":"ration"}],[{"wd":"commission"},{"wd":"percentage"}],[{"wd":"member"},{"wd":"partition"},{"wd":"section"},{"wd":"segment"}]],"phrase_list":[[{"wd":"piece
78
+ of the action"}]],"near_list":[[{"wd":"aggregate"},{"wd":"composite"},{"wd":"compound"},{"wd":"pool"},{"wd":"sum"},{"wd":"total"},{"wd":"totality"}],[{"wd":"whole"}]]}]]]}],"shortdef":["a
79
+ number of things selected from a group to stand for the whole","a piece that
80
+ has been separated from the whole by cutting","something belonging to, due
81
+ to, or contributed by an individual member of a group"]}]'
82
+ headers:
83
+ User-Agent:
84
+ - Faraday v0.15.4
85
+ Accept-Encoding:
86
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
87
+ Accept:
88
+ - "*/*"
89
+ response:
90
+ status:
91
+ code: 200
92
+ message: OK
93
+ headers:
94
+ Date:
95
+ - Tue, 18 Jun 2019 01:45:23 GMT
96
+ Server:
97
+ - Apache
98
+ Access-Control-Allow-Origin:
99
+ - "*"
100
+ Content-Length:
101
+ - '4396'
102
+ Content-Type:
103
+ - application/json; charset=utf-8
104
+ body:
105
+ encoding: UTF-8
106
+ string: '[{"meta":{"id":"slice","uuid":"58b619bb-61ff-49e3-b2cd-9587f661e302","src":"coll_thes","section":"alpha","target":{"tuuid":"235e7e1a-4c43-4b48-9c94-81917924f96f","tsrc":"collegiate"},"stems":["slice","sliceable","sliced","slicer","slicers","slices","slicing"],"syns":[["sliver","splinter"],["cut","gash","incise","rip","shear","slash","slit"]],"ants":[],"offensive":false},"hwi":{"hw":"slice"},"fl":"verb","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","to
107
+ cut into long slender pieces "],["vis",[{"t":"{it}slice{\/it} the carrot into
108
+ tiny strips"}]]],"syn_list":[[{"wd":"sliver"},{"wd":"splinter"}]],"rel_list":[[{"wd":"chip"},{"wd":"chop"},{"wd":"dice"},{"wd":"hash"},{"wd":"julienne"},{"wd":"mince"}],[{"wd":"saw"},{"wd":"scissor"}],[{"wd":"cleave"},{"wd":"rive"},{"wd":"split"}],[{"wd":"gash"},{"wd":"incise"},{"wd":"rip"},{"wd":"slash"},{"wd":"slit"}]]}]],[["sense",{"sn":"2","dt":[["text","to
109
+ penetrate with a sharp edge (as a knife) "],["vis",[{"t":"the shard of glass
110
+ {it}sliced{\/it} my hand, and I started bleeding profusely"}]]],"syn_list":[[{"wd":"cut"},{"wd":"gash"},{"wd":"incise"},{"wd":"rip"},{"wd":"shear"},{"wd":"slash"},{"wd":"slit"}]],"rel_list":[[{"wd":"crosscut"},{"wd":"hacksaw"},{"wd":"saw"},{"wd":"scissor"}],[{"wd":"cleave"},{"wd":"rive"},{"wd":"split"}],[{"wd":"pierce"},{"wd":"stab"}],[{"wd":"bruise"},{"wd":"butcher"},{"wd":"hack"},{"wd":"haggle"},{"wd":"lacerate"},{"wd":"mangle"}],[{"wd":"rend"},{"wd":"tear"}],[{"wd":"carve"},{"wd":"chip"},{"wd":"chisel"},{"wd":"notch"}],[{"wd":"anatomize"},{"wd":"dissect"},{"wd":"section"}],[{"wd":"chop"},{"wd":"dice"},{"wd":"mince"}],[{"wd":"amputate"},{"wd":"cut
111
+ off"},{"wd":"sever"}]]}]]]}],"shortdef":["to cut into long slender pieces","to
112
+ penetrate with a sharp edge (as a knife)"]},{"meta":{"id":"slice","uuid":"72079058-1c30-4cdf-88fa-a134c9e6804a","src":"coll_thes","section":"alpha","target":{"tuuid":"a0e5de09-cce1-4f07-9eee-2a28671305fb","tsrc":"collegiate"},"stems":["slice","slices"],"syns":[["cross
113
+ section","sample","sampler","sampling","selection"],["cut","cutting"],["allotment","allowance","cut","end","part","piece","portion","proportion","quota","share","take"]],"ants":[],"offensive":false},"hwi":{"hw":"slice"},"fl":"noun","def":[{"sseq":[[["sense",{"sn":"1","dt":[["text","a
114
+ number of things selected from a group to stand for the whole "],["vis",[{"t":"the
115
+ novel\u0027s multitudinous array of characters constitute a veritable {it}slice{\/it}
116
+ of humanity"}]]],"syn_list":[[{"wd":"cross section"},{"wd":"sample"},{"wd":"sampler"},{"wd":"sampling"},{"wd":"selection"}]],"rel_list":[[{"wd":"case"},{"wd":"example"},{"wd":"exemplar"},{"wd":"exemplification"},{"wd":"illustration"},{"wd":"instance"},{"wd":"representative"},{"wd":"specimen"}],[{"wd":"archetype"},{"wd":"classic"},{"wd":"locus
117
+ classicus"},{"wd":"paradigm"},{"wd":"prototype"}],[{"wd":"microcosm"}]]}]],[["sense",{"sn":"2","dt":[["text","a
118
+ piece that has been separated from the whole by cutting "],["vis",[{"t":"took
119
+ a {it}slice{\/it} from the cake before passing it down the table"}]]],"syn_list":[[{"wd":"cut"},{"wd":"cutting"}]],"rel_list":[[{"wd":"chop"},{"wd":"cutlet"}],[{"wd":"length"},{"wd":"part"},{"wd":"portion"},{"wd":"section"},{"wd":"segment"}],[{"wd":"chunk"},{"wd":"hunk"},{"wd":"lump"}],[{"wd":"clipping"},{"wd":"paring"},{"wd":"shaving"},{"wd":"sliver"},{"wd":"snippet"},{"wd":"splinter"}]]}]],[["sense",{"sn":"3","dt":[["text","something
120
+ belonging to, due to, or contributed by an individual member of a group "],["vis",[{"t":"there\u0027s
121
+ a pile of money to be made on this land deal, and everybody\u0027s trying
122
+ to get their {it}slice{\/it}"}]]],"syn_list":[[{"wd":"allotment"},{"wd":"allowance"},{"wd":"cut"},{"wd":"end"},{"wd":"part"},{"wd":"piece"},{"wd":"portion"},{"wd":"proportion"},{"wd":"quota"},{"wd":"share"},{"wd":"take"}]],"rel_list":[[{"wd":"lot"},{"wd":"ration"}],[{"wd":"commission"},{"wd":"percentage"}],[{"wd":"member"},{"wd":"partition"},{"wd":"section"},{"wd":"segment"}]],"phrase_list":[[{"wd":"piece
123
+ of the action"}]],"near_list":[[{"wd":"aggregate"},{"wd":"composite"},{"wd":"compound"},{"wd":"pool"},{"wd":"sum"},{"wd":"total"},{"wd":"totality"}],[{"wd":"whole"}]]}]]]}],"shortdef":["a
124
+ number of things selected from a group to stand for the whole","a piece that
125
+ has been separated from the whole by cutting","something belonging to, due
126
+ to, or contributed by an individual member of a group"]}]'
127
+ http_version:
128
+ recorded_at: Tue, 18 Jun 2019 01:45:23 GMT
129
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,7 @@
1
+ require "synonymous/client"
2
+ require "synonymous/version"
3
+
4
+ module Synonymous
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,29 @@
1
+ require "faraday"
2
+ require "faraday/raise_errors"
3
+ require "json"
4
+
5
+ require "synonymous/response"
6
+
7
+ module Synonymous
8
+ class Client
9
+ attr_reader :api_key
10
+
11
+ def initialize(api_key:)
12
+ @api_key = api_key
13
+ end
14
+
15
+ def get(word)
16
+ Response.new(word, client.get("#{URI.escape(word)}?key=#{api_key}"))
17
+ end
18
+
19
+ private
20
+ attr_reader :client
21
+
22
+ def client
23
+ @client ||= Faraday.new("https://www.dictionaryapi.com/api/v3/references/thesaurus/json") do |client|
24
+ client.use Faraday::RaiseErrors
25
+ client.adapter Faraday.default_adapter
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,14 @@
1
+ require "synonymous/sense"
2
+
3
+ module Synonymous
4
+ class Definition
5
+ def initialize(data)
6
+ @data = data
7
+ end
8
+
9
+ def senses
10
+ # https://dictionaryapi.com/products/json#sec-2.sseq
11
+ @data.fetch("sseq").map { |data| Sense.new(data) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,37 @@
1
+ require "synonymous/definition"
2
+ require "synonymous/headword"
3
+
4
+ module Synonymous
5
+ class Entry
6
+ def initialize(data)
7
+ @data = data
8
+ end
9
+
10
+ def functional_label
11
+ # https://dictionaryapi.com/products/json#sec-2.fl
12
+ @data.fetch("fl")
13
+ end
14
+
15
+ def headword
16
+ # https://dictionaryapi.com/products/json#sec-2.hwi
17
+ Headword.new(@data.fetch("hwi"))
18
+ end
19
+
20
+ def senses
21
+ definition.senses
22
+ end
23
+
24
+ def definition
25
+ case definitions.count
26
+ when 1 then definitions[0]
27
+ when 0 then raise Synonymous::Error, "No definitions"
28
+ else raise Synonymous::Error, "Multiple definitions"
29
+ end
30
+ end
31
+
32
+ def definitions
33
+ # https://dictionaryapi.com/products/json#sec-2.def
34
+ @data.fetch("def").map { |data| Definition.new(data) }
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ module Synonymous
2
+ class Headword
3
+ def initialize(data)
4
+ @data = data
5
+ end
6
+
7
+ def to_s
8
+ # https://dictionaryapi.com/products/json#sec-2.hwi
9
+ @data.fetch("hw")
10
+ end
11
+ alias to_str to_s
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ require "synonymous/entry"
2
+
3
+ module Synonymous
4
+ class Response
5
+ attr_reader :suggestions, :entries
6
+
7
+ def initialize(word, response)
8
+ data = JSON.parse(response.body)
9
+
10
+ if data.all? { |entry| entry.is_a?(Hash) }
11
+ entries = data.map { |result| Entry.new(result) }
12
+ @entries, suggestions = entries.partition { |entry| entry.headword.to_s == word }
13
+ @suggestions = suggestions.map { |entry| entry.headword.to_s }
14
+ else
15
+ @entries = []
16
+ @suggestions = data
17
+ end
18
+ end
19
+
20
+ def success?
21
+ entries.any?
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ require "synonymous/word"
2
+
3
+ module Synonymous
4
+ class Sense
5
+ def initialize(data)
6
+ if data.length > 1
7
+ pp data
8
+ raise Synonymous::Error, "Sense Sequence has more than one element"
9
+ end
10
+ unless data[0][0] == "sense"
11
+ pp data[0]
12
+ raise Synonymous::Error, "Sense didn't start with keyword 'sense'"
13
+ end
14
+ unless data[0].length == 2
15
+ pp data[0]
16
+ raise Synonymous::Error, "Sense has more than two entries"
17
+ end
18
+
19
+ @data = data[0][1]
20
+ end
21
+
22
+ def number
23
+ # https://dictionaryapi.com/products/json#sec-2.sn
24
+ @data["sn"]
25
+ end
26
+
27
+ def to_s
28
+ # https://dictionaryapi.com/products/json#sec-2.dt
29
+ @data.fetch("dt").to_h.fetch("text").strip
30
+ end
31
+
32
+ def synonyms
33
+ # https://dictionaryapi.com/products/json#sec-3.synlist
34
+ @data.fetch("syn_list", []).flatten.map(&Word.method(:new))
35
+ end
36
+
37
+ def related_words
38
+ # https://dictionaryapi.com/products/json#sec-3.rellist
39
+ @data.fetch("rel_list", []).flatten.map(&Word.method(:new))
40
+ end
41
+
42
+ def synonymous_phrases
43
+ # https://dictionaryapi.com/products/json#sec-3.phraselist
44
+ @data.fetch("phrase_list", []).flatten.map(&Word.method(:new))
45
+ end
46
+
47
+ def antonyms
48
+ # https://dictionaryapi.com/products/json#sec-3.antlist
49
+ @data.fetch("ant_list", []).flatten.map(&Word.method(:new))
50
+ end
51
+
52
+ def near_antonyms
53
+ # https://dictionaryapi.com/products/json#sec-3.nearlist
54
+ @data.fetch("near_list", []).flatten.map(&Word.method(:new))
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module Synonymous
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,13 @@
1
+ module Synonymous
2
+ class Word
3
+ def initialize(data)
4
+ @data = data
5
+ end
6
+
7
+ def to_s
8
+ # https://dictionaryapi.com/products/json#sec-3.synlist
9
+ @data.fetch("wd")
10
+ end
11
+ alias to_str to_s
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "synonymous/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "synonymous"
8
+ spec.version = Synonymous::VERSION
9
+ spec.authors = ["Bob Lail"]
10
+ spec.email = ["bob.lailfamily@gmail.com"]
11
+
12
+ spec.summary = %q{Merriam-Webster's Collegiate Thesaurus}
13
+ spec.description = %q{A client for dictionaryapi.com}
14
+ spec.homepage = "https://github.com/boblail/synonymous"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) 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"
27
+ spec.add_dependency "faraday-raise-errors"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.17"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "minitest", "~> 5.0"
32
+ spec.add_development_dependency "shoulda-context"
33
+ spec.add_development_dependency "vcr"
34
+ spec.add_development_dependency "webmock"
35
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: synonymous
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bob Lail
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-06-24 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
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-raise-errors
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
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: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: shoulda-context
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: vcr
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
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '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'
125
+ description: A client for dictionaryapi.com
126
+ email:
127
+ - bob.lailfamily@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".travis.yml"
134
+ - Gemfile
135
+ - Gemfile.lock
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - bin/console
140
+ - bin/setup
141
+ - fixtures/vcr_cassettes/adaptable.yml
142
+ - fixtures/vcr_cassettes/asdf.yml
143
+ - fixtures/vcr_cassettes/police_force.yml
144
+ - fixtures/vcr_cassettes/slice.yml
145
+ - lib/synonymous.rb
146
+ - lib/synonymous/client.rb
147
+ - lib/synonymous/definition.rb
148
+ - lib/synonymous/entry.rb
149
+ - lib/synonymous/headword.rb
150
+ - lib/synonymous/response.rb
151
+ - lib/synonymous/sense.rb
152
+ - lib/synonymous/version.rb
153
+ - lib/synonymous/word.rb
154
+ - synonymous.gemspec
155
+ homepage: https://github.com/boblail/synonymous
156
+ licenses:
157
+ - MIT
158
+ metadata: {}
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ requirements: []
174
+ rubyforge_project:
175
+ rubygems_version: 2.7.6
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: Merriam-Webster's Collegiate Thesaurus
179
+ test_files: []