gd_bam 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/bam +36 -3
  2. data/lib/bam/version.rb +1 -1
  3. data/lib/base/flow.rb +4 -0
  4. metadata +2 -2
data/bin/bam CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'gli'
3
3
  require 'bam'
4
-
4
+ require "highline/import"
5
5
  include GLI::App
6
6
 
7
7
  program_desc 'Describe your application here'
@@ -172,8 +172,41 @@ end
172
172
  desc "Prepares params.prm file for debugging that particular graph"
173
173
  command :debug do |c|
174
174
  c.action do |global_options,options,args|
175
- fail "Arguments should be passed as \"project\" \"flow\" \"graph\"" if args.length < 3
176
- GoodData::Bam::Commands::set_up_debug(args.first, args[1], args[2])
175
+ debug_path = args.first
176
+ vs = []
177
+ Pathname(debug_path).ascend {|v| vs << v }
178
+ project_path = vs.last
179
+ debug_path = Pathname(debug_path).basename
180
+ # fail "Arguments should be passed as \"project\" \"flow\" \"graph\"" if args.length < 3
181
+ params = global_options[:user_params]
182
+ params = PARAMS.merge({
183
+ :project_name => "downloaders-#{PARAMS[:project_name]}",
184
+ :graph_repos => [
185
+ GoodData::Bam::Repository.create(:type => :file, :base => './local_graphs'),
186
+ GoodData::Bam::Repository.create(:type => :file, :base => GoodData::CloverGenerator::BAM_DEFINED_GRAPHS_ROOT)]
187
+ })
188
+ home = '.'
189
+ home = Pathname(home)
190
+ project = GoodData::Bam::Project.build_project(home, params)
191
+ flows = project[:flows].find_all do |flow|
192
+ GoodData::Bam::Flow.find_graphs(flow).map {|s| GoodData::Bam::Step.get_graph_path(s).basename}.any? {|name| name == debug_path}
193
+ end
194
+ index = if flows.count > 1
195
+ m = HighLine::Menu.new
196
+ m.choose do |menu|
197
+ menu.prompt = "There is more than one flow using this graph. Pick the flow you want to debug."
198
+ flows.each_with_index do |flow, i|
199
+ menu.choice(flow[:name]) do i end
200
+ end
201
+ end
202
+ else
203
+ 0
204
+ end
205
+
206
+ steps = flows.map {|flow|GoodData::Bam::Flow.find_graphs(flow).find {|s| GoodData::Bam::Step.get_graph_path(s).basename == debug_path }}
207
+ stuff = flows.map {|f| f[:name]}.zip(steps.map {|s| GoodData::Bam::Step.step_name(s)})
208
+
209
+ GoodData::Bam::Commands::set_up_debug(project_path, stuff[index][0], stuff[index][1])
177
210
  end
178
211
  end
179
212
 
data/lib/bam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bam
2
- VERSION = '0.1.17'
2
+ VERSION = '0.1.18'
3
3
  end
data/lib/base/flow.rb CHANGED
@@ -16,6 +16,10 @@ module GoodData
16
16
  x
17
17
  end
18
18
 
19
+ def self.find_graphs(flow)
20
+ flow[:steps].find_all {|s| s[:type] == :graph}
21
+ end
22
+
19
23
  def self.add_step(flow, step)
20
24
  new_steps = flow[:steps].concat([step])
21
25
  Flow.create(flow.merge({:steps => new_steps}))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gd_bam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-26 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake