Class: Tembin::Applyer
- Inherits:
-
Object
- Object
- Tembin::Applyer
- Defined in:
- lib/tembin/applyer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(elements, out: STDOUT, dry_run: true) ⇒ Applyer
constructor
A new instance of Applyer.
- #run ⇒ Object
Constructor Details
#initialize(elements, out: STDOUT, dry_run: true) ⇒ Applyer
Returns a new instance of Applyer.
9 10 11 12 13 |
# File 'lib/tembin/applyer.rb', line 9 def initialize(elements, out: STDOUT, dry_run: true) @elements = elements @dry_run = dry_run @out = out end |
Class Method Details
.run(elements, dry_run: true, out: STDOUT) ⇒ Object
5 6 7 |
# File 'lib/tembin/applyer.rb', line 5 def self.run(elements, dry_run: true, out: STDOUT) new(elements, out: out, dry_run: dry_run).run end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tembin/applyer.rb', line 15 def run remote_queries = Tembin::Redash::Query.created_by_me remote_queries.each do |remote_query| @out.puts(h.color("#{remote_query.name}", :green)) update_query( remote_query, @elements.find{ |e| e.name == remote_query.name }, ) end remote_query_names = remote_queries.map(&:name) @elements.reject { |local| remote_query_names.include?(local.name) }.each { |element| create_new_query(element) } end |