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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f025fcc6cc00f284dc5fe806ab2652a8a41d0dc
4
- data.tar.gz: 89993066b18cc7ed940a60fe151ef1ab1aa7d8ba
3
+ metadata.gz: 3e1d6949f584bfb67a213f16d96f04317cf79ace
4
+ data.tar.gz: 1d111c83e0885f4e602b0433015fc77e1d52dd9e
5
5
  SHA512:
6
- metadata.gz: b038c6ff726f64a512fec9eaf43e7eef4637f92991c470b721ce76a2165f744017dc6004cb89986715cdc3b69265c209a0b48716e2b3642d45bdb5724172619f
7
- data.tar.gz: dca0df53e28870e80494b1b067faf527d43f1dec103fe97539da4f6d70797113b3b45f0e7c954c8658880645013bea45abe37eaac633a62800d051fcba75352a
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/
@@ -0,0 +1,3 @@
1
+ require "wish"
2
+
3
+ Wish::run
@@ -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
- # Your code goes here...
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
+
@@ -0,0 +1,14 @@
1
+
2
+
3
+
4
+ module Logger
5
+ class << self
6
+ def info(msg)
7
+ puts Time.new.to_s + " [INFO] " + msg.inspect
8
+ end
9
+
10
+ def error(msg)
11
+ puts Time.new.to_s + " [ERROR] " + msg.inspect
12
+ end
13
+ end
14
+ end
@@ -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
+
@@ -1,3 +1,3 @@
1
1
  module Wish
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,5 @@
1
+ # To change this license header, choose License Headers in Project Properties.
2
+ # To change this template file, choose Tools | Templates
3
+ # and open the template in the editor.
4
+
5
+ puts "Hello World"
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.1
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-07 00:00:00.000000000 Z
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: