Class: GTM::Push
- Inherits:
-
Object
- Object
- GTM::Push
- Defined in:
- lib/gtm/push.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client) ⇒ Push
constructor
A new instance of Push.
- #run ⇒ Object
Constructor Details
#initialize(client) ⇒ Push
Returns a new instance of Push.
11 12 13 |
# File 'lib/gtm/push.rb', line 11 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
9 10 11 |
# File 'lib/gtm/push.rb', line 9 def client @client end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gtm/push.rb', line 15 def run tag_file = "#{@client.scope[:account_id]}/#{@client.scope[:container_name]}/tags/#{@client.scope[:tag_file]}" data = File.read("#{@client.scope[:path]}.dump/meta/#{tag_file}.dump") tag = Marshal.load(data) tag_content = File.read("#{@client.scope[:path]}#{tag_file}") body = tag body['parameter'].each do |parameter| parameter['value'] = tag_content if parameter['key'].eql?('html') end @client.run do |_accounts| print "pushing tag #{"#{@client.scope[:path]}#{tag_file}"} for account #{tag['accountId']} into container #{tag['containerId']} " result = @client.client.execute( api_method: @client.gtm.accounts.containers..update, parameters: { accountId: tag['accountId'], containerId: tag['containerId'], tagId: tag['tagId'] }, body_object: body ) print '[OK]' end end |