lib/gooddata/models/process.rb in gooddata-0.6.0.pre6 vs lib/gooddata/models/process.rb in gooddata-0.6.0.pre7
- old
+ new
@@ -5,70 +5,13 @@
class Process
class << self
def [](id)
if id == :all
- GoodData.get("/gdc/projects/hi95siviyangv53c3vptkz1eas546pnn/dataload/processes")
+ GoodData.get("/gdc/projects/#{GoodData.project.pid}/dataload/processes")
else
- self.new(GoodData.get("/gdc/projects/hi95siviyangv53c3vptkz1eas546pnn/dataload/processes/#{id}"))
+ self.new(GoodData.get("/gdc/projects/#{GoodData.project.pid}/dataload/processes/#{id}"))
end
- end
-
- def deploy(dir, options={}, &block)
- if block
- begin
- res = deploy_graph(dir, options)
- block.call(res)
- ensure
- self_link = res["process"]["links"]["self"]
- GoodData.delete(self_link)
- end
- else
- deploy_graph(dir, options)
- end
- end
-
- def deploy_graph(dir, options={})
- dir = Pathname(dir)
- fail "Provided path (#{dir}) is not directory." unless dir.directory?
- type = options[:type] || "ETL"
-
- deploy_name = options[:name] || options[:project_name]
- verbose = options[:verbose] || false
- project_pid = 'hi95siviyangv53c3vptkz1eas546pnn'
-
- puts HighLine::color("Deploying #{dir}", HighLine::BOLD) if verbose
- res = nil
-
- Tempfile.open("deploy-graph-archive") do |temp|
- Zip::OutputStream.open(temp.path) do |zio|
- Dir.glob(dir + "**/*") do |item|
- puts "including #{item}" if verbose
- unless File.directory?(item)
- zio.put_next_entry(item)
- zio.print IO.read(item)
- end
- end
- end
-
- GoodData.connection.upload(temp.path)
- process_id = options[:process]
-
- data = {
- :process => {
- :name => deploy_name,
- :path => "/uploads/#{File.basename(temp.path)}",
- :type => type
- }
- }
- res = if process_id.nil?
- GoodData.post("/gdc/projects/#{project_pid}/dataload/processes", data)
- else
- GoodData.put("/gdc/projects/#{project_pid}/dataload/processes/#{process_id}", data)
- end
- end
- puts HighLine::color("Deploy DONE #{dir}", HighLine::BOLD) if verbose
- res
end
end
def initialize(data)
@data = data