hacker_term 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hacker_term (0.0.4)
4
+ hacker_term (0.0.5)
5
5
  clipboard
6
6
  launchy
7
7
  rest-client
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
- unescaped = CGI.unescapeHTML data
17
- @data = JSON.parse(unescaped)['items']
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
File without changes
@@ -1,3 +1,3 @@
1
1
  module HackerTerm
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/hacker_term.rb CHANGED
File without changes
File without changes
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
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-07 00:00:00 Z
13
+ date: 2013-01-09 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client