pergo 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.travis.yml +8 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +9 -0
- data/bin/pergo +14 -0
- data/lib/pergo.rb +11 -0
- data/lib/pergo/configuration.rb +33 -0
- data/lib/pergo/server.rb +35 -0
- data/lib/pergo/version.rb +3 -0
- data/pergo.gemspec +27 -0
- data/test/configuration_test.rb +67 -0
- data/test/server_test.rb +20 -0
- data/test/test_helper.rb +31 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b259fc4258fdf389efd73c7923591bfc2ffb35b
|
4
|
+
data.tar.gz: 822119c6c5226bca3f3793476f0db3b4e293dae8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e142832d63c19ebdfd930c8e420c285ea1579809e040dead722cf5c23ff470b787bb2b14922cf96a657cfbbac90f54b21a3d2c80ae00513fed0c8d32f4334c6
|
7
|
+
data.tar.gz: ef1bbdd0e283957bb756ebe779efbc8c264370914ad7cc405c14cf6602bf50b5e2a2fed57e3be4be40d230c5429a3bdb69d632e34d7f3aeeea925c9fcbef9e23
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*.swp
|
2
|
+
*.swn
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
.bundle
|
6
|
+
.config
|
7
|
+
.yardoc
|
8
|
+
Gemfile.lock
|
9
|
+
InstalledFiles
|
10
|
+
_yardoc
|
11
|
+
coverage
|
12
|
+
doc/
|
13
|
+
lib/bundler/man
|
14
|
+
pkg
|
15
|
+
rdoc
|
16
|
+
spec/reports
|
17
|
+
test/tmp
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
20
|
+
queue.yaml
|
21
|
+
config.yml
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 MalcyL
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# udp2sqs-server
|
2
|
+
|
3
|
+
Simple UDP server. Posts UDP payloads to a configured AWS SQS queue.
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/meducation/udp2sqs-server.png)](https://travis-ci.org/meducation/udp2sqs-server)
|
6
|
+
[![Dependencies](https://gemnasium.com/meducation/udp2sqs-server.png?travis)](https://gemnasium.com/meducation/udp2sqs-server)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/meducation/udp2sqs-server.png)](https://codeclimate.com/github/meducation/udp2sqs-server)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'udp2sqs-server'
|
14
|
+
|
15
|
+
If you want to use the latest version from Github, you can do:
|
16
|
+
|
17
|
+
gem 'udp2sqs-server', github: "meducation/udp2sqs-server"
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
To complete the installation copy queue.yaml.example to queue.yaml and fill in your
|
24
|
+
|
25
|
+
* aws-access-key
|
26
|
+
* aws-secret-key
|
27
|
+
* aws-sqs-url
|
28
|
+
* aws-region
|
29
|
+
|
30
|
+
To run the server type:
|
31
|
+
|
32
|
+
<pre>
|
33
|
+
./bin/udp2sqs hostname port
|
34
|
+
</pre>
|
35
|
+
|
36
|
+
with the hostname and port of the server you want to listen to UDP messages from. For exxample:
|
37
|
+
|
38
|
+
<pre>
|
39
|
+
./bin/udp2sqs 0.0.0.0 9732
|
40
|
+
</pre>
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
Firstly, thank you!! :heart::sparkling_heart::heart:
|
45
|
+
|
46
|
+
Please read our [contributing guide](https://github.com/meducation/udp2sqs-client/tree/master/CONTRIBUTING.md) for information on how to get stuck in.
|
47
|
+
|
48
|
+
## Licence
|
49
|
+
|
50
|
+
Copyright (C) 2013 New Media Education Ltd
|
51
|
+
|
52
|
+
This program is free software: you can redistribute it and/or modify
|
53
|
+
it under the terms of the GNU Affero General Public License as published by
|
54
|
+
the Free Software Foundation, either version 3 of the License, or
|
55
|
+
(at your option) any later version.
|
56
|
+
|
57
|
+
This program is distributed in the hope that it will be useful,
|
58
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
59
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
60
|
+
GNU Affero General Public License for more details.
|
61
|
+
|
62
|
+
A copy of the GNU Affero General Public License is available in [Licence.md](https://github.com/meducation/udp2sqs-client/blob/master/LICENCE.md)
|
63
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/Rakefile
ADDED
data/bin/pergo
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path('../../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require "pergo"
|
7
|
+
|
8
|
+
config = YAML.load_file("config.yml")
|
9
|
+
Pergo.config.access_key = config["access_key"]
|
10
|
+
Pergo.config.secret_key = config["secret_key"]
|
11
|
+
Pergo.config.queue_region = config["queue_region"]
|
12
|
+
Pergo.config.topic = config["topic"]
|
13
|
+
|
14
|
+
Pergo::Server.run(host: ARGV[0], port: ARGV[1])
|
data/lib/pergo.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Pergo
|
4
|
+
|
5
|
+
class ConfigurationError < Exception
|
6
|
+
end
|
7
|
+
|
8
|
+
class Configuration
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
SETTINGS = [
|
12
|
+
:access_key, :secret_key, :queue_region,
|
13
|
+
:topic,
|
14
|
+
:host, :port
|
15
|
+
]
|
16
|
+
attr_writer *SETTINGS
|
17
|
+
|
18
|
+
SETTINGS.each do |setting|
|
19
|
+
define_method setting do
|
20
|
+
get_or_raise(setting)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def get_or_raise(setting)
|
27
|
+
instance_variable_get("@#{setting.to_s}") ||
|
28
|
+
raise(ConfigurationError.new("Configuration for #{setting} is not set"))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
data/lib/pergo/server.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'propono'
|
2
|
+
|
3
|
+
module Pergo
|
4
|
+
class Server
|
5
|
+
|
6
|
+
def self.run(*args)
|
7
|
+
new(*args).run
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@host = options.fetch(:host, "0.0.0.0")
|
12
|
+
@port = options.fetch(:port, 9732)
|
13
|
+
|
14
|
+
Propono.config.access_key = config.access_key
|
15
|
+
Propono.config.secret_key = config.secret_key
|
16
|
+
Propono.config.queue_region = config.queue_region
|
17
|
+
Propono.config.udp_host = config.host
|
18
|
+
Propono.config.udp_port = config.port
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
Propono.listen_to_udp do |text|
|
23
|
+
Propono.publish(config.topic, text)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def config
|
30
|
+
Configuration.instance
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
data/pergo.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pergo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pergo"
|
8
|
+
spec.version = Pergo::VERSION
|
9
|
+
spec.authors = ["MalcyL, mmmmmrob", "iHiD"]
|
10
|
+
spec.email = ["malcolm@landonsonline.me.uk, rob@dynamicorange.com", "jeremy@meducation.net"]
|
11
|
+
spec.description = %q{A simple wrapper of Propono.}
|
12
|
+
spec.summary = %q{See also Propono, a pub/sub build on AWS.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "AGPL3"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "propono"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "mocha"
|
26
|
+
spec.add_development_dependency "minitest", "~> 5.0.8"
|
27
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pergo
|
4
|
+
class ConfigurationTest < Minitest::Test
|
5
|
+
def config
|
6
|
+
@config ||= Configuration.send(:new)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_obtaining_singletion
|
10
|
+
refute config.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_unable_to_create_instance
|
14
|
+
assert_raises(NoMethodError) do
|
15
|
+
config = Configuration.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_access_key
|
20
|
+
access_key = "test-access-key"
|
21
|
+
config.access_key = access_key
|
22
|
+
assert_equal access_key, config.access_key
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_secret_key
|
26
|
+
secret_key = "test-secret-key"
|
27
|
+
config.secret_key = secret_key
|
28
|
+
assert_equal secret_key, config.secret_key
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_queue_region
|
32
|
+
val = "test-topic"
|
33
|
+
config.queue_region = val
|
34
|
+
assert_equal val, config.queue_region
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_queue_udp_host
|
38
|
+
val = "test-topic"
|
39
|
+
config.host = val
|
40
|
+
assert_equal val, config.host
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_udp_port
|
44
|
+
val = "test-topic"
|
45
|
+
config.port = val
|
46
|
+
assert_equal val, config.port
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_missing_access_key_throws_exception
|
50
|
+
assert_raises(ConfigurationError) do
|
51
|
+
config.access_key
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_missing_secret_key_throws_exception
|
56
|
+
assert_raises(ConfigurationError) do
|
57
|
+
config.secret_key
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_missing_topic_throws_exception
|
62
|
+
assert_raises(ConfigurationError) do
|
63
|
+
config.topic
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/test/server_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pergo
|
4
|
+
class ServerTest < Minitest::Test
|
5
|
+
|
6
|
+
def test_initialization
|
7
|
+
server = Server.new
|
8
|
+
assert_equal "0.0.0.0", server.instance_variable_get("@host")
|
9
|
+
assert_equal 9732, server.instance_variable_get("@port")
|
10
|
+
assert_equal config.access_key, Propono.config.access_key
|
11
|
+
assert_equal config.secret_key, Propono.config.secret_key
|
12
|
+
assert_equal config.queue_region, Propono.config.queue_region
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_listen_to_sqs_in_called
|
16
|
+
Propono.expects(:listen_to_udp)
|
17
|
+
Server.run
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#require "codeclimate-test-reporter"
|
2
|
+
#CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
gem "minitest"
|
5
|
+
require "minitest/autorun"
|
6
|
+
require "minitest/pride"
|
7
|
+
require "minitest/mock"
|
8
|
+
require "mocha/setup"
|
9
|
+
|
10
|
+
lib = File.expand_path('../../lib', __FILE__)
|
11
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
12
|
+
|
13
|
+
require "pergo"
|
14
|
+
|
15
|
+
#Fog.mock!
|
16
|
+
|
17
|
+
class Minitest::Test
|
18
|
+
def setup
|
19
|
+
Pergo::Configuration.instance.access_key = "test-access-key"
|
20
|
+
Pergo::Configuration.instance.secret_key = "test-secret-key"
|
21
|
+
Pergo::Configuration.instance.topic = "test-topic"
|
22
|
+
Pergo::Configuration.instance.queue_region = "test-queue-region"
|
23
|
+
Pergo::Configuration.instance.host = "http://udp.example.com"
|
24
|
+
Pergo::Configuration.instance.port = 1234
|
25
|
+
end
|
26
|
+
|
27
|
+
def config
|
28
|
+
Pergo::Configuration.instance
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pergo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MalcyL, mmmmmrob
|
8
|
+
- iHiD
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: propono
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.3'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.3'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: mocha
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: minitest
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 5.0.8
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 5.0.8
|
84
|
+
description: A simple wrapper of Propono.
|
85
|
+
email:
|
86
|
+
- malcolm@landonsonline.me.uk, rob@dynamicorange.com
|
87
|
+
- jeremy@meducation.net
|
88
|
+
executables:
|
89
|
+
- pergo
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- .gitignore
|
94
|
+
- .travis.yml
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/pergo
|
100
|
+
- lib/pergo.rb
|
101
|
+
- lib/pergo/configuration.rb
|
102
|
+
- lib/pergo/server.rb
|
103
|
+
- lib/pergo/version.rb
|
104
|
+
- pergo.gemspec
|
105
|
+
- test/configuration_test.rb
|
106
|
+
- test/server_test.rb
|
107
|
+
- test/test_helper.rb
|
108
|
+
homepage: ''
|
109
|
+
licenses:
|
110
|
+
- AGPL3
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.1.9
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: See also Propono, a pub/sub build on AWS.
|
132
|
+
test_files:
|
133
|
+
- test/configuration_test.rb
|
134
|
+
- test/server_test.rb
|
135
|
+
- test/test_helper.rb
|