related_word 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06728a5d4bf1201987292a5883718f2836962373
4
- data.tar.gz: de82330201b625736806f863b3aa474f8f298af5
3
+ metadata.gz: cb098d732eb20c852bb4991b8c494e50de53e493
4
+ data.tar.gz: 3a9b894523ceb27f2b72a2ca2d0f80143d08a28f
5
5
  SHA512:
6
- metadata.gz: 6d3d2c1e1c54a99174a019dbc032913e871fba483831fa9685f67b7666611c2aa809f1448b0408aea49c89c18c32e0c1208da9c0e9e0f1baf938810d9ffaf345
7
- data.tar.gz: 42f8be9463b0f546a269278583b45da39de55474c4778c67b14bb9e2615f564bfe770b982770080573047f9b57fbd579a99ee546135928927876bb1c3d4cb92c
6
+ metadata.gz: a965c0c6095c02039b89566f8dd6dd23dab1e0856b8e1fb2eae0f3d49592675b3002b98b64f75d341b5711466d06fec01ac8f46273b28428e9983db086cea10a
7
+ data.tar.gz: dd3845d1d752eb2819b5734b89938de07249f25092f2c004bf78a5f2df87451c26f56bbb681d19e8a6508efd310f1c663766fe2fb8be911466f4160b42f8c04d
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # RelatedWord
2
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/related_word`. 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
3
+ Get the list of related words of a specific word.
6
4
 
7
5
  ## Installation
8
6
 
@@ -24,16 +22,12 @@ Or install it yourself as:
24
22
 
25
23
  #### RelatedWord.find
26
24
  ```ruby
25
+ require 'related_word'
26
+
27
27
  word = 'school'
28
28
  RelatedWord.find(word)
29
29
  ```
30
30
 
31
- ## Development
32
-
33
- 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.
34
-
35
- 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).
36
-
37
31
  ## Contributing
38
32
 
39
33
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/related_word. 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.
data/lib/related_word.rb CHANGED
@@ -1,15 +1,17 @@
1
- require "related_word/version"
2
- require "json"
3
- require "net/http"
4
- require "uri"
1
+ require 'related_word/semantic_service'
5
2
 
6
- module RelatedWord
7
- LINK = "http://semantic-link.com/related.php?word="
3
+ class RelatedWord
4
+ def initialize(service = :semantic)
5
+ @service = service
6
+ end
7
+
8
+ def find(word)
9
+ UnknownService = CLass.new(StandardError)
8
10
 
9
- def self.find(word)
10
- link = "#{LINK}#{word}"
11
- uri = URI.parse(link)
12
- response = Net::HTTP.get_response(uri)
13
- JSON.parse(response.body)
11
+ if service == :semantic
12
+ SemanticService.new.find(word)
13
+ else
14
+ raise UnknownService
15
+ end
14
16
  end
15
17
  end
@@ -0,0 +1,14 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "uri"
4
+
5
+ class RelatedWord::SemanticService
6
+ LINK = "http://semantic-link.com/related.php?word="
7
+
8
+ def find(word)
9
+ link = "#{LINK}#{word}"
10
+ uri = URI.parse(link)
11
+ response = Net::HTTP.get_response(uri)
12
+ JSON.parse(response.body)
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: related_word
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - MatBi
@@ -83,10 +83,7 @@ files:
83
83
  - bin/console
84
84
  - bin/setup
85
85
  - lib/related_word.rb
86
- - lib/related_word/version.rb
87
- - related_word-0.1.0.gem
88
- - related_word-0.1.1.gem
89
- - related_word-0.1.2.gem
86
+ - lib/related_word/semantic_service.rb
90
87
  - related_word.gemspec
91
88
  homepage: https://github.com/lmduc/related_word
92
89
  licenses:
@@ -1,3 +0,0 @@
1
- module RelatedWord
2
- VERSION = "0.1.5"
3
- end
Binary file
Binary file
Binary file