shopify_theme 0.0.24 → 0.0.25
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/.travis.yml +2 -0
 - data/Rakefile +14 -0
 - data/lib/certs/cacert.pem +3988 -0
 - data/lib/shopify_theme.rb +3 -0
 - data/lib/shopify_theme/cli.rb +11 -7
 - data/lib/shopify_theme/version.rb +1 -1
 - data/spec/smoke/ca_cert_spec.rb +43 -0
 - data/spec/unit/filters/blacklist_spec.rb +3 -3
 - data/spec/unit/filters/whitelist_spec.rb +3 -3
 - metadata +4 -2
 
    
        data/lib/shopify_theme.rb
    CHANGED
    
    | 
         @@ -1,6 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'httparty'
         
     | 
| 
       2 
2 
     | 
    
         
             
            module ShopifyTheme
         
     | 
| 
      
 3 
     | 
    
         
            +
              REMOTE_CERT_FILE = 'http://curl.haxx.se/ca/cacert.pem'
         
     | 
| 
      
 4 
     | 
    
         
            +
              CA_CERT_FILE = File.expand_path(File.dirname(__FILE__) + '/certs/cacert.pem')
         
     | 
| 
       3 
5 
     | 
    
         
             
              include HTTParty
         
     | 
| 
      
 6 
     | 
    
         
            +
              ssl_ca_file CA_CERT_FILE
         
     | 
| 
       4 
7 
     | 
    
         
             
              @@current_api_call_count = 0
         
     | 
| 
       5 
8 
     | 
    
         
             
              @@total_api_calls = 40
         
     | 
| 
       6 
9 
     | 
    
         | 
    
        data/lib/shopify_theme/cli.rb
    CHANGED
    
    | 
         @@ -169,8 +169,10 @@ module ShopifyTheme 
     | 
|
| 
       169 
169 
     | 
    
         
             
                  puts "Watching current folder: #{Dir.pwd}"
         
     | 
| 
       170 
170 
     | 
    
         
             
                  watcher do |filename, event|
         
     | 
| 
       171 
171 
     | 
    
         
             
                    filename = filename.gsub("#{Dir.pwd}/", '')
         
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
                     
     | 
| 
      
 172 
     | 
    
         
            +
                    
         
     | 
| 
      
 173 
     | 
    
         
            +
                    next unless local_assets_list.include?(filename)
         
     | 
| 
      
 174 
     | 
    
         
            +
                    
         
     | 
| 
      
 175 
     | 
    
         
            +
                    action = if [:changed, :new].include?(event)
         
     | 
| 
       174 
176 
     | 
    
         
             
                      :send_asset
         
     | 
| 
       175 
177 
     | 
    
         
             
                    elsif event == :delete && !options['keep_files']
         
     | 
| 
       176 
178 
     | 
    
         
             
                      :delete_asset
         
     | 
| 
         @@ -194,11 +196,13 @@ module ShopifyTheme 
     | 
|
| 
       194 
196 
     | 
    
         
             
                  end
         
     | 
| 
       195 
197 
     | 
    
         
             
                end
         
     | 
| 
       196 
198 
     | 
    
         | 
| 
       197 
     | 
    
         
            -
                 
     | 
| 
       198 
     | 
    
         
            -
                   
     | 
| 
       199 
     | 
    
         
            -
                     
     | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
      
 199 
     | 
    
         
            +
                no_commands do
         
     | 
| 
      
 200 
     | 
    
         
            +
                  def local_assets_list
         
     | 
| 
      
 201 
     | 
    
         
            +
                    FileFilters.new(
         
     | 
| 
      
 202 
     | 
    
         
            +
                      Filters::Whitelist.new(ShopifyTheme.whitelist_files),
         
     | 
| 
      
 203 
     | 
    
         
            +
                      Filters::Blacklist.new(ShopifyTheme.ignore_files)
         
     | 
| 
      
 204 
     | 
    
         
            +
                    ).select(local_files)
         
     | 
| 
      
 205 
     | 
    
         
            +
                  end
         
     | 
| 
       202 
206 
     | 
    
         
             
                end
         
     | 
| 
       203 
207 
     | 
    
         | 
| 
       204 
208 
     | 
    
         
             
                protected
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'shopify_theme'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'net/http'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'uri'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'digest'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module Smoke
         
     | 
| 
      
 8 
     | 
    
         
            +
              describe "CA Certificate Validity" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                before do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  WebMock.disable!
         
     | 
| 
      
 11 
     | 
    
         
            +
                  unless ENV['VERIFY_CERT']
         
     | 
| 
      
 12 
     | 
    
         
            +
                    puts "Not testing CA certificates unless VERIFY_CERT variable is set"
         
     | 
| 
      
 13 
     | 
    
         
            +
                    skip
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                after do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  WebMock.enable!
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                it "verifies that the local certificate matches with that on haxx.se" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  assert_equal digest(local_file), digest(remote_file)
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def local_file
         
     | 
| 
      
 26 
     | 
    
         
            +
                  File.read(ShopifyTheme::CA_CERT_FILE)
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                def remote_file
         
     | 
| 
      
 30 
     | 
    
         
            +
                  cert_uri = URI(ShopifyTheme::REMOTE_CERT_FILE)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  response = Net::HTTP.get_response(cert_uri)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  if response.code == '200'
         
     | 
| 
      
 33 
     | 
    
         
            +
                    response.body
         
     | 
| 
      
 34 
     | 
    
         
            +
                  else
         
     | 
| 
      
 35 
     | 
    
         
            +
                    flunk "Could not connect to #{cert_uri}. Verify that certificate is still hosted."
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                def digest(message)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  Digest::MD5.hexdigest(message)
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -5,7 +5,7 @@ require 'shopify_theme/filters/blacklist' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            module ShopifyTheme
         
     | 
