zlx_hacker_term 0.0.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,5 +12,5 @@ Requirements
12
12
  Installation
13
13
  ------------
14
14
  * Install with `gem install hacker_term`
15
- * Run using `socksify_ruby 127.0.0.1 1080 run_hacker_term`
15
+ * Run using `hacker_term [socks_server] [socks_port]`
16
16
  * Tests included; I run them using `rspec -fd` in the project directory
@@ -2,5 +2,21 @@
2
2
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
3
  require 'hacker_term'
4
4
 
5
- app = HackerTerm::TerminalApp.new
6
- exit app.run!
5
+ @default_socks_server = '127.0.0.1'
6
+ @default_socks_port = 1080
7
+
8
+ if ARGV.size == 2
9
+ socks_server = ARGV.shift
10
+ socks_port = ARGV.shift
11
+ elsif ARGV.size == 0
12
+ socks_server = @default_socks_server
13
+ socks_port = @default_socks_port
14
+ else
15
+ puts "Usage: hacker_term [socks_server] [socks_port]"
16
+ puts "Default: socks_server: 127.0.0.1"
17
+ puts " socks_port: 1080"
18
+ exit
19
+ end
20
+
21
+ app = HackerTerm::TerminalApp.new(socks_server, socks_port)
22
+ exit app.run!
@@ -3,10 +3,13 @@ require 'hacker_term/ui'
3
3
  require 'rest_client'
4
4
  require 'launchy'
5
5
  require 'clipboard'
6
+ require 'socksify'
6
7
 
7
8
  module HackerTerm
8
9
  class TerminalApp
9
- def initialize
10
+ def initialize(socks_server, socks_port)
11
+ @socks_server = socks_server
12
+ @socks_port = socks_port
10
13
  @raw_json = read_json
11
14
  load
12
15
  end
@@ -82,18 +85,11 @@ module HackerTerm
82
85
  end
83
86
 
84
87
  def read_json
85
- local_proxy = get_local_proxy
86
- #RestClient.proxy = local_proxy unless local_proxy.nil?
88
+ TCPSocket::socks_server = @socks_server
89
+ TCPSocket::socks_port = @socks_port
87
90
  RestClient.get 'http://hndroidapi.appspot.com/news/format/json/page/'
88
91
  end
89
92
 
90
- def get_local_proxy
91
- # Cater for both upper and lower case env variables
92
- local_proxy = ENV['all_proxy']
93
- return local_proxy unless local_proxy.nil?
94
- ENV['http_proxy']
95
- end
96
-
97
93
  def clear_and_show
98
94
  @ui.clear!
99
95
  @ui.show @page
@@ -1,3 +1,3 @@
1
1
  module HackerTerm
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: zlx_hacker_term
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - soffolk zhu
@@ -96,7 +96,6 @@ files:
96
96
  - lib/hacker_term/page_data.rb
97
97
  - lib/hacker_term/ui.rb
98
98
  - lib/hacker_term/version.rb
99
- - lib/run_hacker_term
100
99
  - spec/page_data_spec.rb
101
100
  homepage: https://github.com/zlx/hacker_term
102
101
  licenses: []
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
- require 'hacker_term'
4
-
5
- app = HackerTerm::TerminalApp.new
6
- exit app.run!