gooddata 0.6.18 → 0.6.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +8 -19
  4. data/Guardfile +5 -0
  5. data/README.md +1 -3
  6. data/bin/gooddata +1 -1
  7. data/gooddata.gemspec +6 -4
  8. data/lib/gooddata.rb +1 -1
  9. data/lib/gooddata/bricks/middleware/aws_middleware.rb +24 -0
  10. data/lib/gooddata/cli/commands/console_cmd.rb +1 -1
  11. data/lib/gooddata/cli/commands/project_cmd.rb +29 -9
  12. data/lib/gooddata/cli/hooks.rb +9 -3
  13. data/lib/gooddata/commands/datawarehouse.rb +1 -7
  14. data/lib/gooddata/commands/project.rb +4 -3
  15. data/lib/gooddata/core/logging.rb +14 -2
  16. data/lib/gooddata/exceptions/execution_limit_exceeded.rb +9 -0
  17. data/lib/gooddata/exceptions/uncomputable_report.rb +8 -0
  18. data/lib/gooddata/exceptions/validation_error.rb +1 -1
  19. data/lib/gooddata/goodzilla/goodzilla.rb +5 -1
  20. data/lib/gooddata/helpers/data_helper.rb +40 -9
  21. data/lib/gooddata/mixins/md_finders.rb +35 -0
  22. data/lib/gooddata/models/blueprint/anchor_field.rb +46 -0
  23. data/lib/gooddata/models/blueprint/attribute_field.rb +25 -0
  24. data/lib/gooddata/models/blueprint/blueprint.rb +7 -0
  25. data/lib/gooddata/models/blueprint/blueprint_field.rb +66 -0
  26. data/lib/gooddata/models/{dashboard_builder.rb → blueprint/dashboard_builder.rb} +0 -0
  27. data/lib/gooddata/models/{schema_blueprint.rb → blueprint/dataset_blueprint.rb} +176 -117
  28. data/lib/gooddata/models/blueprint/date_dimension.rb +10 -0
  29. data/lib/gooddata/models/blueprint/fact_field.rb +16 -0
  30. data/lib/gooddata/models/blueprint/label_field.rb +39 -0
  31. data/lib/gooddata/models/{project_blueprint.rb → blueprint/project_blueprint.rb} +366 -168
  32. data/lib/gooddata/models/blueprint/project_builder.rb +79 -0
  33. data/lib/gooddata/models/blueprint/reference_field.rb +39 -0
  34. data/lib/gooddata/models/blueprint/schema_blueprint.rb +156 -0
  35. data/lib/gooddata/models/blueprint/schema_builder.rb +85 -0
  36. data/lib/gooddata/models/{to_manifest.rb → blueprint/to_manifest.rb} +25 -20
  37. data/lib/gooddata/models/{to_wire.rb → blueprint/to_wire.rb} +33 -52
  38. data/lib/gooddata/models/datawarehouse.rb +2 -2
  39. data/lib/gooddata/models/domain.rb +3 -2
  40. data/lib/gooddata/models/execution.rb +2 -2
  41. data/lib/gooddata/models/execution_detail.rb +7 -2
  42. data/lib/gooddata/models/from_wire.rb +60 -71
  43. data/lib/gooddata/models/from_wire_parse.rb +125 -125
  44. data/lib/gooddata/models/metadata.rb +14 -0
  45. data/lib/gooddata/models/metadata/dashboard.rb +2 -2
  46. data/lib/gooddata/models/metadata/label.rb +1 -1
  47. data/lib/gooddata/models/metadata/report.rb +6 -5
  48. data/lib/gooddata/models/metadata/report_definition.rb +44 -59
  49. data/lib/gooddata/models/model.rb +131 -43
  50. data/lib/gooddata/models/process.rb +13 -11
  51. data/lib/gooddata/models/profile.rb +12 -1
  52. data/lib/gooddata/models/project.rb +223 -19
  53. data/lib/gooddata/models/project_creator.rb +4 -15
  54. data/lib/gooddata/models/schedule.rb +1 -0
  55. data/lib/gooddata/models/user_filters/user_filter_builder.rb +2 -2
  56. data/lib/gooddata/rest/client.rb +18 -18
  57. data/lib/gooddata/rest/connection.rb +113 -94
  58. data/lib/gooddata/version.rb +1 -1
  59. data/lib/templates/project/model/model.rb.erb +15 -16
  60. data/spec/data/blueprints/additional_dataset_module.json +32 -0
  61. data/spec/data/blueprints/big_blueprint_not_pruned.json +2079 -0
  62. data/spec/data/blueprints/invalid_blueprint.json +103 -0
  63. data/spec/data/blueprints/m_n_model.json +104 -0
  64. data/spec/data/blueprints/model_module.json +25 -0
  65. data/spec/data/blueprints/test_blueprint.json +38 -0
  66. data/spec/data/blueprints/test_project_model_spec.json +106 -0
  67. data/spec/data/gd_gse_data_manifest.json +34 -34
  68. data/spec/data/manifests/test_blueprint.json +32 -0
  69. data/spec/data/{manifest_test_project.json → manifests/test_project.json} +9 -18
  70. data/spec/data/wire_models/test_blueprint.json +63 -0
  71. data/spec/data/wire_test_project.json +5 -5
  72. data/spec/environment/default.rb +33 -0
  73. data/spec/environment/develop.rb +26 -0
  74. data/spec/environment/environment.rb +14 -0
  75. data/spec/environment/hotfix.rb +17 -0
  76. data/spec/environment/production.rb +31 -0
  77. data/spec/environment/release.rb +17 -0
  78. data/spec/helpers/blueprint_helper.rb +10 -7
  79. data/spec/helpers/cli_helper.rb +24 -22
  80. data/spec/helpers/connection_helper.rb +27 -25
  81. data/spec/helpers/crypto_helper.rb +7 -5
  82. data/spec/helpers/csv_helper.rb +5 -3
  83. data/spec/helpers/process_helper.rb +15 -10
  84. data/spec/helpers/project_helper.rb +40 -33
  85. data/spec/helpers/schedule_helper.rb +15 -9
  86. data/spec/helpers/spec_helper.rb +11 -0
  87. data/spec/integration/blueprint_updates_spec.rb +93 -0
  88. data/spec/integration/command_datawarehouse_spec.rb +2 -1
  89. data/spec/integration/command_projects_spec.rb +9 -8
  90. data/spec/integration/create_from_template_spec.rb +1 -1
  91. data/spec/integration/create_project_spec.rb +1 -1
  92. data/spec/integration/full_process_schedule_spec.rb +1 -1
  93. data/spec/integration/full_project_spec.rb +91 -30
  94. data/spec/integration/over_to_user_filters_spec.rb +24 -28
  95. data/spec/integration/partial_md_export_import_spec.rb +4 -4
  96. data/spec/integration/project_spec.rb +1 -1
  97. data/spec/integration/rest_spec.rb +1 -1
  98. data/spec/integration/user_filters_spec.rb +19 -24
  99. data/spec/integration/variables_spec.rb +7 -9
  100. data/spec/logging_in_logging_out_spec.rb +1 -1
  101. data/spec/spec_helper.rb +10 -1
  102. data/spec/unit/bricks/middleware/aws_middelware_spec.rb +47 -0
  103. data/spec/unit/core/connection_spec.rb +2 -2
  104. data/spec/unit/core/logging_spec.rb +12 -4
  105. data/spec/unit/helpers/data_helper_spec.rb +60 -0
  106. data/spec/unit/models/blueprint/attributes_spec.rb +24 -0
  107. data/spec/unit/models/blueprint/dataset_spec.rb +116 -0
  108. data/spec/unit/models/blueprint/labels_spec.rb +39 -0
  109. data/spec/unit/models/blueprint/project_blueprint_spec.rb +643 -0
  110. data/spec/unit/models/blueprint/reference_spec.rb +24 -0
  111. data/spec/unit/models/{schema_builder_spec.rb → blueprint/schema_builder_spec.rb} +12 -4
  112. data/spec/unit/models/blueprint/to_wire_spec.rb +169 -0
  113. data/spec/unit/models/domain_spec.rb +13 -2
  114. data/spec/unit/models/from_wire_spec.rb +277 -98
  115. data/spec/unit/models/metadata_spec.rb +22 -4
  116. data/spec/unit/models/model_spec.rb +49 -39
  117. data/spec/unit/models/profile_spec.rb +1 -0
  118. data/spec/unit/models/project_spec.rb +7 -7
  119. data/spec/unit/models/schedule_spec.rb +20 -0
  120. data/spec/unit/models/to_manifest_spec.rb +31 -11
  121. data/spec/unit/rest/polling_spec.rb +86 -0
  122. metadata +102 -30
  123. data/lib/gooddata/models/project_builder.rb +0 -136
  124. data/lib/gooddata/models/schema_builder.rb +0 -77
  125. data/out.txt +0 -0
  126. data/spec/data/additional_dataset_module.json +0 -18
  127. data/spec/data/blueprint_invalid.json +0 -38
  128. data/spec/data/m_n_model/blueprint.json +0 -76
  129. data/spec/data/model_module.json +0 -18
  130. data/spec/data/test_project_model_spec.json +0 -76
  131. data/spec/unit/models/attribute_column_spec.rb +0 -7
  132. data/spec/unit/models/project_blueprint_spec.rb +0 -239
  133. data/spec/unit/models/to_wire_spec.rb +0 -71
