gooddata 0.6.0.pre11 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -1
  3. data/.yardopts +2 -0
  4. data/README.md +6 -3
  5. data/Rakefile +24 -7
  6. data/gooddata +2 -2
  7. data/gooddata.gemspec +4 -3
  8. data/lib/gooddata.rb +17 -12
  9. data/lib/gooddata/bricks/base_downloader.rb +7 -7
  10. data/lib/gooddata/bricks/brick.rb +7 -8
  11. data/lib/gooddata/bricks/bricks.rb +4 -1
  12. data/lib/gooddata/bricks/middleware/base_middleware.rb +2 -2
  13. data/lib/gooddata/bricks/middleware/bench_middleware.rb +5 -6
  14. data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +21 -22
  15. data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +3 -4
  16. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +14 -14
  17. data/lib/gooddata/bricks/middleware/logger_middleware.rb +6 -6
  18. data/lib/gooddata/bricks/middleware/middleware.rb +4 -1
  19. data/lib/gooddata/bricks/middleware/restforce_middleware.rb +29 -32
  20. data/lib/gooddata/bricks/middleware/stdout_middleware.rb +5 -5
  21. data/lib/gooddata/bricks/middleware/twitter_middleware.rb +6 -8
  22. data/lib/gooddata/bricks/utils.rb +3 -3
  23. data/lib/gooddata/cli/cli.rb +4 -2
  24. data/lib/gooddata/cli/commands/api_cmd.rb +6 -4
  25. data/lib/gooddata/cli/commands/auth_cmd.rb +5 -3
  26. data/lib/gooddata/cli/commands/console_cmd.rb +1 -1
  27. data/lib/gooddata/cli/commands/process_cmd.rb +6 -4
  28. data/lib/gooddata/cli/commands/profile_cmd.rb +5 -3
  29. data/lib/gooddata/cli/commands/project_cmd.rb +24 -22
  30. data/lib/gooddata/cli/commands/run_ruby_cmd.rb +12 -10
  31. data/lib/gooddata/cli/commands/scaffold_cmd.rb +8 -6
  32. data/lib/gooddata/cli/hooks.rb +4 -2
  33. data/lib/gooddata/cli/shared.rb +3 -1
  34. data/lib/gooddata/cli/terminal.rb +16 -0
  35. data/lib/gooddata/client.rb +28 -22
  36. data/lib/gooddata/commands/api.rb +43 -26
  37. data/lib/gooddata/commands/auth.rb +22 -53
  38. data/lib/gooddata/commands/base.rb +2 -0
  39. data/lib/gooddata/commands/commands.rb +3 -0
  40. data/lib/gooddata/commands/datasets.rb +39 -136
  41. data/lib/gooddata/commands/process.rb +134 -130
  42. data/lib/gooddata/commands/profile.rb +2 -0
  43. data/lib/gooddata/commands/projects.rb +91 -129
  44. data/lib/gooddata/commands/runners.rb +11 -11
  45. data/lib/gooddata/commands/scaffold.rb +28 -26
  46. data/lib/gooddata/connection.rb +61 -68
  47. data/lib/gooddata/core/core.rb +1 -2
  48. data/lib/gooddata/data/data.rb +7 -0
  49. data/lib/gooddata/data/guesser.rb +114 -0
  50. data/lib/gooddata/exceptions/command_failed.rb +7 -0
  51. data/lib/gooddata/exceptions/exceptions.rb +7 -0
  52. data/lib/gooddata/{exceptions.rb → exceptions/project_not_found.rb} +2 -2
  53. data/lib/gooddata/extensions/big_decimal.rb +5 -0
  54. data/lib/gooddata/extract.rb +2 -0
  55. data/lib/gooddata/goodzilla/goodzilla.rb +11 -12
  56. data/lib/gooddata/helpers.rb +49 -35
  57. data/lib/gooddata/models/attribute.rb +7 -5
  58. data/lib/gooddata/models/dashboard.rb +44 -45
  59. data/lib/gooddata/models/data_result.rb +10 -13
  60. data/lib/gooddata/models/data_set.rb +6 -6
  61. data/lib/gooddata/models/display_form.rb +4 -4
  62. data/lib/gooddata/models/empty_result.rb +4 -3
  63. data/lib/gooddata/models/fact.rb +5 -5
  64. data/lib/gooddata/models/links.rb +3 -1
  65. data/lib/gooddata/models/metadata.rb +34 -32
  66. data/lib/gooddata/models/metric.rb +33 -34
  67. data/lib/gooddata/models/model.rb +165 -173
  68. data/lib/gooddata/models/models.rb +3 -0
  69. data/lib/gooddata/models/process.rb +18 -17
  70. data/lib/gooddata/models/profile.rb +3 -1
  71. data/lib/gooddata/models/project.rb +107 -35
  72. data/lib/gooddata/models/project_metadata.rb +12 -12
  73. data/lib/gooddata/models/report.rb +31 -30
  74. data/lib/gooddata/models/report_data_result.rb +22 -19
  75. data/lib/gooddata/models/report_definition.rb +101 -80
  76. data/lib/gooddata/version.rb +5 -3
  77. data/lib/templates/bricks/brick.rb.erb +3 -3
  78. data/lib/templates/bricks/main.rb.erb +3 -2
  79. data/lib/templates/project/Goodfile.erb +2 -2
  80. data/lib/templates/project/model/model.rb.erb +19 -19
  81. data/spec/data/.gooddata +4 -0
  82. data/spec/helpers/blueprint_helper.rb +2 -2
  83. data/spec/helpers/cli_helper.rb +28 -0
  84. data/spec/helpers/connection_helper.rb +2 -2
  85. data/spec/integration/command_projects_spec.rb +1 -1
  86. data/spec/integration/create_from_template_spec.rb +12 -0
  87. data/spec/integration/full_project_spec.rb +2 -2
  88. data/spec/integration/partial_md_export_import_spec.rb +36 -0
  89. data/spec/logging_in_logging_out_spec.rb +1 -1
  90. data/spec/spec_helper.rb +29 -2
  91. data/spec/unit/cli/cli_spec.rb +3 -3
  92. data/spec/unit/cli/commands/cmd_api_spec.rb +21 -4
  93. data/spec/unit/cli/commands/cmd_auth_spec.rb +2 -4
  94. data/spec/unit/cli/commands/cmd_process_spec.rb +20 -4
  95. data/spec/unit/cli/commands/cmd_profile_spec.rb +9 -4
  96. data/spec/unit/cli/commands/cmd_project_spec.rb +53 -4
  97. data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +2 -4
  98. data/spec/unit/cli/commands/cmd_scaffold_spec.rb +14 -4
  99. data/spec/unit/commands/command_api_spec.rb +21 -2
  100. data/spec/unit/commands/command_auth_spec.rb +62 -1
  101. data/spec/unit/commands/command_dataset_spec.rb +31 -3
  102. data/spec/unit/commands/command_process_spec.rb +75 -1
  103. data/spec/unit/commands/command_profile_spec.rb +7 -1
  104. data/spec/unit/commands/command_projects_spec.rb +1 -1
  105. data/spec/unit/commands/command_scaffold_spec.rb +46 -1
  106. data/spec/unit/core/connection_spec.rb +1 -0
  107. data/spec/unit/data/guesser_spec.rb +54 -0
  108. data/spec/unit/helpers_spec.rb +47 -0
  109. data/spec/unit/model/schema_builder_spec.rb +2 -0
  110. data/spec/unit/model/tools_spec.rb +89 -0
  111. data/test/test_upload.rb +39 -15
  112. metadata +98 -75
  113. data/test/test_commands.rb +0 -85
  114. data/test/test_guessing.rb +0 -46
  115. data/test/test_model.rb +0 -81
  116. data/test/test_rest_api_basic.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 143aa38816bd648dc9f03a63e2453432ccf2581f
