Method: GoodData::Process.deploy_simple_process

Defined in:
lib/gooddata/models/process.rb

.deploy_simple_process(path, options = { client: GoodData.client, project: GoodData.project }) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/gooddata/models/process.rb', line 105

def deploy_simple_process(path, options = { client: GoodData.client, project: GoodData.project })
  client, project = GoodData.get_client_and_project(options)

  fail 'Path is not specified' unless path

  path = Pathname(path) || fail('Path is not a valid pathname')
  files_to_exclude = options[:files_to_exclude].nil? ? [] : options[:files_to_exclude].map { |pname| Pathname(pname) }

  type = options[:type] || 'GRAPH'
  deploy_name = options[:name] || "Process of #{path} script"
  fail ArgumentError, 'options[:name] can not be nil or empty!' if deploy_name.nil? || deploy_name.empty?

  verbose = options[:verbose] || false
  GoodData.logger.info("Deploying #{path}") if verbose

  deployed_path = Process.upload_package(path, files_to_exclude, client: client, project: project)
  data_sources = options[:data_sources] || []
  data = {
    :process => {
      :name => deploy_name,
      :path => "/uploads/#{File.basename(deployed_path)}",
      :type => type,
      :dataSources => data_sources
    }
  }

  save(data, options)
end