wiki_on_this_day 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/bin/wiki_on_this_day +1 -1
- data/config/environment.rb +9 -0
- data/lib/wiki_on_this_day.rb +1 -18
- data/lib/wiki_on_this_day/cli.rb +4 -5
- data/lib/wiki_on_this_day/homepage.rb +8 -9
- data/lib/wiki_on_this_day/printer.rb +5 -32
- data/lib/wiki_on_this_day/scraper.rb +0 -1
- data/lib/wiki_on_this_day/snippet.rb +14 -0
- data/lib/wiki_on_this_day/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/main_page_2015_12_15.yml +13560 -1429
- data/spec/wiki_on_this_day/wiki_on_this_day_spec.rb +15 -30
- data/wiki_on_this_day.gemspec +2 -2
- metadata +17 -16
- data/lib/wiki_on_this_day/article.rb +0 -11
@@ -6,12 +6,12 @@ RSpec.describe WikiOnThisDay do
|
|
6
6
|
# https://en.wikipedia.org (as well as one of the articles linked
|
7
7
|
# from the "On This Day" section).
|
8
8
|
|
9
|
-
context 'WikiOnThisDay::
|
9
|
+
context 'WikiOnThisDay::Snippet' do
|
10
10
|
|
11
11
|
describe '#article_abstract' do
|
12
12
|
it 'correctly scrapes the introductory text from an article' do
|
13
13
|
VCR.use_cassette("oliver_cromwell") do
|
14
|
-
expect(WikiOnThisDay::
|
14
|
+
expect(WikiOnThisDay::Snippet.new(link_url: "https://en.wikipedia.org/wiki/Oliver_Cromwell").article_abstract).to eq("Oliver Cromwell (25 April 1599 – 3 September 1658)[a] was an English military and political leader and later Lord Protector of the Commonwealth of England, Scotland and Ireland.")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -20,35 +20,20 @@ RSpec.describe WikiOnThisDay do
|
|
20
20
|
|
21
21
|
context 'WikiOnThisDay::Scraper::Homepage' do
|
22
22
|
|
23
|
-
describe '
|
24
|
-
it '
|
23
|
+
describe 'summarize' do
|
24
|
+
it 'prints the correct data from the homepage VCR' do
|
25
25
|
VCR.use_cassette("main_page_2015_12_15") do
|
26
|
-
expect
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
{:year=>"1918",
|
38
|
-
:text=>
|
39
|
-
"Vincas Mickevičius-Kapsukas declared the formation of the Lithuanian Soviet Socialist Republic, a puppet state created by Soviet Russia to justify the Lithuanian–Soviet War.",
|
40
|
-
:link_url=>
|
41
|
-
"https://en.wikipedia.org/wiki/Lithuanian_Soviet_Socialist_Republic_(1918%E2%80%9319)"},
|
42
|
-
"Herman Lamm"=>
|
43
|
-
{:year=>"1930",
|
44
|
-
:text=>
|
45
|
-
"Herman Lamm, \"the father of modern bank robbery\", killed himself during a botched robbery attempt in Clinton, Indiana, US, rather than be captured by police.",
|
46
|
-
:link_url=>"https://en.wikipedia.org/wiki/Herman_Lamm"},
|
47
|
-
"gang-raped on a bus"=>
|
48
|
-
{:year=>"2012",
|
49
|
-
:text=>
|
50
|
-
"A woman in New Delhi was gang-raped on a bus, generating public protests across the country against the Government of India and the Government of Delhi for not providing adequate security for women.",
|
51
|
-
:link_url=>"https://en.wikipedia.org/wiki/2012_Delhi_gang_rape"}})
|
26
|
+
expect { WikiOnThisDay::Scraper::Homepage.new.summarize }.to output("1410
|
27
|
+
The Yongle Emperor launched the first of his military campaigns against the Mongols, resulting in the fall of the Mongol khan Bunyashiri.
|
28
|
+
1807
|
29
|
+
The Slave Trade Act became law, abolishing the slave trade in the British Empire.
|
30
|
+
1917
|
31
|
+
Following the overthrow of the Russian tsar Nicholas II, Georgia's bishops unilaterally restored the autocephaly of the Georgian Orthodox Church.
|
32
|
+
1949
|
33
|
+
The Soviet Union began mass deportations of more than 90,000 people from the Baltic states to Siberia.
|
34
|
+
2006
|
35
|
+
A gunman in Seattle, Washington, US, entered a rave afterparty and opened fire, killing six and wounding two, before committing suicide.
|
36
|
+
").to_stdout
|
52
37
|
end
|
53
38
|
end
|
54
39
|
end
|
data/wiki_on_this_day.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'wiki_on_this_day/version'
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'wiki_on_this_day'
|
8
8
|
s.version = WikiOnThisDay::VERSION
|
9
|
-
s.date = "
|
9
|
+
s.date = "2016-03-25"
|
10
10
|
s.summary = "Find out what happened on this day in the past, using Wikipedia!"
|
11
11
|
s.description = "This gem scrapes the English Wikipedia Homepage (https://en.wikipedia.org/wiki/Main_Page) and obtains the list of significant historical events (and their abstracts) available there. Optionally, users may select one of the historical events and request the text of the first paragraph of the linked article."
|
12
12
|
s.authors = ["Ed Karabinus"]
|
@@ -21,8 +21,8 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency "bundler", "~> 1.10"
|
22
22
|
s.add_development_dependency "rake", "~> 10.0"
|
23
23
|
s.add_development_dependency "rspec", "~> 3.0"
|
24
|
-
s.add_development_dependency "nokogiri", "~> 1.6"
|
25
24
|
s.add_development_dependency "pry", "~> 0.10"
|
26
25
|
s.add_development_dependency "vcr", "~> 3.0"
|
27
26
|
s.add_development_dependency "webmock", "~> 1.0"
|
27
|
+
s.add_dependency "nokogiri", "~> 1.6"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wiki_on_this_day
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Karabinus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,61 +53,61 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: vcr
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
75
|
+
version: '3.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
82
|
+
version: '3.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: nokogiri
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
104
|
-
type: :
|
103
|
+
version: '1.6'
|
104
|
+
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
110
|
+
version: '1.6'
|
111
111
|
description: This gem scrapes the English Wikipedia Homepage (https://en.wikipedia.org/wiki/Main_Page)
|
112
112
|
and obtains the list of significant historical events (and their abstracts) available
|
113
113
|
there. Optionally, users may select one of the historical events and request the
|
@@ -129,12 +129,13 @@ files:
|
|
129
129
|
- bin/console
|
130
130
|
- bin/setup
|
131
131
|
- bin/wiki_on_this_day
|
132
|
+
- config/environment.rb
|
132
133
|
- lib/wiki_on_this_day.rb
|
133
|
-
- lib/wiki_on_this_day/article.rb
|
134
134
|
- lib/wiki_on_this_day/cli.rb
|
135
135
|
- lib/wiki_on_this_day/homepage.rb
|
136
136
|
- lib/wiki_on_this_day/printer.rb
|
137
137
|
- lib/wiki_on_this_day/scraper.rb
|
138
|
+
- lib/wiki_on_this_day/snippet.rb
|
138
139
|
- lib/wiki_on_this_day/version.rb
|
139
140
|
- spec/fixtures/vcr_cassettes/main_page_2015_12_15.yml
|
140
141
|
- spec/fixtures/vcr_cassettes/oliver_cromwell.yml
|