adman 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Mark
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.
data/README ADDED
@@ -0,0 +1,7 @@
1
+ Adman allows you to easily share an application with other users on your local network using Bonjour.
2
+
3
+ FIXME:
4
+ - Add more documentation
5
+
6
+ TODO:
7
+ -
@@ -0,0 +1,17 @@
1
+ = adman
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Mark. See LICENSE for details.
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "adman"
8
+ gem.summary = %Q{Easily share apps using Bonjour}
9
+ gem.description = %Q{Adman makes it easy to publish your application and collaborate with other apps on your local network using Bonjour.}
10
+ gem.email = "mark@burmis.ca"
11
+ gem.homepage = "http://github.com/MarkBennett/adman"
12
+ gem.authors = ["Mark"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.rubyforge_project = "adman"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "adman #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/TODO ADDED
@@ -0,0 +1,2 @@
1
+ - Add code to autoguess the port if we're running in Rails or Sinatra
2
+ - Add code to poll services being broadcast
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,21 @@
1
+ require 'dnssd'
2
+ require 'adman/common'
3
+
4
+ module Adman
5
+
6
+ require 'adman/dnssd'
7
+
8
+ DEFAULT_PORT = 3000
9
+
10
+ TYPE_WEB_SERVER = "_http._tcp"
11
+ DEFAULT_TYPE = TYPE_WEB_SERVER
12
+
13
+ def announce(name, options={})
14
+ type = options.fetch(:type, DEFAULT_TYPE)
15
+ domain = nil
16
+ port = options.fetch(:port, DEFAULT_PORT)
17
+
18
+ Adman.broadcaster.register(name, type, nil, port)
19
+ end
20
+
21
+ end
@@ -0,0 +1,11 @@
1
+ module Adman
2
+ class << self
3
+
4
+ # Returns the Broadcaster used by Adman
5
+ attr_reader :broadcaster
6
+
7
+ def broadcaster=(broadcaster)
8
+ @broadcaster = broadcaster
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Adman
2
+ Adman.broadcaster = DNSSD
3
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'adman'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,82 @@
1
+ require 'helper'
2
+
3
+ class TestAdman < Test::Unit::TestCase
4
+
5
+ include Adman
6
+
7
+ context "Announcing a service," do
8
+ setup do
9
+ # Replace the standard broadcaster with a mock one
10
+ @broadcaster = EchoBroadcaster.new
11
+ Adman.broadcaster = @broadcaster
12
+
13
+ # Announce the website
14
+ @website_name = "My Website"
15
+ announce @website_name
16
+
17
+ end
18
+
19
+ should "register it with the broadcaster" do
20
+ assert @broadcaster.registered?
21
+ end
22
+
23
+ should "broadcast it with the correct name" do
24
+ assert_equal @broadcaster.registered_name, @website_name
25
+ end
26
+
27
+ should "broadcast it on the default port" do
28
+ assert_equal @broadcaster.registered_port, Adman::DEFAULT_PORT
29
+ end
30
+
31
+ should "broadcast it as a web server" do
32
+ assert_equal @broadcaster.registered_type, Adman::DEFAULT_TYPE
33
+ end
34
+
35
+ end
36
+
37
+ context "Announcing a service on a port and of a type, " do
38
+
39
+ setup do
40
+ @broadcaster = EchoBroadcaster.new
41
+ Adman.broadcaster = @broadcaster
42
+
43
+ @service_name = "A great service"
44
+ @port = 80
45
+ @type = "_git._tcp"
46
+ announce @service_name, :port => @port, :type => @type
47
+ end
48
+
49
+ should "register it under the correct name" do
50
+ assert_equal @broadcaster.registered_name, @service_name
51
+ end
52
+
53
+ should "register in on the correct port" do
54
+ assert_equal @broadcaster.registered_port, @port
55
+ end
56
+
57
+ should "register it as the correct type" do
58
+ assert_equal @broadcaster.registered_type, @type
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+
65
+ class EchoBroadcaster
66
+ attr_reader :registered_name
67
+ attr_reader :registered_type
68
+ attr_reader :registered_domain
69
+ attr_reader :registered_port
70
+
71
+ def registered?
72
+ @registered ||= false
73
+ end
74
+
75
+ def register(name, type, domain, port)
76
+ @registered = true
77
+ @registered_name = name
78
+ @registered_type = type
79
+ @registered_domain = domain
80
+ @registered_port = port
81
+ end
82
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adman
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Mark
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-06 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thoughtbot-shoulda
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
32
+ description: Adman makes it easy to publish your application and collaborate with other apps on your local network using Bonjour.
33
+ email: mark@burmis.ca
34
+ executables: []
35
+
36
+ extensions: []
37
+
38
+ extra_rdoc_files:
39
+ - LICENSE
40
+ - README
41
+ - README.rdoc
42
+ - TODO
43
+ files:
44
+ - .document
45
+ - .gitignore
46
+ - LICENSE
47
+ - README.rdoc
48
+ - Rakefile
49
+ - VERSION
50
+ - lib/adman.rb
51
+ - lib/adman/common.rb
52
+ - lib/adman/dnssd.rb
53
+ - test/helper.rb
54
+ - test/test_adman.rb
55
+ - README
56
+ - TODO
57
+ has_rdoc: true
58
+ homepage: http://github.com/MarkBennett/adman
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --charset=UTF-8
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project: adman
83
+ rubygems_version: 1.3.6
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Easily share apps using Bonjour
87
+ test_files:
88
+ - test/helper.rb
89
+ - test/test_adman.rb