skates 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +113 -0
- data/Rakefile +143 -0
- data/bin/skates +6 -0
- data/lib/skates.rb +108 -0
- data/lib/skates/base/controller.rb +116 -0
- data/lib/skates/base/stanza.rb +23 -0
- data/lib/skates/base/view.rb +58 -0
- data/lib/skates/client_connection.rb +210 -0
- data/lib/skates/component_connection.rb +87 -0
- data/lib/skates/generator.rb +139 -0
- data/lib/skates/router.rb +101 -0
- data/lib/skates/router/dsl.rb +61 -0
- data/lib/skates/runner.rb +137 -0
- data/lib/skates/xmpp_connection.rb +172 -0
- data/lib/skates/xmpp_parser.rb +117 -0
- data/lib/skates/xpath_helper.rb +13 -0
- data/spec/bin/babylon_spec.rb +0 -0
- data/spec/em_mock.rb +42 -0
- data/spec/lib/babylon/base/controller_spec.rb +205 -0
- data/spec/lib/babylon/base/stanza_spec.rb +15 -0
- data/spec/lib/babylon/base/view_spec.rb +92 -0
- data/spec/lib/babylon/client_connection_spec.rb +304 -0
- data/spec/lib/babylon/component_connection_spec.rb +135 -0
- data/spec/lib/babylon/generator_spec.rb +10 -0
- data/spec/lib/babylon/router/dsl_spec.rb +72 -0
- data/spec/lib/babylon/router_spec.rb +189 -0
- data/spec/lib/babylon/runner_spec.rb +213 -0
- data/spec/lib/babylon/xmpp_connection_spec.rb +197 -0
- data/spec/lib/babylon/xmpp_parser_spec.rb +275 -0
- data/spec/lib/babylon/xpath_helper_spec.rb +25 -0
- data/spec/spec_helper.rb +34 -0
- data/templates/skates/app/controllers/controller.rb +7 -0
- data/templates/skates/app/stanzas/stanza.rb +6 -0
- data/templates/skates/app/views/view.rb +6 -0
- data/templates/skates/config/boot.rb +16 -0
- data/templates/skates/config/config.yaml +24 -0
- data/templates/skates/config/dependencies.rb +1 -0
- data/templates/skates/config/routes.rb +22 -0
- data/templates/skates/log/development.log +0 -0
- data/templates/skates/log/production.log +0 -0
- data/templates/skates/log/test.log +0 -0
- data/templates/skates/script/component +36 -0
- data/templates/skates/tmp/pids/README +2 -0
- data/test/skates_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +160 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Skates::XpathHelper do
|
4
|
+
describe "namespace method" do
|
5
|
+
before do
|
6
|
+
@doc = Nokogiri::XML(<<-eoxml)
|
7
|
+
<iq from='me@my.jid/Eee' to='component.my.jid'
|
8
|
+
xml:lang='en' type='get' id='43'><query
|
9
|
+
xmlns='http://jabber.org/protocol/disco#info'/></iq>
|
10
|
+
eoxml
|
11
|
+
end
|
12
|
+
|
13
|
+
it "matches nodes of the given name with the given namespace URI" do
|
14
|
+
@doc.xpath("//iq/*[namespace(., 'query', 'http://jabber.org/protocol/disco#info')]", Skates::XpathHelper.new).length.should == 1
|
15
|
+
end
|
16
|
+
|
17
|
+
it "does not match a namespace URI if the node names differ" do
|
18
|
+
@doc.xpath("//iq/*[namespace(., 'que', 'http://jabber.org/protocol/disco#info')]", Skates::XpathHelper.new).length.should == 0
|
19
|
+
end
|
20
|
+
|
21
|
+
it "does not match a node if the namespace URIs differ" do
|
22
|
+
@doc.xpath("//iq/*[namespace(., 'query', 'http://jabber.org/protocol/disco#inf')]", Skates::XpathHelper.new).length.should == 0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../lib/skates"
|
2
|
+
|
3
|
+
# #
|
4
|
+
# Deactivate the logging
|
5
|
+
Skates.logger.level = Log4r::FATAL
|
6
|
+
|
7
|
+
Skates.environment = "test"
|
8
|
+
|
9
|
+
if !defined? SkatesSpecHelper
|
10
|
+
module SkatesSpecHelper
|
11
|
+
##
|
12
|
+
# Load configuration from a local config file
|
13
|
+
def skates_config
|
14
|
+
@config ||= YAML.load(File.read(File.join(File.dirname(__FILE__), "config.yaml")))
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# Mock for Handler
|
19
|
+
def handler_mock
|
20
|
+
@handler_mock ||=
|
21
|
+
begin
|
22
|
+
mock(Object, { :on_connected => Proc.new { |conn|
|
23
|
+
},
|
24
|
+
:on_disconnected => Proc.new {
|
25
|
+
# Disconnected
|
26
|
+
},
|
27
|
+
:on_stanza => Proc.new { |stanza|
|
28
|
+
# Stanza!
|
29
|
+
}
|
30
|
+
})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class Stanza < Skates::Base::Stanza
|
2
|
+
# element :message, :as => :to, :value => :to (will add a .to method for your <message> stanza, based on the "to" attribute)
|
3
|
+
# element :pubsub (will match to the content of <pubsub> and define a .pubsub method)
|
4
|
+
# element :publish, :as => :node, :value => :node (will match to the content of the "node" attribute of <publish> and defined a .node method)
|
5
|
+
# elements :entry, :as => :entries, :class => AtomEntry (will match <entry> elements to a subclass AtomEntry (that you must define, using SaxMachine) and create a .entries.methods that returns an Array of AtomEntry.
|
6
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Please see Skates Rdoc. Put all the views related to controller MyController into app/views/my/...
|
2
|
+
# This file are Xml Builder Files (see Nokogiri Documentation for any doubt : http://nokogiri.rubyforge.org/nokogiri/Nokogiri/XML/Builder.html ).
|
3
|
+
|
4
|
+
# xml.message(:to => @to, :from => @from, :type => :chat) do
|
5
|
+
# xml.body(@body) # Same as self.send(:body, body)
|
6
|
+
# end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
##
|
2
|
+
# This file is run by the dameons, in the apps directory
|
3
|
+
|
4
|
+
# Change directory to the app's directory.
|
5
|
+
Dir.chdir(File.dirname(__FILE__) + "/../")
|
6
|
+
|
7
|
+
require "rubygems"
|
8
|
+
require "skates"
|
9
|
+
require File.dirname(__FILE__) + "/dependencies"
|
10
|
+
|
11
|
+
|
12
|
+
# Start the App
|
13
|
+
Skates::Runner::run(ARGV[0] || "development") do
|
14
|
+
# Run the initializers, too. This is done here since some initializers might need EventMachine to be started.
|
15
|
+
Dir.glob('config/initializers/*.rb').each { |f| require f }
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This contains the global configuration of your component.
|
2
|
+
# environment:
|
3
|
+
# jid: your.component.jid
|
4
|
+
# password: your.component.password
|
5
|
+
# host: host on which the XMPP server is running
|
6
|
+
# port: port to which your component should connect
|
7
|
+
# application_type: client | component (by default it is component and we strongly discourage any client application in production)
|
8
|
+
|
9
|
+
development:
|
10
|
+
jid: user@server.com
|
11
|
+
password: password
|
12
|
+
application_type: client
|
13
|
+
|
14
|
+
test:
|
15
|
+
jid: component.server.com
|
16
|
+
password: password
|
17
|
+
host: localhost
|
18
|
+
port: 5278
|
19
|
+
|
20
|
+
production:
|
21
|
+
jid: component.server.com
|
22
|
+
password: password
|
23
|
+
host: localhost
|
24
|
+
port: 5278
|
@@ -0,0 +1 @@
|
|
1
|
+
# Require any application-specific dependencies here.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Routes require an xpath against which to match, and a controller/action pair to which to map.
|
2
|
+
#
|
3
|
+
# xpath("//message[@type = 'chat']").to(:controller => "message", :action => "receive")
|
4
|
+
#
|
5
|
+
# Routes can be assigned priorities. The highest priority executes first, and the default priority is 0.
|
6
|
+
#
|
7
|
+
# xpath("//message[@type = 'chat']").to(:controller => "message", :action => "priority").priority(5000000)
|
8
|
+
#
|
9
|
+
# It is not possible to easily check for namespace URI equivalence in xpath, but the following helper function was added.
|
10
|
+
#
|
11
|
+
# xpath("//iq[@type='get']/*[namespace(., 'query', 'http://jabber.org/protocol/disco#info')]").to(:controller => "discovery", :action => "services")
|
12
|
+
#
|
13
|
+
# That syntax is ugly out of necessity. But, relax, you're using Ruby.
|
14
|
+
#
|
15
|
+
# There are a few helper methods for generating xpaths. The following is equivalent to the above example:
|
16
|
+
#
|
17
|
+
# disco_info.to(:controller => "discovery", :action => "services")
|
18
|
+
#
|
19
|
+
# See lib/skates/router/dsl.rb for more helpers.
|
20
|
+
Skates.router.draw do
|
21
|
+
|
22
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
# default options
|
6
|
+
OPTIONS = {
|
7
|
+
:environment => "development",
|
8
|
+
:name => "#{Dir.pwd.split("/").last}",
|
9
|
+
}
|
10
|
+
|
11
|
+
ARGV.options do |o|
|
12
|
+
script_name = File.basename($0)
|
13
|
+
|
14
|
+
o.set_summary_indent(' ')
|
15
|
+
o.banner = "Usage: script/#{script_name} [OPTIONS]"
|
16
|
+
o.define_head "Runs the Babylon Application."
|
17
|
+
o.separator ""
|
18
|
+
o.separator "Arguments :"
|
19
|
+
|
20
|
+
o.on("-e", "--environment=env", String,
|
21
|
+
"The environment to run the application (you should have defined the argument into config/config.yaml)",
|
22
|
+
"Default: #{OPTIONS[:environment]}") { |OPTIONS[:environment]| }
|
23
|
+
o.on("-n", "--name=app_name", String,
|
24
|
+
"Name of your application. The pid_file will be name after this.",
|
25
|
+
"Default: #{OPTIONS[:name]}") { |OPTIONS[:name]| }
|
26
|
+
|
27
|
+
o.separator ""
|
28
|
+
|
29
|
+
o.on_tail("-h", "--help", "Show this help message.") { puts o; exit }
|
30
|
+
|
31
|
+
o.parse!
|
32
|
+
end
|
33
|
+
|
34
|
+
$appname = OPTIONS[:name]
|
35
|
+
BABYLON_ENV = OPTIONS[:environment]
|
36
|
+
require File.dirname(__FILE__) + '/../config/boot.rb'
|
data/test/skates_test.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SkatesTest < Test::Unit::TestCase
|
4
|
+
# Tests are done through Rspec... but feel free to add any Unit tests you think might be helpful to understand and fix code more easily
|
5
|
+
should "probably rename this file and start testing for real" do
|
6
|
+
end
|
7
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skates
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.11
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- julien Genestoux
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-03 00:00:00 -08:00
|
13
|
+
default_executable: skates
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: eventmachine
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.12.10
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: log4r
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: nokogiri
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.4.0
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: julien51-sax-machine
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.0.20
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: templater
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
description:
|
66
|
+
email: julien.genestoux@gmail.com
|
67
|
+
executables:
|
68
|
+
- skates
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files:
|
72
|
+
- LICENSE
|
73
|
+
- README.rdoc
|
74
|
+
files:
|
75
|
+
- LICENSE
|
76
|
+
- README.rdoc
|
77
|
+
- Rakefile
|
78
|
+
- bin/skates
|
79
|
+
- lib/skates.rb
|
80
|
+
- lib/skates/base/controller.rb
|
81
|
+
- lib/skates/base/stanza.rb
|
82
|
+
- lib/skates/base/view.rb
|
83
|
+
- lib/skates/client_connection.rb
|
84
|
+
- lib/skates/component_connection.rb
|
85
|
+
- lib/skates/generator.rb
|
86
|
+
- lib/skates/router.rb
|
87
|
+
- lib/skates/router/dsl.rb
|
88
|
+
- lib/skates/runner.rb
|
89
|
+
- lib/skates/xmpp_connection.rb
|
90
|
+
- lib/skates/xmpp_parser.rb
|
91
|
+
- lib/skates/xpath_helper.rb
|
92
|
+
- templates/skates/app/controllers/controller.rb
|
93
|
+
- templates/skates/app/stanzas/stanza.rb
|
94
|
+
- templates/skates/app/views/view.rb
|
95
|
+
- templates/skates/config/boot.rb
|
96
|
+
- templates/skates/config/config.yaml
|
97
|
+
- templates/skates/config/dependencies.rb
|
98
|
+
- templates/skates/config/routes.rb
|
99
|
+
- templates/skates/log/development.log
|
100
|
+
- templates/skates/log/production.log
|
101
|
+
- templates/skates/log/test.log
|
102
|
+
- templates/skates/script/component
|
103
|
+
- templates/skates/tmp/pids/README
|
104
|
+
has_rdoc: true
|
105
|
+
homepage: http://github.com/julien51/skates
|
106
|
+
licenses: []
|
107
|
+
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options:
|
110
|
+
- --charset=UTF-8
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: "0"
|
118
|
+
version:
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "0"
|
124
|
+
version:
|
125
|
+
requirements:
|
126
|
+
- eventmachine
|
127
|
+
- yaml
|
128
|
+
- fileutils
|
129
|
+
- log4r
|
130
|
+
- nokogiri
|
131
|
+
- julien51-sax-machine
|
132
|
+
- templater
|
133
|
+
- optparse
|
134
|
+
- digest/sha1
|
135
|
+
- base64
|
136
|
+
- resolv
|
137
|
+
- activesupport
|
138
|
+
rubyforge_project: skates
|
139
|
+
rubygems_version: 1.3.5
|
140
|
+
signing_key:
|
141
|
+
specification_version: 3
|
142
|
+
summary: Skates is a framework to create EventMachine based XMPP External Components in Ruby.
|
143
|
+
test_files:
|
144
|
+
- spec/bin/babylon_spec.rb
|
145
|
+
- spec/em_mock.rb
|
146
|
+
- spec/lib/babylon/base/controller_spec.rb
|
147
|
+
- spec/lib/babylon/base/stanza_spec.rb
|
148
|
+
- spec/lib/babylon/base/view_spec.rb
|
149
|
+
- spec/lib/babylon/client_connection_spec.rb
|
150
|
+
- spec/lib/babylon/component_connection_spec.rb
|
151
|
+
- spec/lib/babylon/generator_spec.rb
|
152
|
+
- spec/lib/babylon/router/dsl_spec.rb
|
153
|
+
- spec/lib/babylon/router_spec.rb
|
154
|
+
- spec/lib/babylon/runner_spec.rb
|
155
|
+
- spec/lib/babylon/xmpp_connection_spec.rb
|
156
|
+
- spec/lib/babylon/xmpp_parser_spec.rb
|
157
|
+
- spec/lib/babylon/xpath_helper_spec.rb
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- test/skates_test.rb
|
160
|
+
- test/test_helper.rb
|