saxxy 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +5 -0
- data/Gemfile +13 -0
- data/LICENSE +22 -0
- data/README.md +117 -0
- data/Rakefile +12 -0
- data/lib/saxxy.rb +2 -0
- data/lib/saxxy/activatable.rb +160 -0
- data/lib/saxxy/callbacks/libxml.rb +26 -0
- data/lib/saxxy/callbacks/nokogiri.rb +30 -0
- data/lib/saxxy/callbacks/ox.rb +66 -0
- data/lib/saxxy/callbacks/sax.rb +86 -0
- data/lib/saxxy/context.rb +88 -0
- data/lib/saxxy/context_tree.rb +85 -0
- data/lib/saxxy/event.rb +83 -0
- data/lib/saxxy/event_registry.rb +122 -0
- data/lib/saxxy/node_action.rb +59 -0
- data/lib/saxxy/node_rule.rb +90 -0
- data/lib/saxxy/parsers/base.rb +28 -0
- data/lib/saxxy/parsers/libxml.rb +52 -0
- data/lib/saxxy/parsers/nokogiri.rb +28 -0
- data/lib/saxxy/parsers/ox.rb +30 -0
- data/lib/saxxy/service.rb +47 -0
- data/lib/saxxy/utils/agent.rb +66 -0
- data/lib/saxxy/utils/callback_array.rb +27 -0
- data/lib/saxxy/utils/helpers.rb +13 -0
- data/lib/saxxy/version.rb +3 -0
- data/saxxy.gemspec +21 -0
- data/spec/saxxy/activatable_spec.rb +344 -0
- data/spec/saxxy/callbacks/sax_spec.rb +456 -0
- data/spec/saxxy/context_spec.rb +51 -0
- data/spec/saxxy/context_tree_spec.rb +68 -0
- data/spec/saxxy/event_registry_spec.rb +137 -0
- data/spec/saxxy/event_spec.rb +49 -0
- data/spec/saxxy/node_action_spec.rb +46 -0
- data/spec/saxxy/node_rule_spec.rb +99 -0
- data/spec/saxxy/parsers/libxml_spec.rb +104 -0
- data/spec/saxxy/parsers/nokogiri_spec.rb +200 -0
- data/spec/saxxy/parsers/ox_spec.rb +175 -0
- data/spec/saxxy/utils/agent_spec.rb +63 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/agent_macros.rb +24 -0
- metadata +155 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "saxxy/utils/agent"
|
3
|
+
|
4
|
+
|
5
|
+
describe Saxxy::Agent do
|
6
|
+
include AgentMacros
|
7
|
+
|
8
|
+
it "should set a proxy when proxy settings are passed" do
|
9
|
+
agent = Saxxy::Agent.new(url, proxy: { address: "my.proxy.com", port: 3128 })
|
10
|
+
agent.proxy.should_not be_empty
|
11
|
+
end
|
12
|
+
|
13
|
+
it "#agent should return Net::HTTP if no proxy settings" do
|
14
|
+
agent = Saxxy::Agent.new(url)
|
15
|
+
agent.agent.should eql(Net::HTTP)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "#agent should return a class that behaves like Net::HTTP if proxy settings are present" do
|
19
|
+
agent = Saxxy::Agent.new(url, proxy: { address: "my.proxy.com", port: 3128 })
|
20
|
+
agent.agent.should_not eql(Net::HTTP)
|
21
|
+
agent.agent.proxy_class?.should be_true
|
22
|
+
agent.agent.instance_methods.should eql(Net::HTTP.instance_methods)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "#get should issue a GET request to the url provided in initialization without argument" do
|
26
|
+
fake_get
|
27
|
+
agent = Saxxy::Agent.new(url + "/get")
|
28
|
+
agent.get.should eql("fake_get")
|
29
|
+
FakeWeb.last_request.method.should eql("GET")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "#get should replace the agent's url and uri instance variables when called with argument" do
|
33
|
+
fake_get
|
34
|
+
first_url = url + "/anything"
|
35
|
+
second_url = url + "/get"
|
36
|
+
agent = Saxxy::Agent.new(first_url)
|
37
|
+
agent.url.should eql(first_url)
|
38
|
+
agent.uri.should eql(URI(first_url))
|
39
|
+
agent.get(second_url)
|
40
|
+
agent.url.should eql(second_url)
|
41
|
+
agent.uri.should eql(URI(second_url))
|
42
|
+
end
|
43
|
+
|
44
|
+
it "#post should issue a POST request to the url provided in initialization without arguments" do
|
45
|
+
fake_post
|
46
|
+
agent = Saxxy::Agent.new(url + "/post")
|
47
|
+
agent.post.should eql("fake_post")
|
48
|
+
FakeWeb.last_request.method.should eql("POST")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "#post should replace the agent's url and uri instance variables when called with arguments" do
|
52
|
+
fake_post
|
53
|
+
first_url = url + "/anything"
|
54
|
+
second_url = url + "/post"
|
55
|
+
agent = Saxxy::Agent.new(first_url)
|
56
|
+
agent.url.should eql(first_url)
|
57
|
+
agent.uri.should eql(URI(first_url))
|
58
|
+
agent.post(second_url)
|
59
|
+
agent.url.should eql(second_url)
|
60
|
+
agent.uri.should eql(URI(second_url))
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "rspec"
|
3
|
+
require "saxxy"
|
4
|
+
require "saxxy/parsers/nokogiri"
|
5
|
+
unless RUBY_PLATFORM == "java"
|
6
|
+
require "saxxy/parsers/libxml"
|
7
|
+
require "saxxy/parsers/ox"
|
8
|
+
end
|
9
|
+
require "pry"
|
10
|
+
|
11
|
+
|
12
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each(&method(:require))
|
13
|
+
|
14
|
+
Bundler.require(:default)
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
18
|
+
|
19
|
+
if RUBY_PLATFORM == "java"
|
20
|
+
config.filter_run_excluding :not_jruby
|
21
|
+
end
|
22
|
+
|
23
|
+
config.mock_with :rspec
|
24
|
+
|
25
|
+
config.before(:each) do
|
26
|
+
FakeWeb.clean_registry
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "fakeweb"
|
2
|
+
|
3
|
+
|
4
|
+
module AgentMacros
|
5
|
+
|
6
|
+
def url
|
7
|
+
"http://foo.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
def fake_get(&block)
|
11
|
+
FakeWeb.register_uri(:get, url + "/get",
|
12
|
+
body: block_given? ? block.call : "fake_get",
|
13
|
+
status: ["200", "OK"]
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def fake_post(&block)
|
18
|
+
FakeWeb.register_uri(:post, url + "/post",
|
19
|
+
body: block_given? ? block.call : "fake_post",
|
20
|
+
status: ["201", "Created"]
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: saxxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- rubymaniac
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fakeweb
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A Ruby DSL for building SAX parsers.
|
70
|
+
email:
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- ".gitignore"
|
76
|
+
- ".travis.yml"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/saxxy.rb
|
82
|
+
- lib/saxxy/activatable.rb
|
83
|
+
- lib/saxxy/callbacks/libxml.rb
|
84
|
+
- lib/saxxy/callbacks/nokogiri.rb
|
85
|
+
- lib/saxxy/callbacks/ox.rb
|
86
|
+
- lib/saxxy/callbacks/sax.rb
|
87
|
+
- lib/saxxy/context.rb
|
88
|
+
- lib/saxxy/context_tree.rb
|
89
|
+
- lib/saxxy/event.rb
|
90
|
+
- lib/saxxy/event_registry.rb
|
91
|
+
- lib/saxxy/node_action.rb
|
92
|
+
- lib/saxxy/node_rule.rb
|
93
|
+
- lib/saxxy/parsers/base.rb
|
94
|
+
- lib/saxxy/parsers/libxml.rb
|
95
|
+
- lib/saxxy/parsers/nokogiri.rb
|
96
|
+
- lib/saxxy/parsers/ox.rb
|
97
|
+
- lib/saxxy/service.rb
|
98
|
+
- lib/saxxy/utils/agent.rb
|
99
|
+
- lib/saxxy/utils/callback_array.rb
|
100
|
+
- lib/saxxy/utils/helpers.rb
|
101
|
+
- lib/saxxy/version.rb
|
102
|
+
- saxxy.gemspec
|
103
|
+
- spec/saxxy/activatable_spec.rb
|
104
|
+
- spec/saxxy/callbacks/sax_spec.rb
|
105
|
+
- spec/saxxy/context_spec.rb
|
106
|
+
- spec/saxxy/context_tree_spec.rb
|
107
|
+
- spec/saxxy/event_registry_spec.rb
|
108
|
+
- spec/saxxy/event_spec.rb
|
109
|
+
- spec/saxxy/node_action_spec.rb
|
110
|
+
- spec/saxxy/node_rule_spec.rb
|
111
|
+
- spec/saxxy/parsers/libxml_spec.rb
|
112
|
+
- spec/saxxy/parsers/nokogiri_spec.rb
|
113
|
+
- spec/saxxy/parsers/ox_spec.rb
|
114
|
+
- spec/saxxy/utils/agent_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- spec/support/agent_macros.rb
|
117
|
+
homepage: https://github.com/rubymaniac/saxxy
|
118
|
+
licenses: []
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.4.6
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Constructing SAX parsers never been easier.
|
140
|
+
test_files:
|
141
|
+
- spec/saxxy/activatable_spec.rb
|
142
|
+
- spec/saxxy/callbacks/sax_spec.rb
|
143
|
+
- spec/saxxy/context_spec.rb
|
144
|
+
- spec/saxxy/context_tree_spec.rb
|
145
|
+
- spec/saxxy/event_registry_spec.rb
|
146
|
+
- spec/saxxy/event_spec.rb
|
147
|
+
- spec/saxxy/node_action_spec.rb
|
148
|
+
- spec/saxxy/node_rule_spec.rb
|
149
|
+
- spec/saxxy/parsers/libxml_spec.rb
|
150
|
+
- spec/saxxy/parsers/nokogiri_spec.rb
|
151
|
+
- spec/saxxy/parsers/ox_spec.rb
|
152
|
+
- spec/saxxy/utils/agent_spec.rb
|
153
|
+
- spec/spec_helper.rb
|
154
|
+
- spec/support/agent_macros.rb
|
155
|
+
has_rdoc:
|