whatsa 0.2.2 → 0.2.3

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: 7ac4a4382455cb767f687b48ee577cfbea776f34
4
- data.tar.gz: ee220697878ad879a70bac12da3eb7dd84f54a2c
3
+ metadata.gz: aef97bd6c6bbcfbff00e5fe88ab1e6715de035cb
4
+ data.tar.gz: 4816a33391219a2d92081be925269db130733096
5
5
  SHA512:
6
- metadata.gz: 02c69d6cc696b0e5d8b185de1b0634a335bf154660ed6d31790b03a4e891b5fe8cc3e9959743581c570d1a8206856f6c220348b921d08b5334586126ee12989f
7
- data.tar.gz: 372691d81e21c453a06c37c5cc6365641cdc3922f3375c2e908cabda78d215e7a85afa9fe369877f903cbba13c79e5847a12accac1e4f09db7ac7a333febf2c4
6
+ metadata.gz: 9661681f7cde6a9b5b17807a2a908e18c0eab23a0b053a3a4c4f7cecfcd77ef2401bb3341af3840cc70b6ebf831f7ce5bbc89709b319cbca4514f91cc2e629f5
7
+ data.tar.gz: 87d9ba1a98bb9347d8aef6d369009f0303c096d3d4b31bcfcb2387c56c0f77021aad0f61ff3aaa1e89a5c0d20ae1b75da9d5e23f3f43694868e6f489cd9b6a2e
@@ -6,6 +6,10 @@ class Whatsa::Article
6
6
  @title = noko_doc.css('h1').text
7
7
  @contents = noko_doc.css('#mw-content-text').children
8
8
  @sections = make_sections
9
+
10
+ # comment out the next line if you want sections with non-<p> and non-<ul>
11
+ # content to display as "[no displayable information]"
12
+ remove_empty_sections
9
13
  end
10
14
 
11
15
  def summary
@@ -50,8 +54,10 @@ class Whatsa::Article
50
54
  secs = [Whatsa::Section.new("#{self.title} - Introduction", intro_pars)]
51
55
  indices.each_cons(2) do |i, j|
52
56
  title = self.contents[i].text.gsub('[edit]', '').strip
53
- par_nodes = self.contents[i...j].select { |e| e.name == 'p' && e.text != "" }
54
- pars = par_nodes.map { |par| par.text }
57
+ par_nodes = self.contents[i...j].select do |e|
58
+ e.name == 'p' || e.name == 'ul' && e.text != ""
59
+ end
60
+ pars = par_nodes.map { |par| par.text.strip }
55
61
  secs << Whatsa::Section.new(title, pars).tap { |s| s.article = self }
56
62
  end
57
63
  secs
@@ -64,4 +70,8 @@ class Whatsa::Article
64
70
  end
65
71
  indices
66
72
  end
73
+
74
+ def remove_empty_sections
75
+ self.sections.reject! { |sec| sec.summary == "[no displayable information]" }
76
+ end
67
77
  end
@@ -5,6 +5,7 @@ class Whatsa::Section
5
5
  @title = title
6
6
  @paragraphs = paragraphs
7
7
  remove_citations
8
+ bullet_list_pars
8
9
  end
9
10
 
10
11
  def summary
@@ -21,4 +22,8 @@ class Whatsa::Section
21
22
  self.paragraphs.map! { |par| par.gsub(/\[(\d+|citation needed)\]/, "") }
22
23
  end
23
24
 
25
+ def bullet_list_pars
26
+ self.paragraphs.map! { |par| par.index("\n") ? par.gsub(/^/, "- ") : par }
27
+ end
28
+
24
29
  end
@@ -1,3 +1,3 @@
1
1
  module Whatsa
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application (You can access Whatsa by running the command `whatsa` after installing it, then follow the on-screen instructions in your terminal to interact. The rest is explained in the README.)
5
+ - [x] Pull data from an external source (This application pulls data from articles, disambiguation pages, and search results pages on Wikipedia.org)
6
+ - [x] Implement both list and detail views (If you make a query that is ambiguous, the app will present a list to you, from which you can select a choice by number or name. If you wish to read from a specific category/section of an article, you can type `other` and it will present a similarly-selectable list of sections. Once you get to an article or a section, it will display its summary, and if you'd like more, you can ask for that too.)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whatsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keegan Leitz
@@ -93,6 +93,7 @@ files:
93
93
  - lib/whatsa/scraper.rb
94
94
  - lib/whatsa/section.rb
95
95
  - lib/whatsa/version.rb
96
+ - spec.md
96
97
  - whatsa.gemspec
97
98
  homepage: https://github.com/kjleitz/whatsa
98
99
  licenses: