tableau_server_client 0.0.12 → 0.0.13
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 +4 -4
- data/lib/tableau_server_client/client.rb +4 -14
- data/lib/tableau_server_client/resources/datasource.rb +2 -1
- data/lib/tableau_server_client/resources/downloadable.rb +26 -0
- data/lib/tableau_server_client/resources/resource.rb +6 -0
- data/lib/tableau_server_client/resources/workbook.rb +2 -4
- data/lib/tableau_server_client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac40ff9b18e29df41bff878b7f3ba1f7c5a34ffa20690edb6d23784603afd617
|
4
|
+
data.tar.gz: 5ed21cfe75080d06b2db42b0a383cfb167ef84fde19f877bb22a31fc4fe91621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4677d14c34c02d7db0da58eaa14758047cd923764d4a8bcc74cc1450b7ea403fa06045251f297427c8a6d129904efe4db9c66eb0247cb1736663135490bb0c38
|
7
|
+
data.tar.gz: 30fb765574a89f51f53d1824e12dd8376603607d8842e2956ffe183c726473878dbab4ce6e53e0ffea887ad321194f22c9dcd4fd954202ac0a8aabfe37a584e0
|
@@ -56,23 +56,13 @@ module TableauServerClient
|
|
56
56
|
Nokogiri::XML(response.body).xpath("//xmlns:tsResponse").children.first
|
57
57
|
end
|
58
58
|
|
59
|
-
def download(resource_location)
|
59
|
+
def download(resource_location, file_path: nil)
|
60
60
|
req_url = request_url("#{resource_location.path}/content", resource_location.query_params)
|
61
61
|
response = session.get req_url.to_s
|
62
|
-
|
63
|
-
|
64
|
-
when 'application/xml'
|
65
|
-
return Nokogiri::XML(response.body)
|
66
|
-
when 'application/octet-stream'
|
67
|
-
Zip::InputStream.open(StringIO.new(response.body)) do |io|
|
68
|
-
while entry = io.get_next_entry
|
69
|
-
return Nokogiri::XML(io.read) if entry.name =~ /.*\.(tds|twb)/
|
70
|
-
end
|
71
|
-
raise "TDS or TWB file not found for: #{resource_location.path}"
|
72
|
-
end
|
73
|
-
else
|
74
|
-
raise "Unknown content-type: #{type}"
|
62
|
+
if file_path
|
63
|
+
File.write(file_path, response.body)
|
75
64
|
end
|
65
|
+
return response
|
76
66
|
end
|
77
67
|
|
78
68
|
def update(resource)
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'tableau_server_client/resources/resource'
|
2
2
|
require 'tableau_server_client/resources/project'
|
3
3
|
require 'tableau_server_client/resources/connection'
|
4
|
+
require 'tableau_server_client/resources/downloadable'
|
4
5
|
|
5
6
|
module TableauServerClient
|
6
7
|
module Resources
|
7
8
|
|
8
9
|
class Datasource < Resource
|
10
|
+
include Downloadable
|
9
11
|
|
10
12
|
attr_reader :id, :name, :content_url, :type, :created_at, :updated_at, :is_certified
|
11
13
|
attr_writer :owner
|
@@ -49,7 +51,6 @@ module TableauServerClient
|
|
49
51
|
@client.update self
|
50
52
|
end
|
51
53
|
|
52
|
-
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TableauServerClient
|
2
|
+
module Resources
|
3
|
+
|
4
|
+
module Downloadable
|
5
|
+
|
6
|
+
def download(file_path: nil)
|
7
|
+
response = client.download(location(query_params: {"includeExtract": "False"}), file_path: file_path)
|
8
|
+
type, disposition = response.headers.values_at('content-type', 'content-disposition')
|
9
|
+
case type
|
10
|
+
when 'application/xml'
|
11
|
+
return Nokogiri::XML(response.body)
|
12
|
+
when 'application/octet-stream'
|
13
|
+
Zip::InputStream.open(StringIO.new(response.body)) do |io|
|
14
|
+
while entry = io.get_next_entry
|
15
|
+
return Nokogiri::XML(io.read) if entry.name =~ /.*\.(tds|twb)/
|
16
|
+
end
|
17
|
+
raise "TDS or TWB file not found for: #{location.path}"
|
18
|
+
end
|
19
|
+
else
|
20
|
+
raise "Unknown content-type: #{type}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'tableau_server_client/resources/resource'
|
2
2
|
require 'tableau_server_client/resources/project'
|
3
3
|
require 'tableau_server_client/resources/connection'
|
4
|
+
require 'tableau_server_client/resources/downloadable'
|
4
5
|
|
5
6
|
module TableauServerClient
|
6
7
|
module Resources
|
7
8
|
|
8
9
|
class Workbook < Resource
|
10
|
+
include Downloadable
|
9
11
|
|
10
12
|
attr_reader :id, :name, :content_url, :show_tabs, :size, :created_at, :updated_at
|
11
13
|
attr_writer :owner
|
@@ -79,10 +81,6 @@ module TableauServerClient
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
|
-
def download
|
83
|
-
@twb ||= @client.download location(query_params: {"includeExtract": "False"})
|
84
|
-
end
|
85
|
-
|
86
84
|
def relations
|
87
85
|
download.xpath('//datasources//datasource//relation')
|
88
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tableau_server_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shimpeko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/tableau_server_client/request_url.rb
|
143
143
|
- lib/tableau_server_client/resources/connection.rb
|
144
144
|
- lib/tableau_server_client/resources/datasource.rb
|
145
|
+
- lib/tableau_server_client/resources/downloadable.rb
|
145
146
|
- lib/tableau_server_client/resources/extract_refresh.rb
|
146
147
|
- lib/tableau_server_client/resources/job.rb
|
147
148
|
- lib/tableau_server_client/resources/project.rb
|