4
- data.tar.gz: 3e5d3940d94a67474d14400def5addfc0e91e92a
3
+ metadata.gz: 1b075f6efe569bc8551b63e727f4b8e2f988759a
4
+ data.tar.gz: de39298550e34a781eb07a8af849e7ce6e6b8452
5
5
  SHA512:
6
- metadata.gz: 793043d0ffccb3d565b6c5458b2a7a6358acd77995e4a3fb9302dea6c85ea2c6193f69487f0b63392caaafb501149203b754a4bf62a82c5db7231a092a97ee20
7
- data.tar.gz: e2814af4b8916f9a1b25fe34938ac3955b43418385a8495fff639ccd436006a3a66042d668a1f51fb7b819d2c86eb28048cd9e0fc3feb9fdc290102e35284354
6
+ metadata.gz: d593ea85fad5d42a14821e1a817c01c479fc897c25d3ff8688b77343817c190b9f8d0ea06e8df1976ccf31e222acb5f45622caa358a392f9e4e1d347bc66e774
7
+ data.tar.gz: 2b56559b63c3463c25eba41de9265ee3b8cc6fdc2fea1d1b8fbbaa00b24833fb88e552356fc8ca3cb397b625f733f762966e29e024ec3d6115f1201fd3bdf16f
data/.travis.yml CHANGED
@@ -1,7 +1,18 @@
1
1
  language: ruby