| 
       6 
6 
     | 
    
         
             
              module Filters
         
     | 
| 
       7 
7 
     | 
    
         
             
                describe "Blacklist" do
         
     | 
| 
       8 
     | 
    
         
            -
                   
     | 
| 
      
 8 
     | 
    
         
            +
                  BLACKLIST_TEST_PATHS = %w(
         
     | 
| 
       9 
9 
     | 
    
         
             
                      settings.html
         
     | 
| 
       10 
10 
     | 
    
         
             
                      config/item1.html
         
     | 
| 
       11 
11 
     | 
    
         
             
                      config/item2.html
         
     | 
| 
         @@ -19,12 +19,12 @@ module ShopifyTheme 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                  it "should return the entire list back if initialized with no patterns" do
         
     | 
| 
       21 
21 
     | 
    
         
             
                    blacklist = Blacklist.new
         
     | 
| 
       22 
     | 
    
         
            -
                    assert_equal  
     | 
| 
      
 22 
     | 
    
         
            +
                    assert_equal BLACKLIST_TEST_PATHS, blacklist.select(BLACKLIST_TEST_PATHS)
         
     | 
| 
       23 
23 
     | 
    
         
             
                  end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                  it "should return everything except for the items that matched the pattern" do
         
     | 
| 
       26 
26 
     | 
    
         
             
                    blacklist = Blacklist.new(%w(config/* settings.html assets/* templates/* snippets/*))
         
     | 
| 
       27 
     | 
    
         
            -
                    assert_equal %w(layout/thing1.html), blacklist.select( 
     | 
| 
      
 27 
     | 
    
         
            +
                    assert_equal %w(layout/thing1.html), blacklist.select(BLACKLIST_TEST_PATHS)
         
     | 
| 
       28 
28 
     | 
    
         
             
                  end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                end
         
     | 
| 
         @@ -4,7 +4,7 @@ require 'shopify_theme/filters/whitelist' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            module ShopifyTheme
         
     | 
| 
       5 
5 
     | 
    
         
             
              module Filters
         
     | 
| 
       6 
6 
     | 
    
         
             
                describe "Whitelist" do
         
     | 
| 
       7 
     | 
    
         
            -
                   
     | 
| 
      
 7 
     | 
    
         
            +
                  WHITELIST_TEST_PATHS = %w(
         
     | 
| 
       8 
8 
     | 
    
         
             
                      settings.html
         
     | 
| 
       9 
9 
     | 
    
         
             
                      config/item1.html
         
     | 
| 
       10 
10 
     | 
    
         
             
                      config/item2.html
         
     | 
| 
         @@ -28,13 +28,13 @@ module ShopifyTheme 
     | 
|
| 
       28 
28 
     | 
    
         
             
                      templates/thing2.html
         
     | 
| 
       29 
29 
     | 
    
         
             
                      snippets/fancy.liquid
         
     | 
| 
       30 
30 
     | 
    
         
             
                    )
         
     | 
| 
       31 
     | 
    
         
            -
                    assert_equal expected, whitelist.select( 
     | 
| 
      
 31 
     | 
    
         
            +
                    assert_equal expected, whitelist.select(WHITELIST_TEST_PATHS)
         
     | 
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                  it "should ignore the default 1+ whitelists were provided" do
         
     | 
| 
       35 
35 
     | 
    
         
             
                    whitelist = Whitelist.new %w(settings.html config/item1.html config/item2.html config/item3.html layout/ templates/)
         
     | 
| 
       36 
36 
     | 
    
         
             
                    expected = %w(settings.html config/item1.html config/item2.html config/item3.html layout/thing1.html templates/thing2.html)
         
     | 
| 
       37 
     | 
    
         
            -
                    assert_equal expected, whitelist.select( 
     | 
| 
      
 37 
     | 
    
         
            +
                    assert_equal expected, whitelist.select(WHITELIST_TEST_PATHS)
         
     | 
| 
       38 
38 
     | 
    
         
             
                  end
         
     | 
| 
       39 
39 
     | 
    
         
             
                end
         
     | 
| 
       40 
40 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: shopify_theme
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.25
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - John Duff
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-09-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: thor
         
     | 
| 
         @@ -171,6 +171,7 @@ files: 
     | 
|
| 
       171 
171 
     | 
    
         
             
            - bin/theme
         
     | 
| 
       172 
172 
     | 
    
         
             
            - doc/API-key-and-password.jpg
         
     | 
| 
       173 
173 
     | 
    
         
             
            - doc/how_to_find_theme_id.png
         
     | 
| 
      
 174 
     | 
    
         
            +
            - lib/certs/cacert.pem
         
     | 
| 
       174 
175 
     | 
    
         
             
            - lib/shopify_theme.rb
         
     | 
| 
       175 
176 
     | 
    
         
             
            - lib/shopify_theme/api_checker.rb
         
     | 
| 
       176 
177 
     | 
    
         
             
            - lib/shopify_theme/cli.rb
         
     | 
| 
         @@ -186,6 +187,7 @@ files: 
     | 
|
| 
       186 
187 
     | 
    
         
             
            - spec/cassettes/api_check_success.yml
         
     | 
| 
       187 
188 
     | 
    
         
             
            - spec/cassettes/api_check_unauthorized.yml
         
     | 
| 
       188 
189 
     | 
    
         
             
            - spec/cassettes/timber_releases.yml
         
     | 
| 
      
 190 
     | 
    
         
            +
            - spec/smoke/ca_cert_spec.rb
         
     | 
| 
       189 
191 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       190 
192 
     | 
    
         
             
            - spec/unit/api_checker_spec.rb
         
     | 
| 
       191 
193 
     | 
    
         
             
            - spec/unit/cli_spec.rb
         
     |