@@ -1,136 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require_relative 'dashboard_builder'
4
- require_relative 'schema_builder'
5
-
6
- module GoodData
7
- module Model
8
- class ProjectBuilder
9
- attr_reader :title, :datasets, :reports, :metrics, :uploads, :users, :assert_report, :date_dimensions
10
-
11
- class << self
12
- def create_from_data(blueprint, title = 'Title')
13
- pb = ProjectBuilder.new(title)
14
- pb.data = blueprint.to_hash
15
- pb
16
- end
17
-
18
- def create(title, _options = {}, &block)
19
- pb = ProjectBuilder.new(title)
20
- block.call(pb)
21
- pb
22
- end
23
- end
24
-
25
- def initialize(title)
26
- @title = title
27
- @datasets = []
28
- @reports = []
29
- @assert_tests = []
30
- @metrics = []
31
- @uploads = []
32
- @users = []
33
- @dashboards = []
34
- @date_dimensions = []
35
- end
36
-
37
- def add_date_dimension(name, options = {})
38
- dimension = {
39
- urn: options[:urn],
40
- name: name,
41
- title: options[:title]
42
- }
43
-
44
- @date_dimensions << dimension
45
- end
46
-
47
- def add_dataset(name, &block)
48
- builder = GoodData::Model::SchemaBuilder.new(name)
49
- block.call(builder)
50
- if @datasets.any? { |item| item[:name] == name }
51
- ds = @datasets.find { |item| item[:name] == name }
52
- index = @datasets.index(ds)
53
- stuff = GoodData::Model.merge_dataset_columns(ds, builder.to_hash)
54
- @datasets.delete_at(index)
55
- @datasets.insert(index, stuff)
56
- else
57
- @datasets << builder.to_hash
58
- end
59
- end
60
-
61
- def add_report(title, options = {})
62
- @reports << { :title => title }.merge(options)
63
- end
64
-
65
- def add_metric(title, options = {})
66
- @metrics << { :title => title }.merge(options)
67
- end
68
-
69
- def add_dashboard(title, &block)
70
- db = DashboardBuilder.new(title)
71
- block.call(db)
72
- @dashboards << db.to_hash
73
- end
74
-
75
- def load_metrics(file)
76
- new_metrics = MultiJson.load(open(file).read, :symbolize_keys => true)
77
- @metrics += new_metrics
78
- end
79
-
80
- def load_datasets(file)
81
- new_metrics = MultiJson.load(open(file).read, :symbolize_keys => true)
82
- @datasets += new_metrics
83
- end
84
-
85
- def assert_report(report, result)
86
- @assert_tests << { :report => report, :result => result }
87
- end
88
-
89
- def upload(data, options = {})
90
- mode = options[:mode] || 'FULL'
91
- dataset = options[:dataset]
92
- @uploads << {
93
- :source => data,
94
- :mode => mode,
95
- :dataset => dataset
96
- }
97
- end
98
-
99
- def add_users(users)
100
- @users << users
101
- end
102
-
103
- def to_json(options = {})
104
- eliminate_empty = options[:eliminate_empty] || false
105
-
106
- if eliminate_empty
107
- JSON.pretty_generate(to_hash.reject { |_k, v| v.is_a?(Enumerable) && v.empty? })
108
- else
109
- JSON.pretty_generate(to_hash)
110
- end
111
- end
112
-
113
- def to_blueprint
114
- GoodData::Model::ProjectBlueprint.new(to_hash)
115
- end
116
-
117
- def to_hash
118
- {
119
- :title => @title,
120
- :datasets => @datasets,
121
- :uploads => @uploads,
122
- :dashboards => @dashboards,
123
- :metrics => @metrics,
124
- :reports => @reports,
125
- :users => @users,
126
- :assert_tests => @assert_tests,
127
- :date_dimensions => @date_dimensions
128
- }
129
- end
130
-
131
- def find_dataset(name)
132
- datasets.find { |d| d.name == name }
133
- end
134
- end
135
- end
136
- end
@@ -1,77 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module GoodData
4
- module Model
5
- class SchemaBuilder
6
- attr_accessor :data
7
-
8
- class << self
9
- def create_from_data(blueprint)
10
- sc = SchemaBuilder.new
11
- sc.data = blueprint.to_hash
12
- sc
13
- end
14
- end
15
-
16
- def initialize(name = nil)
17
- @data = {
18
- :name => name,
19
- :columns => []
20
- }
21
- end
22
-
23
- def name
24
- data[:name]
25
- end
26
-
27
- def columns
28
- data[:columns]
29
- end
30
-
31
- def add_column(column_def)
32
- columns.push(column_def)
33
- self
34
- end
35
-
36
- def add_anchor(name, options = {})
37
- add_column({ :type => :anchor, :name => name }.merge(options))
38
- self
39
- end
40
-
41
- def add_attribute(name, options = {})
42
- add_column({ :type => :attribute, :name => name }.merge(options))
43
- self
44
- end
45
-
46
- def add_fact(name, options = {})
47
- add_column({ :type => :fact, :name => name }.merge(options))
48
- self
49
- end
50
-
51
- def add_label(name, options = {})
52
- add_column({ :type => :label, :name => name }.merge(options))
53
- self
54
- end
55
-
56
- def add_date(name, options = {})
57
- add_column({ :type => :date, :name => name }.merge(options))
58
- end
59
-
60
- def add_reference(name, options = {})
61
- add_column({ :type => :reference, :name => name }.merge(options))
62
- end
63
-
64
- def to_json
65
- JSON.pretty_generate(to_hash)
66
- end
67
-
68
- def to_hash
69
- data
70
- end
71
-
72
- def to_blueprint
73
- GoodData::Model::DatasetBlueprint.new(to_hash)
74
- end
75
- end
76
- end
77
- end
data/out.txt DELETED
File without changes
@@ -1,18 +0,0 @@
1
- {
2
- "title": "Region module",
3
- "datasets": [
4
- {
5
- "name": "regions",
6
- "columns": [
7
- {
8
- "type": "anchor",
9
- "name": "id"
10
- },
11
- {
12
- "type": "attribute",
13
- "name": "name"
14
- }
15
- ]
16
- }
17
- ]
18
- }
@@ -1,38 +0,0 @@
1
- {
2
- "title": "x",
3
- "datasets": [
4
- {
5
- "name": "payments",
6
- "columns": [
7
- {
8
- "type": "attribute",
9
- "name": "id",
10
- "gd_data_type" : "INT",
11
- "gd_type" : "GDC.text"
12
- },
13
- {
14
- "type": "fact",
15
- "name": "amount"
16
- },
17
- {
18
- "type": "reference",
19
- "name": "user_id",
20
- "dataset": "users",
21
- "reference": "user_id"
22
- }
23
- ]
24
- },
25
- {
26
- "name": "users",
27
- "columns": [
28
- {
29
- "type": "attribute",
30
- "name": "user_id"
31
- },
32
- {
33
- "type": "fact",
34
- "name": "amount"
35
- }
36
- ]
37
- }
38
- ]}
@@ -1,76 +0,0 @@
1
- {
2
- "title": "GD M:N project testing",
3
- "datasets": [
4
- {
5
- "type": "dataset",
6
- "name": "visibility",
7
- "columns": [
8
- {
9
- "type": "anchor",
10
- "name": "visibility_id"
11
- },
12
- {
13
- "type": "reference",
14
- "name": "perm_user_id",
15
- "dataset": "permission_users"
16
- },
17
- {
18
- "type": "reference",
19
- "name": "commit_id",
20
- "dataset": "commits"
21
- }
22
- ]
23
- },
24
- {
25
- "type": "dataset",
26
- "name": "users",
27
- "columns": [
28
- {
29
- "type": "anchor",
30
- "name": "user_id"
31
- },
32
- {
33
- "type": "label",
34
- "name": "email",
35
- "reference": "user_id",
36
- "default_label" : true
37
- }
38
- ]
39
- },
40
- {
41
- "type": "dataset",
42
- "name": "permission_users",
43
- "columns": [
44
- {
45
- "type": "anchor",
46
- "name": "perm_user_id"
47
- },
48
- {
49
- "type": "label",
50
- "name": "email",
51
- "reference": "perm_user_id",
52
- "default_label" : true
53
- }
54
- ]
55
- },
56
- {
57
- "type": "dataset",
58
- "name": "commits",
59
- "columns": [
60
- {
61
- "type": "anchor",
62
- "name": "commit_id"
63
- },
64
- {
65
- "type": "fact",
66
- "name": "lines_changed"
67
- },
68
- {
69
- "type": "reference",
70
- "name": "user_id",
71
- "dataset": "users"
72
- }
73
- ]
74
- }
75
- ]
76
- }
@@ -1,18 +0,0 @@
1
- {
2
- "title": "Devs module",
3
- "datasets": [
4
- {
5
- "name": "devs",
6
- "columns": [
7
- {
8
- "type": "anchor",
9
- "name": "id"
10
- },
11
- {
12
- "type": "attribute",
13
- "name": "region"
14
- }
15
- ]
16
- }
17
- ]
18
- }
@@ -1,76 +0,0 @@
1
- {
2
- "title": "RubyGem Dev Week test",
3
- "datasets": [
4
- {
5
- "type": "dataset",
6
- "name": "repos",
7
- "folder": "Foldered Repos",
8
- "columns": [
9
- {
10
- "type": "anchor",
11
- "name": "repo_id",
12
- "description": "This is anchor description"
13
- },
14
- {
15
- "type": "label",
16
- "name": "name",
17
- "reference": "repo_id"
18
- },
19
- {
20
- "type": "attribute",
21
- "name": "department"
22
- }
23
- ]
24
- },
25
- {
26
- "type": "dataset",
27
- "name": "devs",
28
- "columns": [
29
- {
30
- "type": "anchor",
31
- "name": "dev_id"
32
- },
33
- {
34
- "type": "label",
35
- "name": "email",
36
- "reference": "dev_id",
37
- "default_label" : true
38
- }
39
- ]
40
- },
41
- {
42
- "type": "dataset",
43
- "name": "commits",
44
- "columns": [
45
- {
46
- "type": "fact",
47
- "name": "lines_changed",
48
- "description": "Fact description"
49
- },
50
- {
51
- "type": "date",
52
- "name": "committed_on",
53
- "dataset": "committed_on"
54
- },
55
- {
56
- "type": "reference",
57
- "name": "dev_id",
58
- "dataset": "devs",
59
- "reference": "dev_id"
60
- },
61
- {
62
- "type": "reference",
63
- "name": "repo_id",
64
- "dataset": "repos",
65
- "reference": "repo_id"
66
- }
67
- ]
68
- }
69
- ],
70
- "date_dimensions": [
71
- {
72
- "type": "date_dimension",
73
- "name": "committed_on"
74
- }
75
- ]
76
- }