wish 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -14
- data/lib/main.rb +3 -0
- data/lib/wish.rb +22 -1
- data/lib/wish/logger.rb +14 -0
- data/lib/wish/receiver.rb +32 -0
- data/lib/wish/version.rb +1 -1
- data/lib/wish/worker.rb +5 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e1d6949f584bfb67a213f16d96f04317cf79ace
|
4
|
+
data.tar.gz: 1d111c83e0885f4e602b0433015fc77e1d52dd9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e518f4d99565ed6ec421cd28d3cdb1ff296ddc318628aa0b469266f6eb87f0270e10f4085b7a6b8ccc90a794195fca8270e3babcbab042b371f355676aa33c65
|
7
|
+
data.tar.gz: 237e8ea1bc257eaf95c0f6a70230168d5337874eb92f01cc2e8c4ba7d58adb557ace3dca7a181678148b9ac7e70fe1b6bf22bcc74c6b61830ff9582687e88511
|
data/.gitignore
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/Gemfile.lock
|
4
|
-
/_yardoc/
|
5
|
-
/coverage/
|
6
|
-
/doc/
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/tmp/
|
10
|
-
*.bundle
|
11
|
-
*.so
|
12
|
-
*.o
|
13
|
-
*.a
|
14
|
-
mkmf.log
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
*.bundle
|
11
|
+
*.so
|
12
|
+
*.o
|
13
|
+
*.a
|
14
|
+
mkmf.log
|
15
|
+
/nbproject/private/
|
data/lib/main.rb
ADDED
data/lib/wish.rb
CHANGED
@@ -1,5 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'eventmachine'
|
3
|
+
require "wish/receiver"
|
4
|
+
require 'wish/logger'
|
1
5
|
require "wish/version"
|
2
6
|
|
3
7
|
module Wish
|
4
|
-
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
attr_accessor :queue
|
12
|
+
|
13
|
+
def run
|
14
|
+
@queue = []
|
15
|
+
puts "Wish service running..."
|
16
|
+
EM::run do
|
17
|
+
EM::start_server("0.0.0.0", 8082, Receiver, @queue)
|
18
|
+
Logger::info "Receiver service start..."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
5
23
|
end
|
24
|
+
|
25
|
+
|
26
|
+
|
data/lib/wish/logger.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
class Receiver < EventMachine::Connection
|
3
|
+
|
4
|
+
attr_accessor :queue
|
5
|
+
|
6
|
+
def initialize queue
|
7
|
+
@queue = queue
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def receive_data data
|
12
|
+
result = find_url data
|
13
|
+
if result == nil
|
14
|
+
send_data "err"
|
15
|
+
else
|
16
|
+
send_data "ok"
|
17
|
+
@queue << result
|
18
|
+
Logger::info "Get a task, now we have " + @queue.size.inspect + " tasks."
|
19
|
+
end
|
20
|
+
close_connection_after_writing
|
21
|
+
end
|
22
|
+
|
23
|
+
def unbind
|
24
|
+
Logger::info "Receiver service close"
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_url headers
|
28
|
+
result = /GET \/[^\?]+\?url=([^\b]+?)\sHTTP\/1/.match(headers)
|
29
|
+
result[1] unless result == nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/lib/wish/version.rb
CHANGED
data/lib/wish/worker.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhenzhong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -50,8 +50,12 @@ files:
|
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
|
+
- lib/main.rb
|
53
54
|
- lib/wish.rb
|
55
|
+
- lib/wish/logger.rb
|
56
|
+
- lib/wish/receiver.rb
|
54
57
|
- lib/wish/version.rb
|
58
|
+
- lib/wish/worker.rb
|
55
59
|
- wish.gemspec
|
56
60
|
homepage: https://github.com/zhenzhong/wish
|
57
61
|
licenses:
|