Sha256: 5cf75ae6980e3b64c51cbb70fd2a8dfa625543a1dd33d546f753642fa30ca43f

Contents?: true

Size: 2 KB

Versions: 19

Compression:

Stored size: 2 KB

Contents

# encoding: UTF-8

# This file shows how the GoodData Ruby API could be used from
# a client code
# 
# Caution: this is far from describing the current functionality!

require 'gooddata'

# Note: this call will store the connection in a thread-local
# variable so this construction and following static method
# calls can be used even in a multi-threaded environment
#
# The connect call is not necessary if credentials are already
# stored in ~/.gooddata (e.g. using bin/gooddata auth:store)

GoodData.connect 'test@example.org', '$3[r37'

# Connect to a specific project
GoodData.project = 'afawtv356b6usdfsdf34vt'

# ... or even during login time
GoodData.connect 'test@example.org', '$3[r37', 'afawtv356b6usdfsdf34vt'

# Get a metadata object
a = Attribute[123]
a = Attribute['attr.country']

# Guess a model from a CSV data set
Model.guess 'data.csv'
# > [ { "type" => "ATTRIBUTE", "title" => "Country" }, ... ]

Model.add_dataset "title" => "Test", "columns" => [
  { "type" => "ATTRIBUTE",  "title" => "Country" }
]
# > Dataset<"dataset.test">

# Populate a data set from a file
Dataset['dataset.test'].load 'data.csv'

# The previous line is actually a short cut for the following call:
p1.datasets['dataset.test'].load GoodData::Source::CsvFile.new 'data.csv'

# Populate a data set from the result of a SalesForce query
Dataset['dataset.test'].load GoodData::Source::SalesForce.new({
  :username => "test@example.org",
  :password => "blahblah",
  :key => "mkjlnlkh845n4lhasdsdagddddddfa",
  :query => "SELECT Id, Name FROM Account"
})

# Get a representation of a specific project
p1 = Project['afawtv356b6usdfsdf34vt']
p2 = Project['/gdc/projects/afawtv356b6usdfsdf34vt']

# Get a specific object by id from a specific project
a = p1.objects[123]
# > Attribute<"attr.country">

# ... or by identifier
a = p1.objects['attr.country']
# > Attribute<"attr.country">

##
# Create a data set from a model
p1.model.add_dataset "title" => "Test", "columns" => [
  { "type" => "ATTRIBUTE",  "title" => "Country" }
]
# > Dataset<"dataset.test">

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gooddata-0.6.20 examples.rb
gooddata-0.6.19 examples.rb
gooddata-0.6.18 examples.rb
gooddata-0.6.17 examples.rb
gooddata-0.6.16 examples.rb
gooddata-0.6.15 examples.rb
gooddata-0.6.14 examples.rb
gooddata-0.6.13 examples.rb
gooddata-0.6.12 examples.rb
gooddata-0.6.11 examples.rb
gooddata-0.6.10 examples.rb
gooddata-0.6.9 examples.rb
gooddata-0.6.8 examples.rb
gooddata-0.6.7 examples.rb
gooddata-0.6.6 examples.rb
gooddata-0.6.5 examples.rb
gooddata-0.6.4 examples.rb
gooddata-0.6.3 examples.rb
gooddata-0.6.2 examples.rb