vespa 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.6.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.9.2.2)
10
+ rcov (0.9.11)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.6.4)
19
+ rcov
20
+ shoulda
data/README.rdoc ADDED
@@ -0,0 +1,30 @@
1
+ = Installation
2
+
3
+ == Install Ruby & Gems
4
+ *NOTE:* Right now, this gem requires ruby 1.9.2 to run.
5
+
6
+ == Install the gem
7
+ From a command line type:
8
+ sudo gem install vespa
9
+
10
+ Windows users can leave off the "sudo"
11
+
12
+ == Some Examples
13
+ From a command line type:
14
+
15
+ To pull a message
16
+
17
+ /bin/vespa topic jms.topic.example.topic --pull --server bus.mycompany.com --subscriber accounting > output_message.txt
18
+
19
+ To push a message
20
+
21
+ /bin/vespa topic jms.topic.example.topic --server bus.mycompany.com -payload "<invoice><line amount='$10'/></invoice>"
22
+ Using pipes
23
+
24
+ cat README.rdoc | ./bin/vespa topic jms.topic.example.topic --push --pull --server bus.mycompany.com
25
+
26
+ == Using the Gem
27
+ For detailed instructions on using the gem type:
28
+ vespa help
29
+ or
30
+ vespa help [TASK]
data/Rakefile ADDED
@@ -0,0 +1,53 @@
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 = "vespa"
18
+ gem.homepage = "http://github.com/pdodds/vespa"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A simple command line interface to JBoss HornetQ RESTful API }
21
+ gem.description = %Q{A simple command line interface to the JBoss HornetQ RESTful API}
22
+ gem.email = "philip.dodds@me.com"
23
+ gem.authors = ["Philip Dodds"]
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
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "vespa #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/vespa ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'commander'
4
+
5
+ #$DEBUG = true
6
+ require File.dirname(__FILE__) + "/../lib/cli.rb"
data/lib/cli.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'commander/import'
2
+ require_relative 'topic'
3
+
4
+ # :name is optional, otherwise uses the basename of this executable
5
+
6
+ appname = "vespa"
7
+ program :name, 'JBoss HornetQ RESTful command line'
8
+ program :version, '0.0.1'
9
+ program :description, 'Interact with the JBoss HornetQ RESTful API from the command line'
10
+
11
+ command :topic do |c|
12
+ c.syntax = "#{appname} topic <name>"
13
+ c.description = 'Enqueue a message on a topic'
14
+ c.option '--server <servername>', String, 'The name of the server (default:localhost)'
15
+ c.option '--port <port>', String, 'The HTTP port (default:8080)'
16
+ c.option '--context <prefix>', String, 'The context path (default:messaging)'
17
+ c.option '--payload <message>', String, 'Payload for the message (used to ignore stdin)'
18
+ c.option '--pull', 'Pull the next message'
19
+ c.option '--push', 'Push a message'
20
+ c.option '--durable', 'Set durable on pull'
21
+ c.option '--subscriber <name>', String, 'Set the name of the subscriber (default:bob)'
22
+ c.action do |args, options|
23
+ options.default :server => 'localhost', :port => '8180', :context => 'messaging', :subscriber => 'bob', :durable => true
24
+ raise "You must provide the topic name" if args[0].nil?
25
+ topic = Topic.new(options.server,options.port,options.context,args[0],options.subscriber)
26
+ if !(options.payload.nil?)
27
+ topic.enqueue(options.payload,options.durable)
28
+ elsif !(options.push.nil?)
29
+ topic.enqueue($stdin.read,options.durable)
30
+ end
31
+
32
+ if !(options.pull.nil?)
33
+ topic.dequeue(options.durable)
34
+ end
35
+ end
36
+ end
data/lib/topic.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'rest_client'
2
+ require 'nokogiri'
3
+ require 'JSON'
4
+
5
+ # Simple representation of a topic
6
+ class Topic
7
+
8
+ def initialize(server,port,context,topic,subscriber)
9
+ @server = server
10
+ @port = port
11
+ @context = context
12
+ @topic = topic
13
+ @subscriber = subscriber
14
+ @base_url = "http://#{@server}:#{@port}/#{@context}/topics/#{@topic}"
15
+ descriptor = RestClient.get(@base_url)
16
+ @name = Nokogiri::XML(descriptor).xpath('/topic/name/text()')
17
+ @create_url = Nokogiri::XML(descriptor).xpath("/topic/link[@rel='create']/@href").text
18
+ @pull_url = Nokogiri::XML(descriptor).xpath("/topic/link[@rel='pull-consumers']/@href").text
19
+ warn "Connected to topic #{@name}"
20
+ warn "Create URL [#{@create_url}]"
21
+ warn "Pull URL [#{@pull_url}]"
22
+ end
23
+
24
+ def info
25
+ puts ""
26
+ end
27
+
28
+ def enqueue(payload,durable)
29
+ warn "Enqueuing payload [#{payload}]"
30
+ response = RestClient.post("#{@create_url}?durable=#{durable}",payload,{:contentType=>"application/xml"})
31
+ raise "Message not created" if response.code != 201
32
+ warn "Message created at #{response.headers[:date]}"
33
+ end
34
+
35
+ def dequeue(durable)
36
+ warn "Dequeuing message"
37
+ lookup = RestClient.post(@pull_url,{:durable=>durable,:name=>@subscriber})
38
+ warn "Getting message from [#{lookup.headers[:msg_consume_next]}]"
39
+ message_response = RestClient.post(lookup.headers[:msg_consume_next],{:durable=>durable,:name=>@subscriber})
40
+ puts message_response
41
+ end
42
+ end
data/vespa.gemspec ADDED
@@ -0,0 +1,58 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "vespa"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Philip Dodds"]
12
+ s.date = "2011-11-29"
13
+ s.description = "A simple command line interface to the JBoss HornetQ RESTful API"
14
+ s.email = "philip.dodds@me.com"
15
+ s.executables = ["vespa"]
16
+ s.extra_rdoc_files = [
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/vespa",
27
+ "lib/cli.rb",
28
+ "lib/topic.rb",
29
+ "vespa.gemspec"
30
+ ]
31
+ s.homepage = "http://github.com/pdodds/vespa"
32
+ s.licenses = ["MIT"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = "1.8.10"
35
+ s.summary = "A simple command line interface to JBoss HornetQ RESTful API"
36
+
37
+ if s.respond_to? :specification_version then
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
42
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
43
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
44
+ s.add_development_dependency(%q<rcov>, [">= 0"])
45
+ else
46
+ s.add_dependency(%q<shoulda>, [">= 0"])
47
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
48
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
49
+ s.add_dependency(%q<rcov>, [">= 0"])
50
+ end
51
+ else
52
+ s.add_dependency(%q<shoulda>, [">= 0"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ end
57
+ end
58
+
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vespa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Philip Dodds
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-29 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: &70269964836720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70269964836720
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &70269964853380 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70269964853380
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &70269964852900 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70269964852900
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &70269964852420 !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: *70269964852420
58
+ description: A simple command line interface to the JBoss HornetQ RESTful API
59
+ email: philip.dodds@me.com
60
+ executables:
61
+ - vespa
62
+ extensions: []
63
+ extra_rdoc_files:
64
+ - README.rdoc
65
+ files:
66
+ - .document
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - README.rdoc
70
+ - Rakefile
71
+ - VERSION
72
+ - bin/vespa
73
+ - lib/cli.rb
74
+ - lib/topic.rb
75
+ - vespa.gemspec
76
+ homepage: http://github.com/pdodds/vespa
77
+ licenses:
78
+ - MIT
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ segments:
90
+ - 0
91
+ hash: 4000962277326604941
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.10
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: A simple command line interface to JBoss HornetQ RESTful API
104
+ test_files: []