Class: GTM::Bootstrap
- Inherits:
-
Object
- Object
- GTM::Bootstrap
- Defined in:
- lib/gtm/bootstrap.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Class Method Summary collapse
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/gtm/bootstrap.rb', line 5 def client @client end |
Class Method Details
.extract_scope(s) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gtm/bootstrap.rb', line 7 def self.extract_scope(s) full_regex = /^(?<path>.+\/|\/?)(?<account_id>\d+)\/(?<container_name>.+)\/tags\/(?<tag_file>.+)$/ container_regex = /^(?<path>.+\/|\/?)(?<account_id>\d+)\/(?<container_name>\w+)\/?$/ account_regex = /^(?<path>.+\/|\/?)(?<account_id>\d+)\/?$/ [full_regex, container_regex, account_regex].each do |r| match = r.match s if match result = (match.names.zip(match.captures)).to_h.with_indifferent_access return result.deep_symbolize_keys end end result = {path: s.to_s} result[:path] += '/' if !result[:path].blank? && !result[:path][-1].eql?('/') result end |
.pull(arg) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/gtm/bootstrap.rb', line 23 def self.pull(arg) @client ||= GTM::Client.new @client.scope = extract_scope(arg.first) pull = GTM::Pull.new @client pull.run end |
.push(arg) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gtm/bootstrap.rb', line 30 def self.push(arg) @client ||= GTM::Client.new @client.scope = extract_scope(arg.first) if @client.scope[:tag_file] push = GTM::Push.new @client push.run else print 'pleas specify a single tag file, directory push is not supported (yet)' end end |