what_a_world 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/what_a_world/cli.rb +8 -8
- data/lib/what_a_world/print_fit.rb +27 -0
- data/lib/what_a_world/scraper.rb +6 -10
- data/lib/what_a_world/version.rb +1 -1
- data/lib/what_a_world.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f02f245188882c2e5b7b412e28f88be6d46ecb
|
4
|
+
data.tar.gz: 6c1bae5ee86d6b63fdf09ca5718689168f337f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9252a93ac5b9a13ea634f8506b6726e4db8b7e6147c65678feb42621b4abc54fe25d0adc279db868145749870f48969e32b2f60f5f82bfb8027e09d32be036e1
|
7
|
+
data.tar.gz: 396c5128dfa0aa9e72d6e02f2070f112633bf666685721f5c08a51c5c08bc2afad29a7c37f9e254e5549ee7d50d963bbfcb21b013ae2168beb68787cd960fab6
|
data/.DS_Store
CHANGED
Binary file
|
data/lib/.DS_Store
CHANGED
Binary file
|
data/lib/what_a_world/cli.rb
CHANGED
@@ -27,16 +27,16 @@ class WhatAWorld::CLI
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def welcome
|
30
|
-
|
30
|
+
"What A World!".print_fit
|
31
31
|
sleep(1.0)
|
32
|
-
|
32
|
+
"Explore transnational issues on a location-by-location basis.".print_fit
|
33
33
|
sleep(1.0)
|
34
|
-
|
34
|
+
"Information provided by the C.I.A.".print_fit
|
35
35
|
end
|
36
36
|
|
37
37
|
def goodbye
|
38
38
|
puts ""
|
39
|
-
|
39
|
+
"Goodbye, and peace to the world!".print_fit
|
40
40
|
puts ""
|
41
41
|
end
|
42
42
|
|
@@ -103,22 +103,22 @@ class WhatAWorld::CLI
|
|
103
103
|
if !trafficking.empty?
|
104
104
|
puts "__________________________________"
|
105
105
|
puts "#{trafficking_label}".colorize(:red)
|
106
|
-
|
106
|
+
trafficking.print_fit
|
107
107
|
end
|
108
108
|
if !drugs.empty?
|
109
109
|
puts "__________________________________"
|
110
110
|
puts "#{drugs_label}".colorize(:red)
|
111
|
-
|
111
|
+
drugs.print_fit
|
112
112
|
end
|
113
113
|
if !refugees.empty?
|
114
114
|
puts "__________________________________"
|
115
115
|
puts "#{refugees_label}".colorize(:red)
|
116
|
-
|
116
|
+
refugees.print_fit
|
117
117
|
end
|
118
118
|
if !disputes.empty?
|
119
119
|
puts "__________________________________"
|
120
120
|
puts "#{disputes_label}".colorize(:red)
|
121
|
-
|
121
|
+
disputes.print_fit
|
122
122
|
end
|
123
123
|
if disputes.empty? && refugees.empty? && drugs.empty? && trafficking.empty?
|
124
124
|
puts "__________________________________"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
def print_fit
|
4
|
+
dimensions = IO.console.winsize
|
5
|
+
window_length = dimensions[1]
|
6
|
+
word_array = self.split(" ")
|
7
|
+
word_index = 0
|
8
|
+
|
9
|
+
remaining_room = window_length
|
10
|
+
while remaining_room >= 0 && word_index < word_array.size
|
11
|
+
remaining_room -= word_array[word_index].size
|
12
|
+
if remaining_room >=0
|
13
|
+
print word_array[word_index]
|
14
|
+
if remaining_room > 0
|
15
|
+
print " "
|
16
|
+
remaining_room -= 1
|
17
|
+
end
|
18
|
+
else
|
19
|
+
puts ""
|
20
|
+
print word_array[word_index] + " "
|
21
|
+
remaining_room = window_length - word_array[word_index].size - 1
|
22
|
+
end
|
23
|
+
word_index += 1
|
24
|
+
end
|
25
|
+
puts ""
|
26
|
+
end
|
27
|
+
end
|
data/lib/what_a_world/scraper.rb
CHANGED
@@ -86,19 +86,15 @@ class WhatAWorld::Scraper
|
|
86
86
|
mod_extension = mod_extension.join
|
87
87
|
end
|
88
88
|
|
89
|
-
def create_string(iterator)
|
90
|
-
"//ul[last()]/li[last()]/div[" + iterator.to_s + "]"
|
91
|
-
end
|
92
|
-
|
93
89
|
def scraped_string(iterator)
|
94
|
-
@country_page.
|
90
|
+
@country_page.css("li").last.css("div")[iterator].text.strip if @country_page.css("li").last.css("div")[iterator]
|
95
91
|
end
|
96
92
|
|
97
93
|
def scrape_issues
|
98
|
-
iterator =
|
94
|
+
iterator = 0
|
99
95
|
scraped_string(iterator)
|
100
|
-
|
101
|
-
while
|
96
|
+
finished = false
|
97
|
+
while !finished
|
102
98
|
if @@disputes == scraped_string(iterator)
|
103
99
|
iterator = add_content(iterator, self.disputes_content)
|
104
100
|
elsif @@refugees == scraped_string(iterator)
|
@@ -108,7 +104,7 @@ class WhatAWorld::Scraper
|
|
108
104
|
elsif @@drugs == scraped_string(iterator)
|
109
105
|
iterator = add_content(iterator, self.drugs_content)
|
110
106
|
else
|
111
|
-
|
107
|
+
finished = true
|
112
108
|
end
|
113
109
|
end
|
114
110
|
self.disputes_hash[@@disputes] = self.disputes_content
|
@@ -120,7 +116,7 @@ class WhatAWorld::Scraper
|
|
120
116
|
def add_content(iterator, content)
|
121
117
|
iterator +=1
|
122
118
|
scraped = scraped_string(iterator)
|
123
|
-
while scraped != @@disputes && scraped != @@refugees && scraped != @@trafficking && scraped != @@drugs && scraped !=
|
119
|
+
while scraped != @@disputes && scraped != @@refugees && scraped != @@trafficking && scraped != @@drugs && scraped != nil
|
124
120
|
content << scraped
|
125
121
|
iterator +=1
|
126
122
|
scraped = scraped_string(iterator)
|
data/lib/what_a_world/version.rb
CHANGED
data/lib/what_a_world.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: what_a_world
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gb23
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/what_a_world/cli.rb
|
107
107
|
- lib/what_a_world/country.rb
|
108
108
|
- lib/what_a_world/issues.rb
|
109
|
+
- lib/what_a_world/print_fit.rb
|
109
110
|
- lib/what_a_world/scraper.rb
|
110
111
|
- lib/what_a_world/version.rb
|
111
112
|
- spec.md
|