words_and_idioms 0.2.1 → 0.2.2

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: 51c2cacea850658aafbd010cded38164bc130c3c
4
- data.tar.gz: 2bf769f3ac117e134f294beae45df9de55f3be40
3
+ metadata.gz: b50c8506a0f4f7239350991ce789499f29696138
4
+ data.tar.gz: ff26ef4720389863d91baccd4fc8ef9fa49aaaab
5
5
  SHA512:
6
- metadata.gz: e20165d0e7b51f88ea4673489f8a18feec57138069c56fb576bbade8a6ad91af79f1eb687758cdd47222c24b42cb6740e33229010c340e8a79a537075fd6df71
7
- data.tar.gz: ac6fe26ce45223e192e875d0379a7eb74a48eb6bf1c5c32f585d07cbf1b33e706bc0ab00892686a10f5905efab5f813b9fa6437deda120334124550c5770ec0e
6
+ metadata.gz: b27f9a9faea62435172144da906e5015326ed523876931efe47cafc14f2affea0926bcc45baf82da1d9348c2d569de489422b3be7433b1d00958812eb8352e38
7
+ data.tar.gz: b804a90d0dfe8a4c899c1021bd76435a9f9e462db922411b58bc1517f9fa0f9c7a550fd8d1dfa04b33e2dd3fbe33b50c18c63a5d2b96625476888685a5e4cddb
data/bin/words_and_idioms CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'bundler/setup'
3
- require './lib/words_and_idioms'
3
+ require_relative '../lib/words_and_idioms'
4
4
 
5
5
  WordsAndIdioms::CLI.new.call
@@ -7,5 +7,6 @@ require_relative "./words_and_idioms/version"
7
7
  require_relative './words_and_idioms/cli'
8
8
  require_relative './words_and_idioms/dictionary_scraper'
9
9
  require_relative './words_and_idioms/idiom_explorer'
10
+ require_relative './words_and_idioms/idiom'
10
11
  require_relative './words_and_idioms/idiom_scraper'
11
12
  require_relative './words_and_idioms/user_input'
@@ -18,6 +18,14 @@ class WordsAndIdioms::CLI
18
18
  menu
19
19
  end
20
20
 
21
+ def print_idiom_list
22
+ puts "Below is a list of newly created idioms from MacMillan's Open Dictionary Project"
23
+ Idiom.all.each.with_index(1) do |idiom, i|
24
+ puts "#{i}. #{idiom.name}"
25
+ end
26
+ IdiomExplorer.show_idiom
27
+ end
28
+
21
29
  def menu
22
30
  first_choice = (gets.chomp).to_i
23
31
  if first_choice == 1
@@ -25,7 +33,7 @@ def menu
25
33
  greet_user
26
34
  elsif first_choice == 2
27
35
  IdiomScraper.constructor
28
- IdiomExplorer.print_list
36
+ print_idiom_list
29
37
  greet_user
30
38
  elsif first_choice != 1 && first_choice != 2 && first_choice != 3
31
39
  puts " "
@@ -37,6 +45,8 @@ def menu
37
45
  end
38
46
  end
39
47
 
48
+
49
+
40
50
  def goodbye
41
51
  puts "I hope you learned something today. See you again soon."
42
52
  end
@@ -0,0 +1,25 @@
1
+ class Idiom
2
+ @@url = "http://www.macmillandictionary.com/us/open-dictionary/latestEntries.html"
3
+ @@html = open(@@url)
4
+ @@doc = Nokogiri::HTML(@@html)
5
+
6
+ @@all = []
7
+
8
+ attr_accessor :name, :definition, :usage
9
+
10
+ def initialize(name, definition, usage)
11
+ @name = name
12
+ @definition = definition
13
+ @usage = usage
14
+ self.save
15
+ end
16
+
17
+ def save
18
+ @@all << self
19
+ end
20
+
21
+ def self.all
22
+ @@all
23
+ end
24
+
25
+ end
@@ -1,21 +1,15 @@
1
1
  class IdiomExplorer
2
2
 
3
- def self.print_list
4
- puts "Below is a list of newly created idioms from MacMillan's Open Dictionary Project"
5
- IdiomScraper.all.each.with_index(1) do |idiom, i|
6
- puts "#{i}. #{idiom.name}"
7
- end
8
- show_idiom
9
- end
10
3
 
11
4
  def self.show_idiom
12
5
  puts "Which idiom would you like me to define?"
13
6
  puts " "
14
7
  input = ((gets.chomp).to_i - 1)
8
+ idiom = Idiom.all[input]
15
9
  puts " "
16
10
  puts "Interesting choice. Here is the definition:".magenta
17
11
  puts " "
18
- puts "#{IdiomScraper.all[input].name.upcase.yellow}: #{IdiomScraper.all[input].definition}"
12
+ puts idiom.name.upcase.yellow + ": " + idiom.definition
19
13
  puts " "
20
14
  puts "Would you like to see this word in context?".light_blue
21
15
  puts "Y/N"
@@ -23,7 +17,7 @@ class IdiomExplorer
23
17
  context = gets.chomp.downcase
24
18
  if context == "y"
25
19
  puts " "
26
- puts IdiomScraper.all[input].usage.green
20
+ puts idiom.usage.green
27
21
  puts " "
28
22
  end
29
23
  end
@@ -3,17 +3,6 @@ class IdiomScraper
3
3
  @@html = open(@@url)
4
4
  @@doc = Nokogiri::HTML(@@html)
5
5
 
6
- @@all = []
7
-
8
- attr_accessor :name, :definition, :usage
9
-
10
- def initialize(name, definition, usage)
11
- @name = name
12
- @definition = definition
13
- @usage = usage
14
- self.save
15
- end
16
-
17
6
  def self.constructor
18
7
  counter = 0
19
8
  @@doc.search(".openEntry").each do |node|
@@ -24,17 +13,10 @@ class IdiomScraper
24
13
  elsif @@doc.search(".openEntry")[counter].css(".openEx").text == ""
25
14
  usage = "It looks like nobody has submitted a sentence yet. Maybe you could write one!"
26
15
  end
27
- IdiomScraper.new(name, definition, usage)
16
+ Idiom.new(name, definition, usage)
28
17
  counter += 1
29
18
  end
30
19
  end
31
20
 
32
- def save
33
- @@all << self
34
- end
35
-
36
- def self.all
37
- @@all
38
- end
39
21
 
40
22
  end
@@ -1,3 +1,3 @@
1
1
  module WordsAndIdioms
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: words_and_idioms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - skmcloughlin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-05 00:00:00.000000000 Z
11
+ date: 2017-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,12 +117,14 @@ files:
117
117
  - lib/words_and_idioms.rb
118
118
  - lib/words_and_idioms/cli.rb
119
119
  - lib/words_and_idioms/dictionary_scraper.rb
120
+ - lib/words_and_idioms/idiom.rb
120
121
  - lib/words_and_idioms/idiom_explorer.rb
121
122
  - lib/words_and_idioms/idiom_scraper.rb
122
123
  - lib/words_and_idioms/user_input.rb
123
124
  - lib/words_and_idioms/version.rb
124
125
  - lib/words_and_idioms/zz - idiom_explorer_old.rb
125
126
  - lib/words_and_idioms/zz - idioms.rb
127
+ - words_and_idioms-0.2.1.gem
126
128
  - words_and_idioms.gemspec
127
129
  homepage: https://github.com/skmcloughlin/WordsAndIdiomsGem
128
130
  licenses: