saiku_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/saiku_client/version.rb +3 -0
- data/lib/saiku_client.rb +69 -0
- data/saiku_client.gemspec +28 -0
- data/spec/lib/saiku_client_spec.rb +20 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/simplecov_support.rb +19 -0
- metadata +145 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use ruby-1.9.3-p194
|
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/saiku_client.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require "rest_client"
|
2
|
+
require "json"
|
3
|
+
require "csv"
|
4
|
+
require "saiku_client/version"
|
5
|
+
|
6
|
+
module SaikuClient
|
7
|
+
|
8
|
+
Config = { saiku_url: "http://localhost:8080/saiku",
|
9
|
+
user: "admin",
|
10
|
+
password: "admin" }
|
11
|
+
|
12
|
+
class Client
|
13
|
+
|
14
|
+
def cookies
|
15
|
+
@cookies ||= lambda {
|
16
|
+
r = RestClient.post(build_url("/session", include_user: false),
|
17
|
+
username: Config[:user], password: Config[:password])
|
18
|
+
r.cookies
|
19
|
+
}.call
|
20
|
+
end
|
21
|
+
|
22
|
+
def repo_info
|
23
|
+
::JSON.parse get("/repository")
|
24
|
+
end
|
25
|
+
|
26
|
+
def query_info(qname)
|
27
|
+
::JSON.parse get("/repository/#{qname}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def run_query(qname)
|
31
|
+
q_info = query_info(qname)
|
32
|
+
|
33
|
+
post("/query/#{qname}", xml: q_info["xml"])
|
34
|
+
get("/query/#{qname}/result")
|
35
|
+
results = ::CSV.parse get("/query/#{qname}/export/csv")
|
36
|
+
delete("/query/#{qname}")
|
37
|
+
|
38
|
+
results
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def get(rel_path, attrs={})
|
44
|
+
q = attrs.collect { |kv| kv.join("=") }.join("&")
|
45
|
+
rel_path = [rel_path, "?", q].join unless q.empty?
|
46
|
+
|
47
|
+
RestClient.get(build_url(rel_path), cookies: cookies)
|
48
|
+
end
|
49
|
+
|
50
|
+
def post(rel_path, attrs={})
|
51
|
+
RestClient.post(build_url(rel_path), attrs, cookies: cookies)
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete(rel_path)
|
55
|
+
RestClient.delete(build_url(rel_path), cookies: cookies)
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_url(rel_path, opts={})
|
59
|
+
opts = {include_user: true}.merge(opts)
|
60
|
+
|
61
|
+
if opts[:include_user]
|
62
|
+
build_url("/#{Config[:user]}#{rel_path}", include_user: false)
|
63
|
+
else
|
64
|
+
[Config[:saiku_url], "/rest/saiku", rel_path].join
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "saiku_client/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "saiku_client"
|
7
|
+
s.version = SaikuClient::VERSION
|
8
|
+
s.authors = ["Jason Sims"]
|
9
|
+
s.email = ["jason@noesissoftware.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Saiku Client Gem}
|
12
|
+
s.description = %q{Saiku Ruby integration client gem.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "saiku_client"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
s.add_development_dependency "rspec"
|
24
|
+
s.add_development_dependency 'simplecov-rcov'
|
25
|
+
s.add_development_dependency 'pry'
|
26
|
+
|
27
|
+
s.add_runtime_dependency "rest-client", "~> 1.6.7"
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SaikuClient do
|
4
|
+
|
5
|
+
describe "Config" do
|
6
|
+
specify { SaikuClient::Config[:saiku_url].should == "http://localhost:8080/saiku" }
|
7
|
+
specify { SaikuClient::Config[:user].should == "admin" }
|
8
|
+
specify { SaikuClient::Config[:password].should == "admin" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "Client" do
|
12
|
+
let(:client) { SaikuClient::Client.new }
|
13
|
+
let(:query) { client.repo_info.first["name"] }
|
14
|
+
|
15
|
+
specify { client.cookies.should be_a_kind_of(Hash) }
|
16
|
+
specify { client.repo_info.should be_a_kind_of(Array) }
|
17
|
+
specify { client.query_info(query).should be_a_kind_of(Hash) }
|
18
|
+
specify { client.run_query(query).should be_a_kind_of(Array) }
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
require 'support/simplecov_support'
|
9
|
+
require 'pry'
|
10
|
+
require 'saiku_client'
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
config.filter_run :focus
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
if ENV['COVERAGE']
|
2
|
+
require 'simplecov'
|
3
|
+
require 'simplecov-rcov'
|
4
|
+
|
5
|
+
SimpleCov.adapters.define 'saiku_client' do
|
6
|
+
add_filter 'vendor'
|
7
|
+
add_filter 'spec'
|
8
|
+
end
|
9
|
+
|
10
|
+
class SimpleCov::Formatter::MergedFormatter
|
11
|
+
def format(result)
|
12
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
13
|
+
SimpleCov::Formatter::RcovFormatter.new.format(result)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
17
|
+
|
18
|
+
SimpleCov.start 'saiku_client'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: saiku_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Sims
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: simplecov-rcov
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rest-client
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.6.7
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.6.7
|
94
|
+
description: Saiku Ruby integration client gem.
|
95
|
+
email:
|
96
|
+
- jason@noesissoftware.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- .rspec
|
103
|
+
- .rvmrc
|
104
|
+
- Gemfile
|
105
|
+
- Rakefile
|
106
|
+
- lib/saiku_client.rb
|
107
|
+
- lib/saiku_client/version.rb
|
108
|
+
- saiku_client.gemspec
|
109
|
+
- spec/lib/saiku_client_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- spec/support/simplecov_support.rb
|
112
|
+
homepage: ''
|
113
|
+
licenses: []
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
hash: -4397362905893649492
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
hash: -4397362905893649492
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project: saiku_client
|
138
|
+
rubygems_version: 1.8.24
|
139
|
+
signing_key:
|
140
|
+
specification_version: 3
|
141
|
+
summary: Saiku Client Gem
|
142
|
+
test_files:
|
143
|
+
- spec/lib/saiku_client_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
145
|
+
- spec/support/simplecov_support.rb
|