cotendo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +39 -0
- data/Rakefile +18 -0
- data/Readme.md +19 -0
- data/VERSION +1 -0
- data/cotendo.gemspec +47 -0
- data/lib/cotendo.rb +44 -0
- data/spec/config.example.yml +3 -0
- data/spec/cotendo_spec.rb +16 -0
- data/spec/spec_helper.rb +2 -0
- metadata +92 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
builder (3.0.0)
|
5
|
+
crack (0.1.8)
|
6
|
+
diff-lcs (1.1.2)
|
7
|
+
git (1.2.5)
|
8
|
+
gyoku (0.1.1)
|
9
|
+
builder (>= 2.1.2)
|
10
|
+
httpi (0.7.7)
|
11
|
+
rack
|
12
|
+
jeweler (1.5.2)
|
13
|
+
bundler (~> 1.0.0)
|
14
|
+
git (>= 1.2.5)
|
15
|
+
rake
|
16
|
+
rack (1.2.1)
|
17
|
+
rake (0.8.7)
|
18
|
+
rspec (2.5.0)
|
19
|
+
rspec-core (~> 2.5.0)
|
20
|
+
rspec-expectations (~> 2.5.0)
|
21
|
+
rspec-mocks (~> 2.5.0)
|
22
|
+
rspec-core (2.5.1)
|
23
|
+
rspec-expectations (2.5.0)
|
24
|
+
diff-lcs (~> 1.1.2)
|
25
|
+
rspec-mocks (2.5.0)
|
26
|
+
savon (0.8.2)
|
27
|
+
builder (>= 2.1.2)
|
28
|
+
crack (~> 0.1.8)
|
29
|
+
gyoku (>= 0.1.1)
|
30
|
+
httpi (>= 0.7.5)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
jeweler
|
37
|
+
rake
|
38
|
+
rspec (~> 2)
|
39
|
+
savon (>= 0.8.2)
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
task :default do
|
2
|
+
sh "rspec spec/"
|
3
|
+
end
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = 'cotendo'
|
9
|
+
gem.summary = "Wrapper for cotendo SOAP Api"
|
10
|
+
gem.email = "michael@grosser.it"
|
11
|
+
gem.homepage = "http://github.com/grosser/#{gem.name}"
|
12
|
+
gem.authors = ["Michael Grosser"]
|
13
|
+
end
|
14
|
+
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
18
|
+
end
|
data/Readme.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Wrapper for cotendo SOAP Api
|
2
|
+
|
3
|
+
Install
|
4
|
+
=======
|
5
|
+
sudo gem install cotendo
|
6
|
+
|
7
|
+
Usage
|
8
|
+
=====
|
9
|
+
client = Cotendo.new(:user => 'user', :password => 'password')
|
10
|
+
|
11
|
+
# flush
|
12
|
+
client.flush(cname, "/images/*") # hard flush
|
13
|
+
client.flush(cname, ["/images/*", "/*.jsp", "/*.txt"], :flush_type => 'soft')
|
14
|
+
|
15
|
+
Author
|
16
|
+
======
|
17
|
+
[Michael Grosser](http://grosser.it)<br/>
|
18
|
+
michael@grosser.it<br/>
|
19
|
+
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/cotendo.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
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 = %q{cotendo}
|
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 = ["Michael Grosser"]
|
12
|
+
s.date = %q{2011-04-29}
|
13
|
+
s.email = %q{michael@grosser.it}
|
14
|
+
s.files = [
|
15
|
+
"Gemfile",
|
16
|
+
"Gemfile.lock",
|
17
|
+
"Rakefile",
|
18
|
+
"Readme.md",
|
19
|
+
"VERSION",
|
20
|
+
"cotendo.gemspec",
|
21
|
+
"lib/cotendo.rb",
|
22
|
+
"spec/config.example.yml",
|
23
|
+
"spec/cotendo_spec.rb",
|
24
|
+
"spec/spec_helper.rb"
|
25
|
+
]
|
26
|
+
s.homepage = %q{http://github.com/grosser/cotendo}
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
s.rubygems_version = %q{1.4.2}
|
29
|
+
s.summary = %q{Wrapper for cotendo SOAP Api}
|
30
|
+
s.test_files = [
|
31
|
+
"spec/cotendo_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
|
35
|
+
if s.respond_to? :specification_version then
|
36
|
+
s.specification_version = 3
|
37
|
+
|
38
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
39
|
+
s.add_runtime_dependency(%q<savon>, [">= 0.8.2"])
|
40
|
+
else
|
41
|
+
s.add_dependency(%q<savon>, [">= 0.8.2"])
|
42
|
+
end
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<savon>, [">= 0.8.2"])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/lib/cotendo.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'savon'
|
2
|
+
|
3
|
+
class Cotendo
|
4
|
+
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
5
|
+
WSDL = "https://api.cotendo.net/cws?wsdl"
|
6
|
+
NAMESPACE = 'http://api.cotendo.net/'
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@user = options[:user]
|
10
|
+
@password = options[:password]
|
11
|
+
end
|
12
|
+
|
13
|
+
def flush(cname, expressions, options = {})
|
14
|
+
expressions = [*expressions]
|
15
|
+
request(:do_flush,
|
16
|
+
:cname => cname,
|
17
|
+
:flush_expression => expressions.join("\n"),
|
18
|
+
:flush_type => options[:flush_type] || 'hard'
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def client
|
23
|
+
@client = begin
|
24
|
+
client = Savon::Client.new do
|
25
|
+
wsdl.document = WSDL
|
26
|
+
end
|
27
|
+
client.wsdl.request.auth.basic @user, @password
|
28
|
+
client
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def request(method, options)
|
33
|
+
response = client.request(api_namespaced(method)) do |r|
|
34
|
+
r.namespaces['xmlns:api'] = NAMESPACE
|
35
|
+
r.namespaces['xmlns:wsdl'] = WSDL+'&ver=1.0'
|
36
|
+
r.body = options
|
37
|
+
end
|
38
|
+
response.to_hash
|
39
|
+
end
|
40
|
+
|
41
|
+
def api_namespaced(method)
|
42
|
+
"api:#{method.to_s.gsub(/_./){|x| x.slice(1,1).upcase }}"
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path('spec/spec_helper')
|
2
|
+
|
3
|
+
describe Cotendo do
|
4
|
+
let(:config){ YAML.load_file('spec/config.yml') }
|
5
|
+
let(:client){ Cotendo.new(config) }
|
6
|
+
|
7
|
+
it "has a VERSION" do
|
8
|
+
Cotendo::VERSION.should =~ /^\d+\.\d+\.\d+$/
|
9
|
+
end
|
10
|
+
|
11
|
+
describe :flush do
|
12
|
+
it "can do it" do
|
13
|
+
client.flush(config[:cname], '/foo')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cotendo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Michael Grosser
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-29 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 59
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 8
|
31
|
+
- 2
|
32
|
+
version: 0.8.2
|
33
|
+
type: :runtime
|
34
|
+
requirement: *id001
|
35
|
+
name: savon
|
36
|
+
prerelease: false
|
37
|
+
description:
|
38
|
+
email: michael@grosser.it
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- Gemfile
|
47
|
+
- Gemfile.lock
|
48
|
+
- Rakefile
|
49
|
+
- Readme.md
|
50
|
+
- VERSION
|
51
|
+
- cotendo.gemspec
|
52
|
+
- lib/cotendo.rb
|
53
|
+
- spec/config.example.yml
|
54
|
+
- spec/cotendo_spec.rb
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://github.com/grosser/cotendo
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 3
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.4.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Wrapper for cotendo SOAP Api
|
90
|
+
test_files:
|
91
|
+
- spec/cotendo_spec.rb
|
92
|
+
- spec/spec_helper.rb
|