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
@@ -0,0 +1,158 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative 'schema_builder'
|
4
|
+
|
5
|
+
module GoodData
|
6
|
+
module Model
|
7
|
+
class DatasetBlueprint
|
8
|
+
attr_accessor :data
|
9
|
+
|
10
|
+
def change(&block)
|
11
|
+
builder = SchemaBuilder.create_from_data(self)
|
12
|
+
block.call(builder)
|
13
|
+
@data = builder.to_hash
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(init_data)
|
18
|
+
@data = init_data
|
19
|
+
end
|
20
|
+
|
21
|
+
def upload(source, options = {})
|
22
|
+
project = options[:project] || GoodData.project
|
23
|
+
fail 'You have to specify a project into which you want to load.' if project.nil?
|
24
|
+
mode = options[:load] || 'FULL'
|
25
|
+
project.upload(source, to_schema, mode)
|
26
|
+
end
|
27
|
+
|
28
|
+
def merge!(a_blueprint)
|
29
|
+
new_blueprint = GoodData::Model.merge_dataset_columns(self, a_blueprint)
|
30
|
+
@data = new_blueprint
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
data[:name]
|
36
|
+
end
|
37
|
+
|
38
|
+
def title
|
39
|
+
data[:title] || name.titleize
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_hash
|
43
|
+
data
|
44
|
+
end
|
45
|
+
|
46
|
+
def columns
|
47
|
+
data[:columns]
|
48
|
+
end
|
49
|
+
|
50
|
+
def anchor?
|
51
|
+
columns.any? { |c| c[:type].to_s == 'anchor' }
|
52
|
+
end
|
53
|
+
|
54
|
+
def anchor
|
55
|
+
find_column_by_type(:anchor, :first)
|
56
|
+
end
|
57
|
+
|
58
|
+
def references
|
59
|
+
find_column_by_type(:reference)
|
60
|
+
end
|
61
|
+
|
62
|
+
def attributes
|
63
|
+
find_column_by_type(:attribute)
|
64
|
+
end
|
65
|
+
|
66
|
+
def facts
|
67
|
+
find_column_by_type(:fact)
|
68
|
+
end
|
69
|
+
|
70
|
+
def labels
|
71
|
+
find_column_by_type(:label)
|
72
|
+
end
|
73
|
+
|
74
|
+
def attributes_and_anchors
|
75
|
+
anchor? ? attributes + [anchor] : attributes
|
76
|
+
end
|
77
|
+
|
78
|
+
def find_column_by_type(type, all = :all)
|
79
|
+
type = type.to_s
|
80
|
+
if all == :all
|
81
|
+
columns.select { |c| c[:type].to_s == type }
|
82
|
+
else
|
83
|
+
columns.find { |c| c[:type].to_s == type }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def find_column_by_name(type, all = :all)
|
88
|
+
type = type.to_s
|
89
|
+
if all == :all
|
90
|
+
columns.select { |c| c[:name].to_s == type }
|
91
|
+
else
|
92
|
+
columns.find { |c| c[:name].to_s == type }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def suggest_metrics
|
97
|
+
identifiers = facts.map { |f| identifier_for(f) }
|
98
|
+
identifiers.zip(facts).map do |id, fact|
|
99
|
+
Metric.xcreate(
|
100
|
+
:title => fact[:name].titleize,
|
101
|
+
:expression => "SELECT SUM(![#{id}])")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def to_schema
|
106
|
+
Schema.new(to_hash)
|
107
|
+
end
|
108
|
+
|
109
|
+
def to_manifest
|
110
|
+
to_schema.to_manifest
|
111
|
+
end
|
112
|
+
|
113
|
+
def pretty_print(printer)
|
114
|
+
printer.text "Schema <#{object_id}>:\n"
|
115
|
+
printer.text " Name: #{name}\n"
|
116
|
+
printer.text " Columns: \n"
|
117
|
+
printer.text columns.map do |c|
|
118
|
+
" #{c[:name]}: #{c[:type]}"
|
119
|
+
end.join("\n")
|
120
|
+
end
|
121
|
+
|
122
|
+
def dup
|
123
|
+
deep_copy = Marshal.load(Marshal.dump(data))
|
124
|
+
DatasetBlueprint.new(deep_copy)
|
125
|
+
end
|
126
|
+
|
127
|
+
def to_wire_model
|
128
|
+
to_schema.to_wire_model
|
129
|
+
end
|
130
|
+
|
131
|
+
def ==(other)
|
132
|
+
to_hash == other.to_hash
|
133
|
+
end
|
134
|
+
|
135
|
+
def eql?(other)
|
136
|
+
to_hash == other.to_hash
|
137
|
+
end
|
138
|
+
|
139
|
+
def identifier_for(column)
|
140
|
+
column = find_column_by_name(column) if column.is_a?(String)
|
141
|
+
case column[:type].to_sym
|
142
|
+
when :attribute
|
143
|
+
"attr.#{name}.#{column[:name]}"
|
144
|
+
when :anchor
|
145
|
+
"attr.#{name}.#{column[:name]}"
|
146
|
+
when :fact
|
147
|
+
"fact.#{name}.#{column[:name]}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def validate_label_references
|
152
|
+
labels.select do |label|
|
153
|
+
find_column_by_name(label[:reference]).empty?
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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
|
+
|
76
|
+
def to_schema
|
77
|
+
Schema.new(to_hash)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module GoodData
|
4
|
+
module Model
|
5
|
+
class TabBuilder
|
6
|
+
def initialize(title)
|
7
|
+
@title = title
|
8
|
+
@stuff = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_report(options = {})
|
12
|
+
@stuff << { :type => :report }.merge(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_hash
|
16
|
+
{
|
17
|
+
:title => @title,
|
18
|
+
:items => @stuff
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative 'project'
|
4
|
+
require_relative 'project_role'
|
5
|
+
|
6
|
+
module GoodData
|
7
|
+
class User
|
8
|
+
attr_reader :json
|
9
|
+
|
10
|
+
def initialize(json)
|
11
|
+
@json = json
|
12
|
+
end
|
13
|
+
|
14
|
+
# Gets author (person who created) of this object
|
15
|
+
#
|
16
|
+
# @return [String] Author
|
17
|
+
def author
|
18
|
+
# TODO: Return object instead
|
19
|
+
@json['user']['meta']['author']
|
20
|
+
end
|
21
|
+
|
22
|
+
# Gets the contributor
|
23
|
+
#
|
24
|
+
# @return [String] Contributor
|
25
|
+
def contributor
|
26
|
+
# TODO: Return object instead
|
27
|
+
@json['user']['meta']['contributor']
|
28
|
+
end
|
29
|
+
|
30
|
+
# Gets date when created
|
31
|
+
#
|
32
|
+
# @return [DateTime] Created date
|
33
|
+
def created
|
34
|
+
Time.parse(@json['user']['meta']['created'])
|
35
|
+
end
|
36
|
+
|
37
|
+
# Gets the email
|
38
|
+
#
|
39
|
+
# @return [String] Email address
|
40
|
+
def email
|
41
|
+
@json['user']['content']['email'] || ''
|
42
|
+
end
|
43
|
+
|
44
|
+
# Gets the first name
|
45
|
+
#
|
46
|
+
# @return [String] First name
|
47
|
+
def first_name
|
48
|
+
@json['user']['content']['firstname'] || ''
|
49
|
+
end
|
50
|
+
|
51
|
+
# Gets the invitations
|
52
|
+
#
|
53
|
+
# @return [Array<GoodData::Invitation>] List of invitations
|
54
|
+
def invitations
|
55
|
+
res = []
|
56
|
+
|
57
|
+
tmp = GoodData.get @json['user']['links']['invitations']
|
58
|
+
tmp['invitations'].each do |invitation|
|
59
|
+
end
|
60
|
+
|
61
|
+
res
|
62
|
+
end
|
63
|
+
|
64
|
+
# Gets the last name
|
65
|
+
#
|
66
|
+
# @return [String] Last name
|
67
|
+
def last_name
|
68
|
+
@json['user']['content']['lastname'] || ''
|
69
|
+
end
|
70
|
+
|
71
|
+
# Gets the login
|
72
|
+
#
|
73
|
+
# @return [String] Login
|
74
|
+
def login
|
75
|
+
@json['user']['content']['login'] || ''
|
76
|
+
end
|
77
|
+
|
78
|
+
# Gets user raw object ID
|
79
|
+
#
|
80
|
+
# @return [String] Raw Object ID
|
81
|
+
def obj_id
|
82
|
+
uri.split('/').last
|
83
|
+
end
|
84
|
+
|
85
|
+
# Gets the permissions
|
86
|
+
#
|
87
|
+
# @return [Hash] Hash with permissions
|
88
|
+
def permissions
|
89
|
+
res = {}
|
90
|
+
|
91
|
+
tmp = GoodData.get @json['user']['links']['permissions']
|
92
|
+
tmp['associatedPermissions']['permissions'].each do |permission_name, permission_value|
|
93
|
+
res[permission_name] = permission_value
|
94
|
+
end
|
95
|
+
|
96
|
+
res
|
97
|
+
end
|
98
|
+
|
99
|
+
# Gets the phone number
|
100
|
+
#
|
101
|
+
# @return [String] Phone number
|
102
|
+
def phone
|
103
|
+
@json['user']['content']['phonenumber'] || ''
|
104
|
+
end
|
105
|
+
|
106
|
+
# Gets the projects of user
|
107
|
+
#
|
108
|
+
# @return [Array<GoodData::Project>] Array of projets
|
109
|
+
def projects
|
110
|
+
res = []
|
111
|
+
|
112
|
+
tmp = GoodData.get @json['user']['links']['projects']
|
113
|
+
tmp['projects'].each do |project_meta|
|
114
|
+
project_uri = project_meta['project']['links']['self']
|
115
|
+
project = GoodData.get project_uri
|
116
|
+
res << GoodData::Project.new(project)
|
117
|
+
end
|
118
|
+
|
119
|
+
res
|
120
|
+
end
|
121
|
+
|
122
|
+
# Gets the project roles of user
|
123
|
+
#
|
124
|
+
# @return [Array<GoodData::ProjectRole>] Array of project roles
|
125
|
+
def roles
|
126
|
+
res = []
|
127
|
+
|
128
|
+
tmp = GoodData.get @json['user']['links']['roles']
|
129
|
+
tmp['associatedRoles']['roles'].each do |role_uri|
|
130
|
+
role = GoodData.get role_uri
|
131
|
+
res << GoodData::ProjectRole.new(role)
|
132
|
+
end
|
133
|
+
|
134
|
+
res
|
135
|
+
end
|
136
|
+
|
137
|
+
# Gets the status
|
138
|
+
#
|
139
|
+
# @return [String] Status
|
140
|
+
def status
|
141
|
+
@json['user']['content']['status'] || ''
|
142
|
+
end
|
143
|
+
|
144
|
+
# Gets the title
|
145
|
+
#
|
146
|
+
# @return [String] User title
|
147
|
+
def title
|
148
|
+
@json['user']['meta']['title'] || ''
|
149
|
+
end
|
150
|
+
|
151
|
+
# Gets the date when updated
|
152
|
+
#
|
153
|
+
# @return [DateTime] Date of last update
|
154
|
+
def updated
|
155
|
+
DateTime.parse(@json['user']['meta']['updated'])
|
156
|
+
end
|
157
|
+
|
158
|
+
# Gets the object URI
|
159
|
+
#
|
160
|
+
# @return [String] Object URI
|
161
|
+
def uri
|
162
|
+
@json['user']['links']['self']
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
data/lib/gooddata/version.rb
CHANGED