hacker_term 0.0.5 → 0.0.6
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.
- data/.gitignore +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +1 -1
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/data/comments.json +0 -0
- data/data/data.json +0 -0
- data/data/lorem.txt +0 -0
- data/hacker_term.gemspec +0 -0
- data/lib/hacker_term/comments_data.rb +0 -0
- data/lib/hacker_term/page_data.rb +11 -3
- data/lib/hacker_term/ui.rb +0 -0
- data/lib/hacker_term/version.rb +1 -1
- data/lib/hacker_term.rb +0 -0
- data/spec/comments_data_spec.rb +0 -0
- data/spec/page_data_spec.rb +0 -0
- metadata +2 -2
data/.gitignore
CHANGED
|
File without changes
|
data/.travis.yml
CHANGED
|
File without changes
|
data/Gemfile
CHANGED
|
File without changes
|
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
File without changes
|
data/Rakefile
CHANGED
|
File without changes
|
data/data/comments.json
CHANGED
|
File without changes
|
data/data/data.json
CHANGED
|
File without changes
|
data/data/lorem.txt
CHANGED
|
File without changes
|
data/hacker_term.gemspec
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -13,13 +13,17 @@ module HackerTerm
|
|
|
13
13
|
attr_reader :data, :mean_score, :median_score, :mode_score, :sorted_by, :line_pos
|
|
14
14
|
|
|
15
15
|
def initialize(data)
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
begin
|
|
17
|
+
@data = JSON.parse(data)['items']
|
|
18
|
+
rescue JSON::ParserError
|
|
19
|
+
raise "JSON appears to be malformed: #{unescaped}" # Bomb out for now...
|
|
20
|
+
end
|
|
18
21
|
|
|
19
22
|
add_missing_keys!
|
|
20
23
|
format_numbers!
|
|
21
24
|
format_urls!
|
|
22
|
-
|
|
25
|
+
unescape_titles!
|
|
26
|
+
|
|
23
27
|
calculate_mean_score
|
|
24
28
|
calculate_median_score
|
|
25
29
|
calculate_mode_score
|
|
@@ -28,6 +32,10 @@ module HackerTerm
|
|
|
28
32
|
@line_pos = 1
|
|
29
33
|
end
|
|
30
34
|
|
|
35
|
+
def unescape_titles!
|
|
36
|
+
@data.each { |row| row['title'] = CGI.unescapeHTML(row['title']) }
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
def sort_on!(mode)
|
|
32
40
|
case mode
|
|
33
41
|
when :score
|
data/lib/hacker_term/ui.rb
CHANGED
|
File without changes
|
data/lib/hacker_term/version.rb
CHANGED
data/lib/hacker_term.rb
CHANGED
|
File without changes
|
data/spec/comments_data_spec.rb
CHANGED
|
File without changes
|
data/spec/page_data_spec.rb
CHANGED
|
File without changes
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: hacker_term
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.0.
|
|
5
|
+
version: 0.0.6
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Ciaran Archer
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2013-01-
|
|
13
|
+
date: 2013-01-09 00:00:00 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rest-client
|