2
+
3
+ env:
4
+ - TEST_SUITE=test:unit
5
+
2
6
  rvm:
3
7
  - 1.9.3
4
8
  - 2.1.0
5
9
  - ruby-head
6
10
 
7
- script: rake test:unit
11
+ before_install:
12
+ - gem update --system
13
+ - gem update bundler
14
+
15
+ before_script:
16
+ - cp spec/data/.gooddata ~/
17
+
18
+ script: rake $TEST_SUITE
data/.yardopts CHANGED
@@ -1,5 +1,6 @@
1
1
  --template-path doc/templates
2
2
  --plugin rspec
3
+ --template default
3
4
  --protected
4
5
  --no-private
5
6
  --verbose
@@ -11,6 +12,7 @@
11
12
  --readme doc/pages/HOMEPAGE.md
12
13
  --hide-void-return
13
14
  --exclude LICENSE
15
+ --no-cache
14
16
  --output-dir doc/html
15
17
  lib/**/*.rb
16
18
  ext/**/*{.m,.c}
data/README.md CHANGED
@@ -5,7 +5,7 @@ It has a CLI client and it is a library which you can integrate into your applic
5
5
 
6
6
  The best documentation for the GoodData API can be found using these resources:
7
7
 
8
- * sdk.gooddata.com/gooddata-ruby/
8
+ * http://sdk.gooddata.com/gooddata-ruby/
9
9
  * http://docs.gooddata.apiary.io/
10
10
  * http://developer.gooddata.com/api
11
11
  * https://secure.gooddata.com/gdc
