gooddata 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.rubocop.yml +23 -0
- data/.travis.yml +9 -4
- data/CLI.md +439 -0
- data/Gemfile +0 -1
- data/README.md +2 -2
- data/Rakefile +60 -8
- data/doc/templates/default/module/setup.rb +1 -1
- data/examples.rb +2 -0
- data/gooddata +2 -0
- data/gooddata.gemspec +12 -8
- data/lib/gooddata.rb +0 -2
- data/lib/gooddata/bricks/base_downloader.rb +52 -47
- data/lib/gooddata/bricks/brick.rb +20 -31
- data/lib/gooddata/bricks/bricks.rb +1 -1
- data/lib/gooddata/bricks/middleware/base_middleware.rb +9 -7
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +12 -10
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +28 -28
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +20 -16
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +21 -19
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +10 -8
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +36 -34
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +11 -9
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +14 -12
- data/lib/gooddata/bricks/pipeline.rb +28 -0
- data/lib/gooddata/bricks/utils.rb +10 -8
- data/lib/gooddata/cli/cli.rb +1 -6
- data/lib/gooddata/cli/commands/auth_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/console_cmd.rb +7 -5
- data/lib/gooddata/cli/commands/domain_cmd.rb +45 -0
- data/lib/gooddata/cli/commands/process_cmd.rb +42 -5
- data/lib/gooddata/cli/commands/project_cmd.rb +96 -36
- data/lib/gooddata/cli/commands/projects_cmd.rb +21 -0
- data/lib/gooddata/cli/commands/role_cmd.rb +28 -0
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +5 -5
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/{profile_cmd.rb → user_cmd.rb} +7 -9
- data/lib/gooddata/cli/shared.rb +3 -2
- data/lib/gooddata/client.rb +16 -304
- data/lib/gooddata/commands/api.rb +13 -5
- data/lib/gooddata/commands/auth.rb +47 -40
- data/lib/gooddata/commands/base.rb +4 -2
- data/lib/gooddata/commands/commands.rb +1 -1
- data/lib/gooddata/commands/datasets.rb +20 -7
- data/lib/gooddata/commands/domain.rb +23 -0
- data/lib/gooddata/commands/process.rb +23 -117
- data/lib/gooddata/commands/project.rb +147 -0
- data/lib/gooddata/commands/projects.rb +8 -102
- data/lib/gooddata/commands/role.rb +26 -0
- data/lib/gooddata/commands/runners.rb +41 -38
- data/lib/gooddata/commands/scaffold.rb +46 -43
- data/lib/gooddata/commands/user.rb +33 -0
- data/lib/gooddata/connection.rb +43 -353
- data/lib/gooddata/core/connection.rb +389 -0
- data/lib/gooddata/core/core.rb +5 -4
- data/lib/gooddata/core/logging.rb +48 -0
- data/lib/gooddata/core/nil_logger.rb +13 -0
- data/lib/gooddata/core/project.rb +70 -0
- data/lib/gooddata/core/rest.rb +120 -0
- data/lib/gooddata/core/threaded.rb +14 -0
- data/lib/gooddata/core/user.rb +19 -0
- data/lib/gooddata/data/data.rb +2 -1
- data/lib/gooddata/data/guesser.rb +16 -12
- data/lib/gooddata/exceptions/command_failed.rb +1 -1
- data/lib/gooddata/exceptions/exceptions.rb +2 -1
- data/lib/gooddata/exceptions/no_project_error.rb +11 -0
- data/lib/gooddata/exceptions/project_not_found.rb +1 -1
- data/lib/gooddata/extensions/big_decimal.rb +6 -2
- data/lib/gooddata/extract.rb +10 -8
- data/lib/gooddata/goodzilla/goodzilla.rb +61 -59
- data/lib/gooddata/helpers.rb +15 -9
- data/lib/gooddata/models/account_settings.rb +124 -0
- data/lib/gooddata/models/attributes/anchor.rb +37 -0
- data/lib/gooddata/models/attributes/attributes.rb +8 -0
- data/lib/gooddata/models/attributes/date_attribute.rb +25 -0
- data/lib/gooddata/models/attributes/time_attribute.rb +24 -0
- data/lib/gooddata/models/columns/attribute.rb +71 -0
- data/lib/gooddata/models/columns/columns.rb +8 -0
- data/lib/gooddata/models/columns/date_column.rb +63 -0
- data/lib/gooddata/models/columns/fact_model.rb +54 -0
- data/lib/gooddata/models/columns/label.rb +55 -0
- data/lib/gooddata/models/columns/reference.rb +57 -0
- data/lib/gooddata/models/dashboard_builder.rb +26 -0
- data/lib/gooddata/models/data_result.rb +10 -9
- data/lib/gooddata/models/domain.rb +131 -0
- data/lib/gooddata/models/empty_result.rb +5 -8
- data/lib/gooddata/models/facts/facts.rb +8 -0
- data/lib/gooddata/models/facts/time_fact.rb +20 -0
- data/lib/gooddata/models/folders/attribute_folder.rb +20 -0
- data/lib/gooddata/models/folders/fact_folder.rb +20 -0
- data/lib/gooddata/models/folders/folders.rb +8 -0
- data/lib/gooddata/models/invitation.rb +78 -0
- data/lib/gooddata/models/links.rb +6 -6
- data/lib/gooddata/models/md_object.rb +25 -0
- data/lib/gooddata/models/metadata.rb +160 -62
- data/lib/gooddata/models/metadata/attribute.rb +81 -0
- data/lib/gooddata/models/metadata/column.rb +61 -0
- data/lib/gooddata/models/{dashboard.rb → metadata/dashboard.rb} +12 -7
- data/lib/gooddata/models/{data_set.rb → metadata/data_set.rb} +5 -4
- data/lib/gooddata/models/metadata/date_dimension.rb +26 -0
- data/lib/gooddata/models/metadata/display_form.rb +61 -0
- data/lib/gooddata/models/metadata/fact.rb +36 -0
- data/lib/gooddata/models/metadata/folder.rb +24 -0
- data/lib/gooddata/models/metadata/metadata.rb +8 -0
- data/lib/gooddata/models/metadata/metric.rb +197 -0
- data/lib/gooddata/models/metadata/report.rb +115 -0
- data/lib/gooddata/models/{report_definition.rb → metadata/report_definition.rb} +16 -10
- data/lib/gooddata/models/metadata/schema.rb +227 -0
- data/lib/gooddata/models/model.rb +38 -1339
- data/lib/gooddata/models/models.rb +5 -2
- data/lib/gooddata/models/module_constants.rb +29 -0
- data/lib/gooddata/models/process.rb +142 -13
- data/lib/gooddata/models/profile.rb +4 -6
- data/lib/gooddata/models/project.rb +406 -136
- data/lib/gooddata/models/project_blueprint.rb +221 -0
- data/lib/gooddata/models/project_builder.rb +136 -0
- data/lib/gooddata/models/project_creator.rb +138 -0
- data/lib/gooddata/models/project_metadata.rb +11 -10
- data/lib/gooddata/models/project_role.rb +92 -0
- data/lib/gooddata/models/references/date_reference.rb +44 -0
- data/lib/gooddata/models/references/references.rb +8 -0
- data/lib/gooddata/models/references/time_reference.rb +13 -0
- data/lib/gooddata/models/report_data_result.rb +11 -11
- data/lib/gooddata/models/schedule.rb +284 -0
- data/lib/gooddata/models/schema_blueprint.rb +158 -0
- data/lib/gooddata/models/schema_builder.rb +81 -0
- data/lib/gooddata/models/tab_builder.rb +23 -0
- data/lib/gooddata/models/user.rb +165 -0
- data/lib/gooddata/version.rb +1 -1
- data/lib/templates/project/data/devs.csv +1 -1
- data/lib/templates/project/data/repos.csv +1 -1
- data/lib/templates/project/model/model.rb.erb +7 -11
- data/spec/bricks/bricks_spec.rb +2 -0
- data/spec/data/test-ci-data.csv +2 -0
- data/spec/data/test_project_model_spec.json +7 -27
- data/spec/helpers/blueprint_helper.rb +2 -0
- data/spec/helpers/cli_helper.rb +2 -0
- data/spec/helpers/connection_helper.rb +14 -1
- data/spec/helpers/project_helper.rb +16 -0
- data/spec/helpers/schema_helper.rb +16 -0
- data/spec/integration/command_projects_spec.rb +7 -7
- data/spec/integration/create_from_template_spec.rb +2 -2
- data/spec/integration/full_project_spec.rb +160 -7
- data/spec/integration/partial_md_export_import_spec.rb +3 -3
- data/spec/logging_in_logging_out_spec.rb +2 -1
- data/spec/spec_helper.rb +26 -4
- data/spec/unit/bricks/bricks_spec.rb +15 -7
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +2 -0
- data/spec/unit/cli/cli_spec.rb +2 -0
- data/spec/unit/cli/commands/cmd_api_spec.rb +23 -15
- data/spec/unit/cli/commands/cmd_auth_spec.rb +8 -4
- data/spec/unit/cli/commands/cmd_domain_spec.rb +82 -0
- data/spec/unit/cli/commands/cmd_process_spec.rb +29 -13
- data/spec/unit/cli/commands/cmd_project_spec.rb +51 -30
- data/spec/unit/cli/commands/cmd_role_spec.rb +44 -0
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +8 -4
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +48 -11
- data/spec/unit/cli/commands/cmd_user_spec.rb +29 -0
- data/spec/unit/commands/command_api_spec.rb +1 -1
- data/spec/unit/commands/command_auth_spec.rb +100 -18
- data/spec/unit/commands/command_dataset_spec.rb +4 -0
- data/spec/unit/commands/command_process_spec.rb +9 -4
- data/spec/unit/commands/command_projects_spec.rb +10 -6
- data/spec/unit/commands/command_scaffold_spec.rb +5 -1
- data/spec/unit/commands/command_user_spec.rb +22 -0
- data/spec/unit/core/connection_spec.rb +35 -6
- data/spec/unit/core/logging_spec.rb +65 -0
- data/spec/unit/core/nil_logger_spec.rb +9 -0
- data/spec/unit/core/project_spec.rb +51 -0
- data/spec/unit/core/rest_spec.rb +33 -0
- data/spec/unit/data/guesser_spec.rb +5 -0
- data/spec/unit/godzilla/goodzilla_spec.rb +2 -0
- data/spec/unit/models/account_settings_spec.rb +28 -0
- data/spec/unit/models/anchor_spec.rb +32 -0
- data/spec/unit/models/attribute_column_spec.rb +7 -0
- data/spec/unit/models/domain_spec.rb +45 -0
- data/spec/unit/models/invitation_spec.rb +13 -0
- data/spec/unit/models/md_object_spec.rb +47 -0
- data/spec/unit/models/metric.rb +92 -0
- data/spec/unit/{model → models}/model_spec.rb +9 -7
- data/spec/unit/models/project_blueprint_spec.rb +202 -0
- data/spec/unit/models/project_creator.rb +73 -0
- data/spec/unit/models/project_role_spec.rb +90 -0
- data/spec/unit/models/project_spec.rb +143 -0
- data/spec/unit/models/schedule_spec.rb +491 -0
- data/spec/unit/{model → models}/schema_builder_spec.rb +2 -0
- data/spec/unit/{model → models}/tools_spec.rb +13 -7
- data/spec/unit/models/user_spec.rb +16 -0
- data/test/test_upload.rb +2 -0
- metadata +189 -86
- data/lib/gooddata/commands/profile.rb +0 -11
- data/lib/gooddata/models/attribute.rb +0 -29
- data/lib/gooddata/models/display_form.rb +0 -9
- data/lib/gooddata/models/fact.rb +0 -19
- data/lib/gooddata/models/metric.rb +0 -99
- data/lib/gooddata/models/report.rb +0 -89
- data/spec/data/blueprint_valid.json +0 -37
- data/spec/unit/cli/commands/cmd_profile_spec.rb +0 -16
- data/spec/unit/commands/command_profile_spec.rb +0 -18
- data/spec/unit/core/core_spec.rb +0 -7
- data/spec/unit/model/blueprint_spec.rb +0 -132
- data/spec/unit/model/project_blueprint_spec.rb +0 -44
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -17,8 +17,6 @@ The best documentation for the GoodData API can be found using these resources:
|
|
17
17
|
[![Code Climate](https://codeclimate.com/github/gooddata/gooddata-ruby.png)](https://codeclimate.com/github/gooddata/gooddata-ruby)
|
18
18
|
[![Build Status](https://travis-ci.org/gooddata/gooddata-ruby.png)](https://travis-ci.org/gooddata/gooddata-ruby)
|
19
19
|
[![Coverage Status](https://coveralls.io/repos/gooddata/gooddata-ruby/badge.png)](https://coveralls.io/r/gooddata/gooddata-ruby)
|
20
|
-
[![Build Status](https://travis-ci.org/gooddata/gooddata-ruby.png)](https://travis-ci.org/gooddata/gooddata-ruby)
|
21
|
-
|
22
20
|
|
23
21
|
## Install
|
24
22
|
|
@@ -44,6 +42,8 @@ If you are using gems just
|
|
44
42
|
future version unintentionally.
|
45
43
|
* Commit, do not mess with rakefile, version, or history.
|
46
44
|
(if you want to have your own version, that is fine but bump version in a commit by itself we can ignore when we pull)
|
45
|
+
* run `rake test` and make sure all tests passes
|
46
|
+
* run `rake cop` and make sure you did not introduced any new coding rules issues
|
47
47
|
* Send us a pull request. Bonus points for topic branches.
|
48
48
|
|
49
49
|
## Credits
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
|
3
5
|
require 'bundler/setup'
|
@@ -6,6 +8,7 @@ require 'bundler/gem_tasks'
|
|
6
8
|
require 'coveralls/rake/task'
|
7
9
|
|
8
10
|
require 'rake/testtask'
|
11
|
+
require 'rake/notes/rake_task'
|
9
12
|
require 'rspec/core/rake_task'
|
10
13
|
|
11
14
|
require 'yard'
|
@@ -17,14 +20,58 @@ end
|
|
17
20
|
|
18
21
|
Coveralls::RakeTask.new
|
19
22
|
|
20
|
-
desc
|
21
|
-
task :
|
22
|
-
|
23
|
-
|
23
|
+
desc 'Run continuous integration test'
|
24
|
+
task :ci do
|
25
|
+
Rake::Task['test:unit'].invoke
|
26
|
+
unless ENV['TRAVIS'] == 'true' && ENV['TRAVIS_SECURE_ENV_VARS'] == 'false'
|
27
|
+
Rake::Task['test:integration'].invoke
|
28
|
+
end
|
29
|
+
Rake::Task['test:cop'].invoke if RUBY_VERSION.start_with?('2.2') == false
|
30
|
+
Rake::Task['coveralls:push'].invoke
|
31
|
+
end
|
32
|
+
|
33
|
+
namespace :hook do
|
34
|
+
hook_path = File.join(File.dirname(__FILE__), '.git', 'hooks', 'pre-commit').to_s
|
35
|
+
|
36
|
+
desc 'Installs git pre-commit hook running rubocop'
|
37
|
+
task :install do |t|
|
38
|
+
if(File.exist?(hook_path))
|
39
|
+
puts 'Git pre-commit hook is already installed'
|
40
|
+
else
|
41
|
+
File.open(hook_path, 'w') do |file|
|
42
|
+
file.write("#! /usr/bin/env bash\n")
|
43
|
+
file.write("\n")
|
44
|
+
file.write("rake cop\n")
|
45
|
+
end
|
46
|
+
system "chmod 755 #{hook_path}"
|
47
|
+
puts 'Git commit hook was installed'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Uninstalls git pre-commit hook'
|
52
|
+
task :uninstall do |t|
|
53
|
+
res = File.exist?(hook_path)
|
54
|
+
if res
|
55
|
+
puts 'Uninstalling git pre-commit hook'
|
56
|
+
system "rm #{hook_path}"
|
57
|
+
puts 'Git pre-commit hook was uninstalled'
|
58
|
+
else
|
59
|
+
puts 'Git pre-commit hook is not installed'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'Checks if is git pre-commit hook installed'
|
64
|
+
task :check do
|
65
|
+
res = File.exist?(hook_path)
|
66
|
+
if res
|
67
|
+
puts 'Git pre-commit IS installed'
|
68
|
+
else
|
69
|
+
puts 'Git pre-commit IS NOT installed'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
24
73
|
end
|
25
74
|
|
26
|
-
desc 'Run tests with coveralls'
|
27
|
-
task :coveralls => ['coverage', 'coveralls:push']
|
28
75
|
|
29
76
|
RSpec::Core::RakeTask.new(:test)
|
30
77
|
|
@@ -44,7 +91,12 @@ namespace :test do
|
|
44
91
|
t.pattern = 'test/**/test_*.rb'
|
45
92
|
end
|
46
93
|
|
47
|
-
|
94
|
+
desc "Run coding style tests"
|
95
|
+
RSpec::Core::RakeTask.new(:cop) do |t|
|
96
|
+
Rake::Task['cop'].invoke
|
97
|
+
end
|
98
|
+
|
99
|
+
task :all => [:unit, :integration, :cop]
|
48
100
|
end
|
49
101
|
|
50
102
|
desc "Run all tests"
|
@@ -56,4 +108,4 @@ end
|
|
56
108
|
|
57
109
|
YARD::Rake::YardocTask.new
|
58
110
|
|
59
|
-
task :default => [:usage]
|
111
|
+
task :default => [:usage]
|
@@ -37,7 +37,7 @@ def method_listing(include_specials = true)
|
|
37
37
|
return @meths if @meths
|
38
38
|
@meths = object.meths(:inherited => false, :included => !options.embed_mixins.empty?)
|
39
39
|
if options.embed_mixins.size > 0
|
40
|
-
@meths = @meths.reject {|m| options.embed_mixins_match?(m.namespace)
|
40
|
+
@meths = @meths.reject {|m| !options.embed_mixins_match?(m.namespace) }
|
41
41
|
end
|
42
42
|
@meths = sort_listing(prune_method_listing(@meths))
|
43
43
|
@meths
|
data/examples.rb
CHANGED
data/gooddata
CHANGED
data/gooddata.gemspec
CHANGED
@@ -10,7 +10,9 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [
|
12
12
|
"Pavel Kolesnikov",
|
13
|
-
"Thomas Watson Steen"
|
13
|
+
"Thomas Watson Steen",
|
14
|
+
"Tomas Svarovsky",
|
15
|
+
"Tomas Korcak"
|
14
16
|
]
|
15
17
|
|
16
18
|
s.summary = %q{A convenient Ruby wrapper around the GoodData RESTful API}
|
@@ -27,24 +29,26 @@ Gem::Specification.new do |s|
|
|
27
29
|
s.require_paths = ["lib"]
|
28
30
|
s.rubygems_version = "1.3.7"
|
29
31
|
|
30
|
-
s.add_development_dependency "rake", "~> 10.
|
31
|
-
s.add_development_dependency "
|
32
|
+
s.add_development_dependency "rake", "~> 10.3.1"
|
33
|
+
s.add_development_dependency "rake-notes", "~> 0.2.0"
|
34
|
+
s.add_development_dependency "redcarpet", "~> 3.1.1" if RUBY_PLATFORM != 'java'
|
32
35
|
s.add_development_dependency "rspec", "~> 2.14.1"
|
33
|
-
s.add_development_dependency "rubocop", "~> 0.20.
|
36
|
+
s.add_development_dependency "rubocop", "~> 0.20.1"
|
34
37
|
s.add_development_dependency "simplecov", "~> 0.8.2"
|
35
38
|
s.add_development_dependency "yard", "~> 0.8.7.3"
|
36
39
|
s.add_development_dependency "yard-rspec", "~> 0.1"
|
37
|
-
s.add_development_dependency "ZenTest", "~> 4.
|
40
|
+
s.add_development_dependency "ZenTest", "~> 4.10.0"
|
38
41
|
s.add_development_dependency "coveralls", "~> 0.7.0"
|
39
42
|
|
40
|
-
s.add_dependency "activesupport", "~> 4.0
|
43
|
+
s.add_dependency "activesupport", "~> 4.1.0"
|
41
44
|
s.add_dependency "bundler", ">= 1.6.1"
|
45
|
+
s.add_dependency 'docile', '~> 1.1.3'
|
42
46
|
s.add_dependency "erubis", "~> 2.7.0"
|
43
|
-
s.add_dependency "gli", "~> 2.
|
47
|
+
s.add_dependency "gli", "~> 2.10.0"
|
44
48
|
s.add_dependency "highline", "~> 1.6.21"
|
45
49
|
s.add_dependency "i18n", "~> 0.6.9"
|
46
50
|
s.add_dependency "json_pure", "~> 1.8.1"
|
47
|
-
s.add_dependency "multi_json", "~> 1.
|
51
|
+
s.add_dependency "multi_json", "~> 1.10.0"
|
48
52
|
s.add_dependency "parseconfig", "~> 1.0.4"
|
49
53
|
s.add_dependency "pry", "~> 0.9.12.6"
|
50
54
|
s.add_dependency "restforce", "~> 1.4.3"
|
data/lib/gooddata.rb
CHANGED
@@ -1,63 +1,68 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
4
|
-
class BaseDownloader
|
5
|
-
def initialize(params)
|
6
|
-
@params = params
|
7
|
-
end
|
3
|
+
require 'pathname'
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
module GoodData
|
6
|
+
module Bricks
|
7
|
+
class BaseDownloader
|
8
|
+
def initialize(params)
|
9
|
+
@params = params
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
12
|
+
def pre_process(meta)
|
13
|
+
meta
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
memo << item[:filename]
|
16
|
+
def download
|
17
|
+
puts 'would download data'
|
18
|
+
[]
|
22
19
|
end
|
23
20
|
|
24
|
-
|
21
|
+
def backup(meta)
|
22
|
+
puts 'would send a backup list of files to backup'
|
23
|
+
files = meta.reduce([]) do |a, e|
|
24
|
+
a << e[:filename]
|
25
|
+
end
|
26
|
+
|
27
|
+
bucket_name = @params[:s3_backup_bucket_name]
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
s3 = AWS::S3.new(
|
30
|
+
:access_key_id => @params[:aws_access_key_id],
|
31
|
+
:secret_access_key => @params[:aws_secret_access_key])
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
bucket = s3.buckets[bucket_name]
|
34
|
+
bucket = s3.buckets.create(bucket_name) unless bucket.exists?
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
files.each do |file|
|
37
|
+
obj = bucket.objects[file]
|
38
|
+
obj.write(Pathname.new(file))
|
39
|
+
end
|
40
|
+
meta
|
36
41
|
end
|
37
|
-
meta
|
38
|
-
end
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
def post_process(meta)
|
44
|
+
puts 'Maybe some postprocessing'
|
45
|
+
meta
|
46
|
+
end
|
47
|
+
|
48
|
+
# Run downloader
|
49
|
+
def run
|
50
|
+
downloaded_data = download
|
51
|
+
downloaded_data = pre_process(downloaded_data)
|
52
|
+
backup(downloaded_data)
|
53
|
+
downloaded_data = post_process(downloaded_data)
|
54
|
+
|
55
|
+
accumulated_state = downloaded_data.reduce([]) do |memo, item|
|
56
|
+
item.key?(:state) ? memo.concat(item[:state]) : memo
|
57
|
+
end
|
58
|
+
accumulated_state.each do |item|
|
59
|
+
key = item[:key]
|
60
|
+
val = item[:value]
|
44
61
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
downloaded_data = pre_process(downloaded_data)
|
49
|
-
backup(downloaded_data)
|
50
|
-
downloaded_data = post_process(downloaded_data)
|
51
|
-
|
52
|
-
downloaded_data.reduce([]) do |memo, item|
|
53
|
-
item.has_key?(:state) ? memo.concat(item[:state]) : memo
|
54
|
-
end.each do |item|
|
55
|
-
key = item[:key]
|
56
|
-
val = item[:value]
|
57
|
-
|
58
|
-
puts "Saving metadata #{key} => #{val}"
|
59
|
-
GoodData::ProjectMetadata[key] = val
|
62
|
+
puts "Saving metadata #{key} => #{val}"
|
63
|
+
GoodData::ProjectMetadata[key] = val
|
64
|
+
end
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
63
|
-
end
|
68
|
+
end
|
@@ -3,43 +3,32 @@
|
|
3
3
|
require_relative 'base_downloader'
|
4
4
|
require_relative 'utils'
|
5
5
|
|
6
|
-
Dir[File.dirname(__FILE__) + '/commands/**/*_cmd.rb'].each do |file|
|
7
|
-
require file
|
8
|
-
end
|
9
|
-
|
10
6
|
require_relative 'middleware/middleware'
|
11
7
|
|
12
|
-
module GoodData
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
app.respond_to?(:new) ? (app.new(:app => memo)) : (app.app = memo; app)
|
20
|
-
end
|
8
|
+
module GoodData
|
9
|
+
module Bricks
|
10
|
+
# Brick base class
|
11
|
+
class Brick
|
12
|
+
def log(message)
|
13
|
+
logger = @params[:gdc_logger]
|
14
|
+
logger.info(message) unless logger.nil?
|
21
15
|
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Brick base class
|
26
|
-
class Brick
|
27
|
-
def log(message)
|
28
|
-
logger = @params[:gdc_logger]
|
29
|
-
logger.info(message) unless logger.nil?
|
30
|
-
end
|
31
16
|
|
32
|
-
|
33
|
-
|
34
|
-
|
17
|
+
# Name of the brick
|
18
|
+
def name
|
19
|
+
self.class
|
20
|
+
end
|
35
21
|
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
# Version of brick, this should be implemented in subclasses
|
23
|
+
def version
|
24
|
+
fail NotImplementedError, 'Method version should be reimplemented'
|
25
|
+
end
|
39
26
|
|
40
|
-
|
41
|
-
|
42
|
-
|
27
|
+
# Bricks implementation which can be 'called'
|
28
|
+
def call(params = {})
|
29
|
+
@params = params
|
30
|
+
''
|
31
|
+
end
|
43
32
|
end
|
44
33
|
end
|
45
34
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
module GoodData
|
4
|
-
|
5
|
-
|
3
|
+
module GoodData
|
4
|
+
module Bricks
|
5
|
+
class Middleware
|
6
|
+
attr_accessor :app
|
6
7
|
|
7
|
-
|
8
|
+
include Bricks::Utils
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
def initialize(options = {})
|
11
|
+
@app = options[:app]
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
|
-
end
|
15
|
+
end
|
@@ -3,15 +3,17 @@
|
|
3
3
|
require 'benchmark'
|
4
4
|
require_relative 'base_middleware'
|
5
5
|
|
6
|
-
module GoodData
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
module GoodData
|
7
|
+
module Bricks
|
8
|
+
class BenchMiddleware < Bricks::Middleware
|
9
|
+
def call(params)
|
10
|
+
puts 'Starting timer'
|
11
|
+
result = nil
|
12
|
+
report = Benchmark.measure { result = @app.call(params) }
|
13
|
+
puts 'Stopping timer'
|
14
|
+
pp report
|
15
|
+
result
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
|
-
end
|
19
|
+
end
|
@@ -4,35 +4,35 @@ require 'salesforce_bulk'
|
|
4
4
|
|
5
5
|
require_relative 'base_middleware'
|
6
6
|
|
7
|
-
module GoodData
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
module GoodData
|
8
|
+
module Bricks
|
9
|
+
class BulkSalesforceMiddleware < Bricks::Middleware
|
10
|
+
def call(params)
|
11
|
+
username = params[:salesforce_username]
|
12
|
+
password = params[:salesforce_password]
|
13
|
+
token = params[:salesforce_token]
|
14
|
+
client_id = params[:salesforce_client_id]
|
15
|
+
client_secret = params[:salesforce_client_secret]
|
16
|
+
host = params[:salesforce_host]
|
16
17
|
|
17
|
-
|
18
|
+
credentials = if username && password && token
|
19
|
+
{
|
20
|
+
:username => username,
|
21
|
+
:password => password,
|
22
|
+
:security_token => token
|
23
|
+
}
|
24
|
+
end
|
18
25
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
:client_id => client_id,
|
30
|
-
:client_secret => client_secret,
|
31
|
-
})
|
32
|
-
credentials[:host] = host unless host.nil?
|
33
|
-
SalesforceBulk::Api.new(credentials[:username], credentials[:password] + credentials[:security_token])
|
34
|
-
end
|
35
|
-
@app.call(params.merge(:salesforce_bulk_client => client))
|
26
|
+
client = if credentials
|
27
|
+
credentials.merge!(
|
28
|
+
:client_id => client_id,
|
29
|
+
:client_secret => client_secret
|
30
|
+
)
|
31
|
+
credentials[:host] = host unless host.nil?
|
32
|
+
SalesforceBulk::Api.new(credentials[:username], credentials[:password] + credentials[:security_token])
|
33
|
+
end
|
34
|
+
@app.call(params.merge(:salesforce_bulk_client => client))
|
35
|
+
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end
|