gtm-cli 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gtm/pull.rb +14 -5
- data/lib/gtm/push.rb +27 -19
- data/lib/gtm/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 032d0ea69efdaeb3578392fa8b6c3e34d4c2ac71
         | 
| 4 | 
            +
              data.tar.gz: 2968ef86c27f4cad8c2397000580bc21088d0b51
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0aa17dc5393898986b9f6cbec04ccc13907e4566001ba0109f96080a85dfcd45918987e635e9ed5df4c482492baa4352e3583757d07e9bf8838b2af0a30d446f
         | 
| 7 | 
            +
              data.tar.gz: 6016f017280980ce3c261f435d4457437d9021ecadcc5c3d44277a634ba7a45ac3000f32282a5a003a6fedba1164dfc4744771949ffb20b32374816b568f1bad
         | 
    
        data/lib/gtm/pull.rb
    CHANGED
    
    | @@ -74,13 +74,22 @@ module GTM | |
| 74 74 | 
             
                        print "pulling tags from account #{container['accountId']} into #{tags_path} "
         | 
| 75 75 | 
             
                        tags.each do |tag|
         | 
| 76 76 | 
             
                          tag_name = tag['name'].parameterize.underscore
         | 
| 77 | 
            -
                           | 
| 78 | 
            -
             | 
| 79 | 
            -
                             | 
| 80 | 
            -
                               | 
| 77 | 
            +
                          if %w(ua html).include?(tag.type) # dumpable types
         | 
| 78 | 
            +
                            suffix = ''
         | 
| 79 | 
            +
                            if tag.type.eql?('ua')
         | 
| 80 | 
            +
                              value = tag.parameter.to_json
         | 
| 81 | 
            +
                              suffix = '.json'
         | 
| 82 | 
            +
                            elsif tag.type.eql?('html') and false
         | 
| 83 | 
            +
                              html_parameter = tag.parameter.select { |p| p.key.eql? 'html' }.first
         | 
| 84 | 
            +
                              value = html_parameter.value
         | 
| 81 85 | 
             
                            end
         | 
| 86 | 
            +
                            # EDITABLE CONTENT
         | 
| 87 | 
            +
                            File.open("#{tags_path}/#{tag_name}.#{tag.type}#{suffix}", 'w') do |f|
         | 
| 88 | 
            +
                              f.write value
         | 
| 89 | 
            +
                            end
         | 
| 90 | 
            +
                            # DUMP
         | 
| 82 91 | 
             
                            data = Marshal.dump(tag.to_hash)
         | 
| 83 | 
            -
                            File.open("#{meta_tags_path}/#{tag_name}.#{ | 
| 92 | 
            +
                            File.open("#{meta_tags_path}/#{tag_name}.#{tag.type}.dump", 'w') do |f|
         | 
| 84 93 | 
             
                              f.write data
         | 
| 85 94 | 
             
                            end
         | 
| 86 95 | 
             
                            print '.'
         | 
    
        data/lib/gtm/push.rb
    CHANGED
    
    | @@ -13,28 +13,36 @@ module GTM | |
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
| 15 15 | 
             
                def run
         | 
| 16 | 
            -
                   | 
| 16 | 
            +
                  tag_file_origin = "#{@client.scope[:account_id]}/#{@client.scope[:container_name]}/tags/#{@client.scope[:tag_file]}"
         | 
| 17 | 
            +
                  tag_file = tag_file_origin.gsub(/\.json$/, '')
         | 
| 17 18 | 
             
                  data = File.read("#{@client.scope[:path]}.dump/meta/#{tag_file}.dump")
         | 
| 18 19 | 
             
                  tag = Marshal.load(data)
         | 
| 19 | 
            -
                   | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
                     | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
                         | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
                         | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 20 | 
            +
                  if tag
         | 
| 21 | 
            +
                    tag_content = File.read("#{@client.scope[:path]}#{tag_file_origin}")
         | 
| 22 | 
            +
                    body = tag
         | 
| 23 | 
            +
                    if %w(ua html).include?(tag['type']) # dumpable types
         | 
| 24 | 
            +
                      if tag['type'].eql?('ua')
         | 
| 25 | 
            +
                        body['parameter'] = JSON.parse(tag_content)
         | 
| 26 | 
            +
                      elsif tag['type'].eql?('html') and false
         | 
| 27 | 
            +
                        body['parameter'].each do |parameter|
         | 
| 28 | 
            +
                          parameter['value'] = tag_content if parameter['key'].eql?('html')
         | 
| 29 | 
            +
                        end
         | 
| 30 | 
            +
                      end
         | 
| 31 | 
            +
                      @client.run do |_accounts|
         | 
| 32 | 
            +
                        print "pushing tag #{"#{@client.scope[:path]}#{tag_file_origin}"} for account #{tag['accountId']} into container #{tag['containerId']} "
         | 
| 33 | 
            +
                        result = @client.client.execute(
         | 
| 34 | 
            +
                            api_method: @client.gtm.accounts.containers.tags.update,
         | 
| 35 | 
            +
                            parameters: {
         | 
| 36 | 
            +
                                accountId: tag['accountId'],
         | 
| 37 | 
            +
                                containerId: tag['containerId'],
         | 
| 38 | 
            +
                                tagId: tag['tagId']
         | 
| 39 | 
            +
                            },
         | 
| 40 | 
            +
                            body_object: body
         | 
| 41 | 
            +
                        )
         | 
| 42 | 
            +
                        puts '[OK]'
         | 
| 43 | 
            +
                      end
         | 
| 44 | 
            +
                    end
         | 
| 36 45 | 
             
                  end
         | 
| 37 46 | 
             
                end
         | 
| 38 47 | 
             
              end
         | 
| 39 48 | 
             
            end
         | 
| 40 | 
            -
             | 
    
        data/lib/gtm/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: gtm-cli
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1 | 
| 4 | 
            +
              version: 0.2.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Manuel Dudda
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2016-09-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: google-api-client
         |