@@ -15,7 +15,10 @@ The best documentation for the GoodData API can be found using these resources:
15
15
  [![Gem Version](https://badge.fury.io/rb/gooddata.png)](http://badge.fury.io/rb/gooddata)
16
16
  [![Dependency Status](https://gemnasium.com/gooddata/gooddata-ruby.png)](https://gemnasium.com/gooddata/gooddata-ruby)
17
17
  [![Code Climate](https://codeclimate.com/github/gooddata/gooddata-ruby.png)](https://codeclimate.com/github/gooddata/gooddata-ruby)
18
- [![Build Status](https://travis-ci.org/korczis/gooddata-ruby.png?branch=refactor)](https://travis-ci.org/korczis/gooddata-ruby)
18
+ [![Build Status](https://travis-ci.org/gooddata/gooddata-ruby.png)](https://travis-ci.org/gooddata/gooddata-ruby)
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
+
19
22
 
20
23
  ## Install
21
24
 
@@ -51,4 +54,4 @@ Special thanks to Thomas Watson Steen [ <mailto:w@tson.dk> / [@wa7son](http://tw
51
54
 
52
55
  ## Copyright
53
56
 
54
- Copyright (c) 2010 - 2014 GoodData Corporation and Thomas Watson Steen. See LICENSE for details.
57
+ Copyright (c) 2010 - 2014 GoodData Corporation and Thomas Watson Steen. See LICENSE for details.
data/Rakefile CHANGED
@@ -3,15 +3,29 @@ require 'rubygems'
3
3
  require 'bundler/setup'
4
4
  require 'bundler/gem_tasks'
5
5
 
6
+ require 'coveralls/rake/task'
7
+
6
8
  require 'rake/testtask'
7
9
  require 'rspec/core/rake_task'
8
10
 
9
11
  require 'yard'
10
12
 
11
- task :usage do
12
- puts "No rake task specified, use rake -T to list them"
13
+ desc "Run Rubocop"
14
+ task :cop do
15
+ exec "rubocop lib/"
16
+ end
17
+
18
+ Coveralls::RakeTask.new
19
+
20
+ desc "Create rspec coverage"
21
+ task :coverage do
22
+ ENV['COVERAGE'] = 'true'
23
+ Rake::Task["test:unit"].execute
13
24
  end
14
25
 
26
+ desc 'Run tests with coveralls'
27
+ task :coveralls => ['coverage', 'coveralls:push']
28
+
15
29
  RSpec::Core::RakeTask.new(:test)
16
30
 
17
31
  namespace :test do
@@ -25,11 +39,10 @@ namespace :test do
25
39
  t.pattern = 'spec/integration/**/*.rb'
26
40
  end
27
41
 
28
- # Rake::TestTask.new(:legacy) do |test|
29
- # test.libs << 'lib' << 'test'
30
- # test.pattern = 'test/**/test_*.rb'
31
- # test.verbose = true
32
- # end
42
+ desc "Run legacy tests"
43
+ RSpec::Core::RakeTask.new(:legacy) do |t|
44
+ t.pattern = 'test/**/test_*.rb'
45
+ end
33
46
 
34
47
  task :all => [:unit, :integration]
35
48
  end
@@ -37,6 +50,10 @@ end
37
50
  desc "Run all tests"
38
51
  task :test => 'test:all'
39
52
 
53
+ task :usage do
54
+ puts "No rake task specified, use rake -T to list them"
55
+ end
56
+
40
57
  YARD::Rake::YardocTask.new
41
58
 
42
59
  task :default => [:usage]
data/gooddata CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.join(File.dirname(__FILE__), "lib/gooddata/cli/cli")
3
+ require_relative "lib/gooddata/cli/cli"
4
4
 
5
5
  res = GoodData::CLI.main(ARGV)
6
6
 
7
- exit(res)
7
+ exit(res)
data/gooddata.gemspec CHANGED
@@ -27,21 +27,22 @@ Gem::Specification.new do |s|
27
27
  s.require_paths = ["lib"]
28
28
  s.rubygems_version = "1.3.7"
29
29
 
30
- s.add_development_dependency "rake", "~> 10.1.1"
30
+ s.add_development_dependency "rake", "~> 10.2.2"
31
31
  s.add_development_dependency "redcarpet", "~> 3.1.1"
32
32
  s.add_development_dependency "rspec", "~> 2.14.1"
33
+ s.add_development_dependency "rubocop", "~> 0.20.0"
33
34
  s.add_development_dependency "simplecov", "~> 0.8.2"
34
35
  s.add_development_dependency "yard", "~> 0.8.7.3"
35
36
  s.add_development_dependency "yard-rspec", "~> 0.1"
36
37
  s.add_development_dependency "ZenTest", "~> 4.9.5"
38
+ s.add_development_dependency "coveralls", "~> 0.7.0"
37
39
 
38
40
  s.add_dependency "activesupport", "~> 4.0.3"
39
- s.add_dependency "bundler", "~> 1.5.3"
41
+ s.add_dependency "bundler", ">= 1.6.1"
40
42
  s.add_dependency "erubis", "~> 2.7.0"
41
43
  s.add_dependency "gli", "~> 2.9.0"
42
44
  s.add_dependency "highline", "~> 1.6.21"
43
45
  s.add_dependency "i18n", "~> 0.6.9"
44
- s.add_dependency "json", "~> 1.8.1"
45
46
  s.add_dependency "json_pure", "~> 1.8.1"
46
47
  s.add_dependency "multi_json", "~> 1.9.0"
47
48
  s.add_dependency "parseconfig", "~> 1.0.4"
data/lib/gooddata.rb CHANGED
@@ -1,18 +1,23 @@
1
- module GoodData; end
1
+ # encoding: UTF-8
2
+
3
+ # GoodData Module
4
+ module GoodData
5
+ end
2
6
 
3
7
  require 'active_support/all'
4
8
 
5
9
  # Modules
6
- require File.join(File.dirname(__FILE__), 'gooddata/bricks/bricks')
7
- require File.join(File.dirname(__FILE__), 'gooddata/cli/cli')
8
- require File.join(File.dirname(__FILE__), 'gooddata/commands/commands')
9
- require File.join(File.dirname(__FILE__), 'gooddata/core/core')
10
- require File.join(File.dirname(__FILE__), 'gooddata/models/models')
10
+ require_relative 'gooddata/bricks/bricks'
11
+ require_relative 'gooddata/cli/cli'
12
+ require_relative 'gooddata/commands/commands'
13
+ require_relative 'gooddata/core/core'
14
+ require_relative 'gooddata/data/data'
15
+ require_relative 'gooddata/exceptions/exceptions'
16
+ require_relative 'gooddata/models/models'
11
17
 
12
18
  # Files
13
- require File.join(File.dirname(__FILE__), 'gooddata/client')
14
- require File.join(File.dirname(__FILE__), 'gooddata/connection')
15
- require File.join(File.dirname(__FILE__), 'gooddata/exceptions')
16
- require File.join(File.dirname(__FILE__), 'gooddata/extract')
17
- require File.join(File.dirname(__FILE__), 'gooddata/helpers')
18
- require File.join(File.dirname(__FILE__), 'gooddata/version')
19
+ require_relative 'gooddata/client'
20
+ require_relative 'gooddata/connection'
21
+ require_relative 'gooddata/extract'
22
+ require_relative 'gooddata/helpers'
23
+ require_relative 'gooddata/version'
@@ -1,6 +1,7 @@
1
+ # encoding: UTF-8
2
+
1
3
  module GoodData::Bricks
2
4
  class BaseDownloader
3
-
4
5
  def initialize(params)
5
6
  @params = params
6
7
  end
@@ -10,12 +11,12 @@ module GoodData::Bricks
10
11
  end
11
12
 
12
13
  def download
13
- puts "would download data"
14
+ puts 'would download data'
14
15
  []
15
16
  end
16
17
 
17
18
  def backup(meta)
18
- puts "would send a backup list of files to backup"
19
+ puts 'would send a backup list of files to backup'
19
20
  files = meta.reduce([]) do |memo, item|
20
21
  memo << item[:filename]
21
22
  end
@@ -37,7 +38,7 @@ module GoodData::Bricks
37
38
  end
38
39
 
39
40
  def post_process(meta)
40
- puts "Maybe some postprocessing"
41
+ puts 'Maybe some postprocessing'
41
42
  meta
42
43
  end
43
44
 
@@ -47,17 +48,16 @@ module GoodData::Bricks
47
48
  downloaded_data = pre_process(downloaded_data)
48
49
  backup(downloaded_data)
49
50
  downloaded_data = post_process(downloaded_data)
50
-
51
+
51
52
  downloaded_data.reduce([]) do |memo, item|
52
53
  item.has_key?(:state) ? memo.concat(item[:state]) : memo
53
54
  end.each do |item|
54
55
  key = item[:key]
55
56
  val = item[:value]
56
57
 
57
- puts "Saving metadata #{}"
58
+ puts "Saving metadata #{key} => #{val}"
58
59
  GoodData::ProjectMetadata[key] = val
59
60
  end
60
61
  end
61
-
62
62
  end
63
63
  end
@@ -1,11 +1,13 @@
1
- require File.join(File.dirname(__FILE__), 'base_downloader')
2
- require File.join(File.dirname(__FILE__), 'utils')
1
+ # encoding: UTF-8
2
+
3
+ require_relative 'base_downloader'
4
+ require_relative 'utils'
3
5
 
4
6
  Dir[File.dirname(__FILE__) + '/commands/**/*_cmd.rb'].each do |file|
5
7
  require file
6
8
  end
7
9
 
8
- require File.join(File.dirname(__FILE__), 'middleware/middleware')
10
+ require_relative 'middleware/middleware'
9
11
 
10
12
  module GoodData::Bricks
11
13
  class Pipeline
@@ -22,7 +24,6 @@ module GoodData::Bricks
22
24
 
23
25
  # Brick base class
24
26
  class Brick
25
-
26
27
  def log(message)
27
28
  logger = @params[:gdc_logger]
28
29
  logger.info(message) unless logger.nil?
@@ -33,14 +34,12 @@ module GoodData::Bricks
33
34
  end
34
35
 
35
36
  def version
36
- fail "Method version should be reimplemented"
37
+ fail 'Method version should be reimplemented'
37
38
  end
38
39
 
39
40
  def call(params={})
40
41
  @params = params
41
- ""
42
+ ''
42
43
  end
43
-
44
44
  end
45
-
46
45
  end
@@ -1,7 +1,10 @@
1
+ # encoding: UTF-8
2
+ require 'pathname'
3
+
1
4
  base = Pathname(__FILE__).dirname.expand_path
2
5
  Dir.glob(base + '*.rb').each do |file|
3
6
  require file
4
7
  end
5
8
 
6
9
  # Require all middleware
7
- require File.join(File.dirname(__FILE__), "middleware/middleware")
10
+ require_relative 'middleware/middleware'
@@ -1,5 +1,6 @@
1
- module GoodData::Bricks
1
+ # encoding: UTF-8
2
2
 
3
+ module GoodData::Bricks
3
4
  class Middleware
4
5
  attr_accessor :app
5
6
 
@@ -8,6 +9,5 @@ module GoodData::Bricks
8
9
  def initialize(options={})
9
10
  @app = options[:app]
10
11
  end
11
-
12
12
  end
13
13
  end
@@ -1,18 +1,17 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'benchmark'
2
- require File.join(File.dirname(__FILE__), "base_middleware")
4
+ require_relative 'base_middleware'
3
5
 
4
6
  module GoodData::Bricks
5
-
6
7
  class BenchMiddleware < GoodData::Bricks::Middleware
7
-
8
8
  def call(params)
9
- puts "Starting timer"
9
+ puts 'Starting timer'
10
10
  result = nil
11
11
  report = Benchmark.measure { result = @app.call(params) }
12
- puts "Stopping timer"
12
+ puts 'Stopping timer'
13
13
  pp report
14
14
  result
15
15
  end
16
-
17
16
  end
18
17
  end
@@ -1,39 +1,38 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'salesforce_bulk'
2
4
 
3
- require File.join(File.dirname(__FILE__), "base_middleware")
5
+ require_relative 'base_middleware'
4
6
 
5
7
  module GoodData::Bricks
6
8
  class BulkSalesforceMiddleware < GoodData::Bricks::Middleware
7
-
8
9
  def call(params)
9
-
10
- username = params[:salesforce_username]
11
- password = params[:salesforce_password]
12
- token = params[:salesforce_token]
13
- client_id = params[:salesforce_client_id]
10
+ username = params[:salesforce_username]
11
+ password = params[:salesforce_password]
12
+ token = params[:salesforce_token]
13
+ client_id = params[:salesforce_client_id]
14
14
  client_secret = params[:salesforce_client_secret]
15
- host = params[:salesforce_host]
15
+ host = params[:salesforce_host]
16
16
 
17
17
  credentials = {}
18
18
 
19
19
  credentials = if (username && password && token)
20
- {
21
- :username => username,
22
- :password => password,
23
- :security_token => token
24
- }
25
- end
20
+ {
21
+ :username => username,
22
+ :password => password,
23
+ :security_token => token
24
+ }
25
+ end
26
26
 
27
27
  client = if credentials
28
- credentials.merge!({
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
28
+ credentials.merge!({
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
35
  @app.call(params.merge(:salesforce_bulk_client => client))
36
36
  end
37
-
38
37
  end
39
38
  end
@@ -2,10 +2,10 @@ require 'uri'
2
2
  require 'net/http'
3
3
  require 'pathname'
4
4
 
5
- module GoodData::Bricks
5
+ require_relative 'base_middleware'
6
6
 
7
+ module GoodData::Bricks
7
8
  class FsUploadMiddleware < GoodData::Bricks::Middleware
8
-
9
9
  def initialize(options={})
10
10
  super
11
11
  @destination = options[:destination]
@@ -25,6 +25,5 @@ module GoodData::Bricks
25
25
  end
26
26
  end
27
27
  end
28
-
29
28
  end
30
- end
29
+ end
@@ -1,31 +1,31 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'gooddata'
2
4
 
3
- require File.join(File.dirname(__FILE__), "base_middleware")
5
+ require_relative 'base_middleware'
4
6
 
5
7
  module GoodData::Bricks
6
8
  class GoodDataMiddleware < GoodData::Bricks::Middleware
7
-
8
9
  def call(params)
9
- logger = params["GDC_LOGGER"]
10
- token_name = "GDC_SST"
11
- protocol_name = "GDC_PROTOCOL"
12
- server_name = "GDC_HOSTNAME"
13
- project_id = params["GDC_PROJECT_ID"]
10
+ logger = params['GDC_LOGGER']
11
+ token_name = 'GDC_SST'
12
+ protocol_name = 'GDC_PROTOCOL'
13
+ server_name = 'GDC_HOSTNAME'
14
+ project_id = params['GDC_PROJECT_ID']
14
15
 
15
- fail "SST (SuperSecureToken) not present in params" if params[token_name].nil?
16
+ fail 'SST (SuperSecureToken) not present in params' if params[token_name].nil?
16
17
  server = if !params[protocol_name].empty? && !params[server_name].empty?
17
- params[protocol_name] + "://" + params[server_name]
18
- end
18
+ "#{params[protocol_name]}://#{params[server_name]}"
19
+ end
19
20
 
20
- fail "GoodData username is missing. Expected param \"GDC_USERNAME\"" if params["GDC_USERNAME"].nil?
21
- fail "GoodData password is missing. Expected param \"GDC_PASSWORD\"" if params["GDC_PASSWORD"].nil?
21
+ fail 'GoodData username is missing. Expected param :GDC_USERNAME' if params['GDC_USERNAME'].nil?
22
+ fail 'GoodData password is missing. Expected param :GDC_PASSWORD' if params['GDC_PASSWORD'].nil?
22
23
 
23
- GoodData.connect(params["GDC_USERNAME"], params["GDC_PASSWORD"], {:server => server})
24
+ GoodData.connect(params['GDC_USERNAME'], params['GDC_PASSWORD'], {:server => server})
24
25
  GoodData.logger = logger
25
26
  GoodData.with_project(project_id) do |p|
26
27
  @app.call(params)
27
28
  end
28
29
  end
29
-
30
30
  end
31
31
  end