synack 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3@synack
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "getopt"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "bundler"
12
+ gem "jeweler"
13
+ gem "rdoc"
14
+ gem "rspec"
15
+ gem "shoulda"
16
+ gem "simplecov"
17
+ end
@@ -0,0 +1,50 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.7)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
7
+ diff-lcs (1.1.3)
8
+ getopt (1.4.1)
9
+ git (1.2.5)
10
+ i18n (0.6.0)
11
+ jeweler (1.8.4)
12
+ bundler (~> 1.0)
13
+ git (>= 1.2.5)
14
+ rake
15
+ rdoc
16
+ json (1.7.4)
17
+ multi_json (1.3.6)
18
+ rake (0.9.2.2)
19
+ rdoc (3.12)
20
+ json (~> 1.4)
21
+ rspec (2.11.0)
22
+ rspec-core (~> 2.11.0)
23
+ rspec-expectations (~> 2.11.0)
24
+ rspec-mocks (~> 2.11.0)
25
+ rspec-core (2.11.1)
26
+ rspec-expectations (2.11.2)
27
+ diff-lcs (~> 1.1.3)
28
+ rspec-mocks (2.11.1)
29
+ shoulda (3.1.1)
30
+ shoulda-context (~> 1.0)
31
+ shoulda-matchers (~> 1.2)
32
+ shoulda-context (1.0.0)
33
+ shoulda-matchers (1.2.0)
34
+ activesupport (>= 3.0.0)
35
+ simplecov (0.6.4)
36
+ multi_json (~> 1.0)
37
+ simplecov-html (~> 0.5.3)
38
+ simplecov-html (0.5.3)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler
45
+ getopt
46
+ jeweler
47
+ rdoc
48
+ rspec
49
+ shoulda
50
+ simplecov
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Corey 'Bantik' Ehmke and Max Thom Stahl
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ synack
2
+ ======
3
+
4
+ Synack is a client/server wrapper for https://github.com/alloy/terminal-notifier that allows
5
+ arbitrary messages to be sent to Mac OS X Mountain Lion's Notification Center.
6
+
7
+ Note that Terminal Notifier must be installed in your Applications directory for Synack to work
8
+ properly.
9
+
10
+ To start synack:
11
+
12
+ synack --start
13
+
14
+ To send a message to your local Notification Center:
15
+
16
+ synack "Watson, come here, I need you."
17
+
18
+ You can send messages to remote machines by specifying a host and port in the client:
19
+
20
+ synack -h my_remote_machine "I'm here, what did you want?"
21
+
@@ -0,0 +1,35 @@
1
+ = synack
2
+
3
+ Synack is a client/server wrapper for https://github.com/alloy/terminal-notifier that allows
4
+ arbitrary messages to be sent to Mac OS X Mountain Lion's Notification Center.
5
+
6
+ Note that Terminal Notifier must be installed in your Applications directory for Synack to work
7
+ properly.
8
+
9
+ To start synack:
10
+
11
+ synack --start
12
+
13
+ To send a message to your local Notification Center:
14
+
15
+ synack "Watson, come here, I need you."
16
+
17
+ You can send messages to remote machines by specifying a host and port in the client:
18
+
19
+ synack -h my_remote_machine -p 11113 "I'm here, what did you want?"
20
+
21
+ == Contributing to synack
22
+
23
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
24
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
25
+ * Fork the project.
26
+ * Start a feature/bugfix branch.
27
+ * Commit and push until you are happy with your contribution.
28
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
29
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
30
+
31
+ == Copyright
32
+
33
+ Copyright (c) 2012 Corey Ehmke and Max Thom Stahl. See LICENSE.txt for
34
+ further details.
35
+
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "synack"
18
+ gem.homepage = "http://github.com/Bantik/synack"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A Ruby server for terminal-notifier}
21
+ gem.description = %Q{A Ruby server for terminal-notifier}
22
+ gem.email = "corey@idolhands.com"
23
+ gem.authors = ["Corey Ehmke", "Max Thom Stahl"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'rdoc/task'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "synack #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ require 'getopt/long'
4
+ require 'synack'
5
+
6
+ options = Getopt::Long.getopts(
7
+ ["--server", "-s"],
8
+ ["--host", "-h"],
9
+ ["--port", "-p"]
10
+ )
11
+
12
+ @host = options['host'] || 'localhost'
13
+ @port = options['port'] || 11113
14
+
15
+ if options["server"]
16
+ Synack::Server.start(
17
+ host: @host,
18
+ port: @port
19
+ )
20
+ else
21
+ begin
22
+ client = Synack::Client.new(
23
+ host: @host,
24
+ port: @port
25
+ )
26
+
27
+ _input = STDIN.gets.chomp
28
+ client.say _input
29
+ rescue DRb::DRbConnError => e
30
+ puts "Some kind of connection error occurred: #{e}"
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ require 'synack'
4
+ # require File.join(File.dirname(__FILE__), '..', 'lib', 'synack')
5
+
6
+ USAGE = %q{
7
+ Hi! It looks like you're trying to connect to a Synack server, which is great,
8
+ but you didn't specify a URI.
9
+
10
+ Try this instead:
11
+
12
+ synack_client 127.0.0.1:11113
13
+
14
+ You'll probably have better luck that way.
15
+ }
16
+
17
+ if ARGV.empty?
18
+ puts USAGE
19
+ exit
20
+ end
21
+
22
+ host, port = ARGV.first.split(/:/)
23
+
24
+ begin
25
+ client = Synack::Client.new host: host, port: (port || 11113)
26
+
27
+ _input = STDIN.gets.chomp
28
+ client.say _input
29
+ rescue DRb::DRbConnError => e
30
+ puts "Some kind of connection error occurred: #{e}"
31
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ require 'synack'
4
+
5
+ host, port = ARGV.first ? ARGV.first.split(/:/) : ["localhost", 11113]
6
+ Synack::Server.start(host: host, port: port)
@@ -0,0 +1,5 @@
1
+ require 'synack/client'
2
+ require 'synack/server'
3
+
4
+ module Synack
5
+ end
@@ -0,0 +1,30 @@
1
+ require 'drb'
2
+ require 'socket'
3
+
4
+ module Synack
5
+
6
+ class Client
7
+
8
+ DEFAULT_OPTIONS = {
9
+ host: '0.0.0.0',
10
+ port: 11113
11
+ }
12
+
13
+ attr_reader :host, :port, :socket
14
+
15
+ # Instance methods =============================================================================
16
+
17
+ def initialize(options = {})
18
+ options = DEFAULT_OPTIONS.merge(options)
19
+
20
+ @host = options[:host]
21
+ @port = options[:port]
22
+
23
+ @socket = DRbObject.new(nil, "druby://#{@host}:#{@port}")
24
+ end
25
+
26
+ def say(message)
27
+ @socket.say(message)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,44 @@
1
+ require 'drb'
2
+ require 'socket'
3
+
4
+ module Synack
5
+
6
+ class Server
7
+
8
+ DEFAULT_OPTIONS = {
9
+ host: 'localhost',
10
+ port: 11113
11
+ }
12
+
13
+ attr_reader :host, :port, :socket
14
+
15
+ # Class methods ================================================================================
16
+
17
+ def self.start(options={})
18
+ options = DEFAULT_OPTIONS.merge(options)
19
+ @host = options[:host]
20
+ @port = options[:port].to_i
21
+ @@server = Synack::Server.new
22
+ puts "Synack Server Running. Fire at will."
23
+ ::DRb.start_service("druby://#{@host}:#{@port}", @@server)
24
+ ::DRb.thread.join
25
+ end
26
+
27
+ def self.stop
28
+ ::DRb.stop_service
29
+ end
30
+
31
+ # Instance methods =============================================================================
32
+
33
+ def sanitize(message)
34
+ message.gsub(/[^0-9A-z\.\-\' ]/, '_')
35
+ end
36
+
37
+ def say(message)
38
+ puts message
39
+ system "/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -message \"#{sanitize(message)}\""
40
+ end
41
+
42
+ end
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: synack
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Corey Ehmke
9
+ - Max Thom Stahl
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-07-29 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: getopt
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: bundler
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rdoc
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: rspec
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: shoulda
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ description: A Ruby server for terminal-notifier
128
+ email: corey@idolhands.com
129
+ executables:
130
+ - synack
131
+ - synack_client
132
+ - synack_server
133
+ extensions: []
134
+ extra_rdoc_files:
135
+ - LICENSE.txt
136
+ - README.md
137
+ - README.rdoc
138
+ files:
139
+ - .rspec
140
+ - .rvmrc
141
+ - Gemfile
142
+ - Gemfile.lock
143
+ - LICENSE.txt
144
+ - README.md
145
+ - README.rdoc
146
+ - Rakefile
147
+ - VERSION
148
+ - bin/synack
149
+ - bin/synack_client
150
+ - bin/synack_server
151
+ - lib/synack.rb
152
+ - lib/synack/client.rb
153
+ - lib/synack/server.rb
154
+ homepage: http://github.com/Bantik/synack
155
+ licenses:
156
+ - MIT
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ segments:
168
+ - 0
169
+ hash: -4189887632649267850
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 1.8.24
179
+ signing_key:
180
+ specification_version: 3
181
+ summary: A Ruby server for terminal-notifier
182
+ test_files: []