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.
@@ -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::Scraper::Article' do
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::Scraper::Article.new("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.")
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 '#on_this_day' do
24
- it 'returns the correct nested hash data from the homepage VCR' do
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(WikiOnThisDay::Scraper::Homepage.new.on_this_day).to eq({"Battle of Noryang"=>
27
- {:year=>"1598",
28
- :text=>
29
- "Admiral Yi Sun-sin's Korean navy defeated the Japanese fleet at the Battle of Noryang, the final naval battle of the Imjin War.",
30
- :link_url=>"https://en.wikipedia.org/wiki/Battle_of_Noryang"},
31
- "Oliver Cromwell"=>
32
- {:year=>"1653",
33
- :text=>
34
- "Oliver Cromwell (pictured) became Lord Protector of the Commonwealth of England.",
35
- :link_url=>"https://en.wikipedia.org/wiki/Oliver_Cromwell"},
36
- "Lithuanian Soviet Socialist Republic"=>
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
@@ -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 = "2015-12-14"
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.1.1
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: 2015-12-14 00:00:00.000000000 Z
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: nokogiri
56
+ name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.6'
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: '1.6'
68
+ version: '0.10'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry
70
+ name: vcr
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.10'
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.10'
82
+ version: '3.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: vcr
84
+ name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
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: '3.0'
96
+ version: '1.0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: webmock
98
+ name: nokogiri
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.0'
104
- type: :development
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.0'
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
@@ -1,11 +0,0 @@
1
- class WikiOnThisDay::Scraper::Article < WikiOnThisDay::Scraper
2
-
3
- def initialize(link_url)
4
- super(link_url)
5
- end
6
-
7
- def article_abstract
8
- self.html_doc.css('div#mw-content-text > p').first.text
9
- end
10
-
11
- end