hacker_term 0.0.2 → 0.0.3
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/README.md +3 -0
- data/lib/hacker_term.rb +7 -1
- data/lib/hacker_term/page_data.rb +6 -6
- data/lib/hacker_term/version.rb +1 -1
- data/spec/page_data_spec.rb +4 -4
- metadata +1 -2
- data/run.rb +0 -5
data/README.md
CHANGED
@@ -2,6 +2,8 @@ hacker_term
|
|
2
2
|
==========
|
3
3
|
Hacker News on the Terminal.
|
4
4
|
|
5
|
+

|
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.
|
31
|
+
@data = @data.sort_by { |a| -a['score'].to_f } # desc
|
32
32
|
when :comments
|
33
|
-
@data = @data.
|
33
|
+
@data = @data.sort_by { |a| -a['comments'].to_f } # desc
|
34
34
|
when :rank
|
35
|
-
@data = @data.
|
35
|
+
@data = @data.sort_by { |a| a['rank'].to_f }
|
36
36
|
when :title
|
37
|
-
@data = @data.
|
37
|
+
@data = @data.sort_by { |a| a['title'].upcase }
|
38
38
|
else
|
39
|
-
throw "
|
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
|
data/lib/hacker_term/version.rb
CHANGED
data/spec/page_data_spec.rb
CHANGED
@@ -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 == '
|
118
|
-
@pd.data.last['title'].should == '
|
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 == '
|
124
|
-
@pd.data.last['title'].should == '
|
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.
|
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: []
|