Module: GoodData::Bam::Project
- Defined in:
- lib/base/project.rb
Class Method Summary collapse
- .build_project(options = {}) ⇒ Object
- .create(project) ⇒ Object
- .find_by(project, what, by_what, name) ⇒ Object
- .find_graph_by_path(project, path) ⇒ Object
- .find_sink_by_id(project, name) ⇒ Object
- .find_sink_by_name(project, name) ⇒ Object
- .find_tap_by_id(project, name) ⇒ Object
- .find_tap_by_name(project, name) ⇒ Object
- .load_flows_definitions(project, path = "./flows/") ⇒ Object
- .load_sinks(project, path = "./sinks/") ⇒ Object
- .load_taps(project, path = "./taps/") ⇒ Object
- .set_graph_repos(project, repos = []) ⇒ Object
Class Method Details
.build_project(options = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/base/project.rb', line 83 def self.build_project(={}) project = Project.create({}) paths = [:graph_repos] || [] p = Project.load_taps(project) p = Project.load_sinks(p) p = Project.set_graph_repos(p, paths) p = Project.load_flows_definitions(p) p = Compiler.compile_dsl(p) end |
.create(project) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/base/project.rb', line 5 def self.create(project) { :flows => [], :flows_definitions => [], :taps => [], :sinks => [] }.merge(project).merge({:type => :project}) end |
.find_by(project, what, by_what, name) ⇒ Object
14 15 16 |
# File 'lib/base/project.rb', line 14 def self.find_by(project, what, by_what, name) project[what].detect {|item| item[by_what] == name} end |
.find_graph_by_path(project, path) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/base/project.rb', line 34 def self.find_graph_by_path(project, path) found = project[:graph_repos].reduce([]) do |acc, repo| if Bam::Repository.find(repo, path) acc.concat([Bam::Repository.find(repo, path)]) else acc end end found.first end |
.find_sink_by_id(project, name) ⇒ Object
26 27 28 |
# File 'lib/base/project.rb', line 26 def self.find_sink_by_id(project, name) Project.find_by(project, :sinks, :id, name) end |
.find_sink_by_name(project, name) ⇒ Object
30 31 32 |
# File 'lib/base/project.rb', line 30 def self.find_sink_by_name(project, name) Project.find_by(project, :sinks, :name, name) end |
.find_tap_by_id(project, name) ⇒ Object
18 19 20 |
# File 'lib/base/project.rb', line 18 def self.find_tap_by_id(project, name) Project.find_by(project, :taps, :id, name) end |
.find_tap_by_name(project, name) ⇒ Object
22 23 24 |
# File 'lib/base/project.rb', line 22 def self.find_tap_by_name(project, name) Project.find_by(project, :taps, :name, name) end |
.load_flows_definitions(project, path = "./flows/") ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/base/project.rb', line 75 def self.load_flows_definitions(project, path="./flows/") p = Pathname(path) flows = Pathname.glob(p + "*.rb").map do |p| GoodData::Bam::DSL.class_eval(File.read p).to_hash end Project.create(project.merge({:flows_definitions => flows})) end |
.load_sinks(project, path = "./sinks/") ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/base/project.rb', line 67 def self.load_sinks(project, path="./sinks/") p = Pathname(path) sinks = Pathname.glob(p + "*.json").map do |p| Sink.create(JSON.parse(File.read(p), :symbolize_names => true)) end Project.create(project.merge({:sinks => sinks})) end |
.load_taps(project, path = "./taps/") ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/base/project.rb', line 45 def self.load_taps(project, path="./taps/") p = Pathname(path) taps = Pathname.glob(p + "*.json").map do |p| Tap.create(JSON.parse(File.read(p), :symbolize_names => true)) end Project.create(project.merge({:taps => taps.map {|tap| Tap.create(tap)}})) end |
.set_graph_repos(project, repos = []) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/base/project.rb', line 53 def self.set_graph_repos(project, repos=[]) # paths = paths.map {|p| Pathname(p)} # graphs = paths.reduce([]) do |acc, path| # Pathname.glob(path + "*.grf").map do |graph_path| # acc.concat([Graph.create({ # :path => graph_path # })]) # end # acc # end Project.create(project.merge({:graph_repos => repos})) end |