hacker_term 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,8 @@ hacker_term
2
2
  ==========
3
3
  Hacker News on the Terminal.
4
4
 
5
+ ![Screenshot](http://flydillonfly.files.wordpress.com/2013/01/hacker_term_png1.png)
6
+
5
7
  Installation
6
8
  ------------
7
9
  * Install with `gem install hacker_term`
@@ -18,6 +20,7 @@ See the front page of HN, use the arrow keys to browse and open particular items
18
20
  * Uses the HN feed available at http://hndroidapi.appspot.com - without that resource this project would not exist.
19
21
  * Sorting options included.
20
22
  * Some stats included.
23
+ * Blog post here: http://flydillonfly.wordpress.com/2013/01/01/hacker-news-in-your-terminal/
21
24
 
22
25
  Background
23
26
  ----------
data/lib/hacker_term.rb CHANGED
@@ -28,6 +28,12 @@ module HackerTerm
28
28
  when "DOWN"
29
29
  @page.change_line_pos :up
30
30
 
31
+ when "K"
32
+ @page.change_line_pos :down
33
+
34
+ when "J"
35
+ @page.change_line_pos :up
36
+
31
37
  when "O"
32
38
  launch
33
39
 
@@ -90,4 +96,4 @@ module HackerTerm
90
96
  @ui.show @page
91
97
  end
92
98
  end
93
- end
99
+ end
@@ -28,15 +28,15 @@ module HackerTerm
28
28
  def sort_on!(mode)
29
29
  case mode
30
30
  when :score
31
- @data = @data.sort { |a, b| a['score'].to_f <=> b['score'].to_f }
31
+ @data = @data.sort_by { |a| -a['score'].to_f } # desc
32
32
  when :comments
33
- @data = @data.sort { |a, b| a['comments'].to_f <=> b['comments'].to_f }
33
+ @data = @data.sort_by { |a| -a['comments'].to_f } # desc
34
34
  when :rank
35
- @data = @data.sort { |a, b| a['rank'].to_f <=> b['rank'].to_f }
35
+ @data = @data.sort_by { |a| a['rank'].to_f }
36
36
  when :title
37
- @data = @data.sort { |a, b| a['title'].upcase <=> b['title'].upcase } # Convert all to upper case when comparing
37
+ @data = @data.sort_by { |a| a['title'].upcase }
38
38
  else
39
- throw "sorting mode #{mode} not supported"
39
+ throw "Sorting mode #{mode} not supported!"
40
40
  end
41
41
 
42
42
  @sorted_by = mode.to_s.upcase
@@ -109,4 +109,4 @@ module HackerTerm
109
109
  end
110
110
  end
111
111
  end
112
- end
112
+ end
@@ -1,3 +1,3 @@
1
1
  module HackerTerm
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -114,14 +114,14 @@ module HackerTerm
114
114
 
115
115
  it 'sorts by score when requested' do
116
116
  @pd.sort_on!(:score)
117
- @pd.data.first['title'].should == 'First Article'
118
- @pd.data.last['title'].should == 'Second Article'
117
+ @pd.data.first['title'].should == 'Second Article'
118
+ @pd.data.last['title'].should == 'First Article'
119
119
  end
120
120
 
121
121
  it 'sorts by number of comments when requested' do
122
122
  @pd.sort_on!(:comments)
123
- @pd.data.first['title'].should == 'Third Article'
124
- @pd.data.last['title'].should == 'First Article'
123
+ @pd.data.first['title'].should == 'First Article'
124
+ @pd.data.last['title'].should == 'Third Article'
125
125
  end
126
126
 
127
127
  it 'sorts by rank when requested' do
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.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ciaran Archer
@@ -68,7 +68,6 @@ files:
68
68
  - lib/hacker_term/page_data.rb
69
69
  - lib/hacker_term/ui.rb
70
70
  - lib/hacker_term/version.rb
71
- - run.rb
72
71
  - spec/page_data_spec.rb
73
72
  homepage: https://github.com/ciaranarcher/hacker_term
74
73
  licenses: []
data/run.rb DELETED
@@ -1,5 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/lib')
2
-
3
- require 'hacker_term'
4
- app = HackerTerm::TerminalApp.new
5
- app.run!