wiki_on_this_day 0.1.0
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 +7 -0
- data/.gitmodules +3 -0
- data/.learn +8 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +59 -0
- data/LICENSE.md +21 -0
- data/README.md +5 -0
- data/Rakefile +6 -0
- data/bin/console +9 -0
- data/bin/setup +7 -0
- data/bin/wiki_on_this_day +5 -0
- data/lib/wiki_on_this_day/article.rb +11 -0
- data/lib/wiki_on_this_day/cli.rb +24 -0
- data/lib/wiki_on_this_day/homepage.rb +18 -0
- data/lib/wiki_on_this_day/printer.rb +41 -0
- data/lib/wiki_on_this_day/scraper.rb +9 -0
- data/lib/wiki_on_this_day/version.rb +3 -0
- data/lib/wiki_on_this_day.rb +21 -0
- data/spec/fixtures/vcr_cassettes/main_page_2015_12_15.yml +1511 -0
- data/spec/fixtures/vcr_cassettes/oliver_cromwell.yml +8249 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/wiki_on_this_day/wiki_on_this_day_spec.rb +58 -0
- data/wiki_on_this_day.gemspec +28 -0
- metadata +173 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'wiki_on_this_day'
|
2
|
+
require 'vcr'
|
3
|
+
|
4
|
+
VCR.configure do |config|
|
5
|
+
config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
|
6
|
+
config.hook_into :webmock # or :fakeweb
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.expect_with :rspec do |expectations|
|
11
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
12
|
+
end
|
13
|
+
config.mock_with :rspec do |mocks|
|
14
|
+
mocks.verify_partial_doubles = true
|
15
|
+
end
|
16
|
+
|
17
|
+
config.filter_run :focus
|
18
|
+
config.run_all_when_everything_filtered = true
|
19
|
+
|
20
|
+
config.disable_monkey_patching!
|
21
|
+
|
22
|
+
config.warnings = true
|
23
|
+
|
24
|
+
if config.files_to_run.one?
|
25
|
+
config.default_formatter = 'doc'
|
26
|
+
end
|
27
|
+
|
28
|
+
config.profile_examples = 10
|
29
|
+
|
30
|
+
config.order = :default
|
31
|
+
|
32
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
33
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
34
|
+
# test failures related to randomization by passing the same `--seed` value
|
35
|
+
# as the one that triggered the failure.
|
36
|
+
Kernel.srand config.seed
|
37
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe WikiOnThisDay do
|
4
|
+
# If the fixtures are deleted or VCR generates new cassettes these tests
|
5
|
+
# will have to be updated based on current values from:
|
6
|
+
# https://en.wikipedia.org (as well as one of the articles linked
|
7
|
+
# from the "On This Day" section).
|
8
|
+
|
9
|
+
context 'WikiOnThisDay::Scraper::Article' do
|
10
|
+
|
11
|
+
describe '#article_abstract' do
|
12
|
+
it 'correctly scrapes the introductory text from an article' do
|
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.")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'WikiOnThisDay::Scraper::Homepage' do
|
22
|
+
|
23
|
+
describe '#on_this_day' do
|
24
|
+
it 'returns the correct nested hash data from the homepage VCR' do
|
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"}})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wiki_on_this_day/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'wiki_on_this_day'
|
8
|
+
s.version = WikiOnThisDay::VERSION
|
9
|
+
s.date = "2015-12-14"
|
10
|
+
s.summary = "Find out what happened on this day in the past, using Wikipedia!"
|
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 linked article."
|
12
|
+
s.authors = ["Ed Karabinus"]
|
13
|
+
s.email = 'karabinus@uchicago.edu'
|
14
|
+
s.files = `git ls-files`.split($\)
|
15
|
+
s.executables = ["wiki_on_this_day"]
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
s.require_paths = ["lib", "lib/wiki_on_this_day"]
|
18
|
+
s.homepage = 'http://rubygems.org/gems/wiki_on_this_day'
|
19
|
+
s.license = 'MIT'
|
20
|
+
|
21
|
+
s.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
s.add_development_dependency "rake", "~> 10.0"
|
23
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
s.add_development_dependency "nokogiri", "~> 1.6"
|
25
|
+
s.add_development_dependency "pry", "~> 0.10"
|
26
|
+
s.add_development_dependency "vcr", "~> 3.0"
|
27
|
+
s.add_development_dependency "webmock", "~> 1.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wiki_on_this_day
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ed Karabinus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.10'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
description: This gem scrapes the English Wikipedia Homepage (https://en.wikipedia.org/wiki/Main_Page)
|
112
|
+
and obtains the list of significant historical events (and their abstracts) available
|
113
|
+
there. Optionally, users may select one of the historical events and request the
|
114
|
+
text of the linked article.
|
115
|
+
email: karabinus@uchicago.edu
|
116
|
+
executables:
|
117
|
+
- wiki_on_this_day
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files: []
|
120
|
+
files:
|
121
|
+
- ".gitmodules"
|
122
|
+
- ".learn"
|
123
|
+
- ".rspec"
|
124
|
+
- Gemfile
|
125
|
+
- Gemfile.lock
|
126
|
+
- LICENSE.md
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- bin/console
|
130
|
+
- bin/setup
|
131
|
+
- bin/wiki_on_this_day
|
132
|
+
- lib/wiki_on_this_day.rb
|
133
|
+
- lib/wiki_on_this_day/article.rb
|
134
|
+
- lib/wiki_on_this_day/cli.rb
|
135
|
+
- lib/wiki_on_this_day/homepage.rb
|
136
|
+
- lib/wiki_on_this_day/printer.rb
|
137
|
+
- lib/wiki_on_this_day/scraper.rb
|
138
|
+
- lib/wiki_on_this_day/version.rb
|
139
|
+
- spec/fixtures/vcr_cassettes/main_page_2015_12_15.yml
|
140
|
+
- spec/fixtures/vcr_cassettes/oliver_cromwell.yml
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
- spec/wiki_on_this_day/wiki_on_this_day_spec.rb
|
143
|
+
- wiki_on_this_day.gemspec
|
144
|
+
homepage: http://rubygems.org/gems/wiki_on_this_day
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata: {}
|
148
|
+
post_install_message:
|
149
|
+
rdoc_options: []
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
- lib/wiki_on_this_day
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
requirements: []
|
164
|
+
rubyforge_project:
|
165
|
+
rubygems_version: 2.4.5.1
|
166
|
+
signing_key:
|
167
|
+
specification_version: 4
|
168
|
+
summary: Find out what happened on this day in the past, using Wikipedia!
|
169
|
+
test_files:
|
170
|
+
- spec/fixtures/vcr_cassettes/main_page_2015_12_15.yml
|
171
|
+
- spec/fixtures/vcr_cassettes/oliver_cromwell.yml
|
172
|
+
- spec/spec_helper.rb
|
173
|
+
- spec/wiki_on_this_day/wiki_on_this_day_spec.rb
|