haravan_theme 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.
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'haravan_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(HaravanTheme::CA_CERT_FILE)
27
+ end
28
+
29
+ def remote_file
30
+ cert_uri = URI(HaravanTheme::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
@@ -0,0 +1,9 @@
1
+ ENV['TEST'] = 'true'
2
+ require 'minitest/autorun'
3
+ require 'webmock'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |config|
7
+ config.cassette_library_dir = "spec/cassettes"
8
+ config.hook_into :webmock
9
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'haravan_theme'
3
+ require 'haravan_theme/api_checker'
4
+
5
+ module HaravanTheme
6
+ describe "APIChecker" do
7
+ attr_reader :checker
8
+
9
+ before do
10
+ config = {
11
+ api_key: 'abracadabra',
12
+ password: 'alakazam',
13
+ store: 'something.myharavan.com'
14
+ }
15
+ HaravanTheme.config = config
16
+ @checker = APIChecker.new(HaravanTheme)
17
+ end
18
+
19
+ after do
20
+ HaravanTheme.config = nil
21
+ end
22
+
23
+ it "should return an APIResponse that says if the API is accessible when it gets a 200 response" do
24
+ VCR.use_cassette("api_check_success") do
25
+ response = checker.test_connectivity
26
+ assert response.accessed_api?
27
+ end
28
+ end
29
+
30
+ it "should return an APIResponse that says the API is down if it gets a 500-series response" do
31
+ VCR.use_cassette("api_check_api_down") do
32
+ response = checker.test_connectivity
33
+ assert response.api_down?
34
+ end
35
+ end
36
+
37
+ it "should return an APIResponse that says the client is misconfigured if it gets a 401 response" do
38
+ VCR.use_cassette("api_check_unauthorized") do
39
+ response = checker.test_connectivity
40
+ assert response.invalid_config?
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+ require 'haravan_theme'
3
+ require 'haravan_theme/cli'
4
+
5
+ module HaravanTheme
6
+ describe "Cli" do
7
+
8
+ class CliDouble < Cli
9
+ attr_writer :local_files, :mock_config
10
+
11
+ desc "",""
12
+ def config
13
+ @mock_config || super
14
+ end
15
+
16
+ desc "",""
17
+ def shop_theme_url
18
+ super
19
+ end
20
+
21
+ desc "",""
22
+ def binary_file?(file)
23
+ super
24
+ end
25
+
26
+ desc "", ""
27
+ def local_files
28
+ @local_files
29
+ end
30
+ end
31
+
32
+ before do
33
+ @cli = CliDouble.new
34
+ HaravanTheme.config = {}
35
+ end
36
+
37
+ it "should remove assets that are not a part of the white list" do
38
+ @cli.local_files = ['assets/image.png', 'config.yml', 'layout/theme.liquid', 'locales/en.default.json']
39
+ assert_equal 3, @cli.local_assets_list.length
40
+ assert_equal false, @cli.local_assets_list.include?('config.yml')
41
+ end
42
+
43
+ it 'should only use the whitelist entries for determining which files to upload (bug #156)' do
44
+ @cli.local_files = %w(assets/application.css.liquid assets/application.js assets/image.png assets/bunny.jpg layout/index.liquid snippets/preview.liquid)
45
+ HaravanTheme.config = {whitelist_files: %w(assets/application.css.liquid assets/application.js layout/ snippets/)}
46
+ assert_equal 4, @cli.local_assets_list.length
47
+ assert_equal false, @cli.local_assets_list.include?('assets/image.png')
48
+ end
49
+
50
+ it "should remove assets that are part of the ignore list" do
51
+ HaravanTheme.config = {ignore_files: ['config/settings.html']}
52
+ @cli.local_files = ['assets/image.png', 'layout/theme.liquid', 'config/settings.html']
53
+ assert_equal 2, @cli.local_assets_list.length
54
+ assert_equal false, @cli.local_assets_list.include?('config/settings.html')
55
+ end
56
+
57
+ it "should generate the shop path URL to the query parameter preview_theme_id if the id is present" do
58
+ @cli.mock_config = {store: 'somethingfancy.myharavan.com', theme_id: 12345}
59
+ assert_equal "somethingfancy.myharavan.com?preview_theme_id=12345", @cli.shop_theme_url
60
+ end
61
+
62
+ it "should generate the shop path URL withouth the preview_theme_id if the id is not present" do
63
+ @cli.mock_config = {store: 'somethingfancy.myharavan.com'}
64
+ assert_equal "somethingfancy.myharavan.com", @cli.shop_theme_url
65
+
66
+ @cli.mock_config = {store: 'somethingfancy.myharavan.com', theme_id: ''}
67
+ assert_equal "somethingfancy.myharavan.com", @cli.shop_theme_url
68
+ end
69
+
70
+ it "should report binary files as such" do
71
+ extensions = %w(png gif jpg jpeg eot svg ttf woff otf swf ico pdf)
72
+ extensions.each do |ext|
73
+ assert @cli.binary_file?("hello.#{ext}"), "#{ext.upcase}s are binary files"
74
+ end
75
+ end
76
+
77
+ it "should report unknown files as binary files" do
78
+ assert @cli.binary_file?('omg.wut'), "Unknown filetypes are assumed to be binary"
79
+ end
80
+
81
+ it "should not report text based files as binary" do
82
+ refute @cli.binary_file?('theme.liquid'), "liquid files are not binary"
83
+ refute @cli.binary_file?('style.sass.liquid'), "sass.liquid files are not binary"
84
+ refute @cli.binary_file?('style.css'), 'CSS files are not binary'
85
+ refute @cli.binary_file?('application.js'), 'Javascript files are not binary'
86
+ refute @cli.binary_file?('settings_data.json'), 'JSON files are not binary'
87
+ refute @cli.binary_file?('applicaton.js.map'), 'Javascript Map files are not binary'
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'haravan_theme/file_filters'
3
+
4
+ module HaravanTheme
5
+ describe "FileFilters" do
6
+ class IdentityFilter
7
+ def select(list)
8
+ list.select { true }
9
+ end
10
+ end
11
+
12
+ class EvenFilter
13
+ def select(list)
14
+ list.select { |i| i % 2 == 0 }
15
+ end
16
+ end
17
+
18
+ it "initializing without a filter raises an error" do
19
+ assert_raises ArgumentError do
20
+ FileFilters.new
21
+ end
22
+ end
23
+
24
+ it "initializing with a single filter" do
25
+ begin
26
+ FileFilters.new(IdentityFilter.new)
27
+ rescue Error => e
28
+ flunk("Initializing with a single filter should not fail. #{e}")
29
+ end
30
+ end
31
+
32
+ it "should only select entries that were valid for all of the given filters" do
33
+ filters = FileFilters.new(IdentityFilter.new, EvenFilter.new)
34
+ assert_equal [2, 4], filters.select([1, 2, 3, 4, 5])
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'haravan_theme/filters/blacklist'
3
+
4
+
5
+ module HaravanTheme
6
+ module Filters
7
+ describe "Blacklist" do
8
+ BLACKLIST_TEST_PATHS = %w(
9
+ settings.html
10
+ config/item1.html
11
+ config/item2.html
12
+ config/item3.html
13
+ layout/thing1.html
14
+ assets/application.css.liquid
15
+ assets/application.js
16
+ templates/thing2.html
17
+ snippets/fancy.liquid
18
+ )
19
+
20
+ it "should return the entire list back if initialized with no patterns" do
21
+ blacklist = Blacklist.new
22
+ assert_equal BLACKLIST_TEST_PATHS, blacklist.select(BLACKLIST_TEST_PATHS)
23
+ end
24
+
25
+ it "should return everything except for the items that matched the pattern" do
26
+ blacklist = Blacklist.new(%w(config/* settings.html assets/* templates/* snippets/*))
27
+ assert_equal %w(layout/thing1.html), blacklist.select(BLACKLIST_TEST_PATHS)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'haravan_theme/filters/command_input'
3
+
4
+ module HaravanTheme
5
+ module Filters
6
+ describe "CommandInput" do
7
+ it "should return the entire list if initialized with nothing" do
8
+ filter = CommandInput.new([])
9
+ assert_equal %w(a b c d e f), filter.select(%w(a b c d e f))
10
+ end
11
+
12
+ it "should return a subset if initialized with some values" do
13
+ filter = CommandInput.new(%w(a c d))
14
+ assert_equal %w(a c d a), filter.select(%w(a b c d e a f))
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'haravan_theme/filters/whitelist'
3
+
4
+ module HaravanTheme
5
+ module Filters
6
+ describe "Whitelist" do
7
+ WHITELIST_TEST_PATHS = %w(
8
+ settings.html
9
+ config/item1.html
10
+ config/item2.html
11
+ config/item3.html
12
+ layout/thing1.html
13
+ assets/application.css.liquid
14
+ assets/application.js
15
+ templates/thing2.html
16
+ snippets/fancy.liquid
17
+ )
18
+
19
+ it "should use the default whitelist if nothing was provided" do
20
+ whitelist = Whitelist.new
21
+ expected = %w(
22
+ config/item1.html
23
+ config/item2.html
24
+ config/item3.html
25
+ layout/thing1.html
26
+ assets/application.css.liquid
27
+ assets/application.js
28
+ templates/thing2.html
29
+ snippets/fancy.liquid
30
+ )
31
+ assert_equal expected, whitelist.select(WHITELIST_TEST_PATHS)
32
+ end
33
+
34
+ it "should ignore the default 1+ whitelists were provided" do
35
+ whitelist = Whitelist.new %w(settings.html config/item1.html config/item2.html config/item3.html layout/ templates/)
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(WHITELIST_TEST_PATHS)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'haravan_theme'
3
+ require 'haravan_theme/releases'
4
+
5
+ module HaravanTheme
6
+ describe 'Releases' do
7
+
8
+ before do
9
+ VCR.use_cassette("timber_releases") do
10
+ @releases = Releases.new
11
+ @releases.fetch!
12
+ end
13
+ end
14
+
15
+ it "should provide a list of all the available releases" do
16
+ versions = @releases.all.keys
17
+ assert_equal true, versions.include?('latest')
18
+ assert_equal true, versions.include?('v2.0.2')
19
+ assert_equal true, versions.include?('v2.0.1')
20
+ end
21
+
22
+ it "should be able to find a specific release" do
23
+ release = @releases.find('v2.0.2')
24
+ assert_equal 'v2.0.2', release.version
25
+ end
26
+
27
+ it "should raise an error if the version does not exist" do
28
+ assert_raises Releases::VersionError do
29
+ @releases.find('reccomended')
30
+ end
31
+ end
32
+
33
+ it "should provide a zip URL for a release" do
34
+ assert_equal "https://github.com/Haravan/Timber/archive/v2.0.2.zip", @releases.all['v2.0.2'].zip_url
35
+ end
36
+
37
+ it "should provide a zip URL for the latest release" do
38
+ assert_equal "https://github.com/Haravan/Timber/archive/v2.0.2.zip", @releases.all['latest'].zip_url
39
+ end
40
+
41
+ it 'should provide a zip URL for the master release' do
42
+ assert_equal "https://github.com/Haravan/Timber/archive/master.zip", @releases.all['master'].zip_url
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,236 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haravan_theme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.25
5
+ platform: ruby
6
+ authors:
7
+ - John Duff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.14.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.14.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.13.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.13.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: mimemagic
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: filewatcher
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: launchy
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 5.0.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 5.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: vcr
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Command line tool to help with developing Haravan themes. Provides simple
154
+ commands to download, upload and delete files from a theme. Also includes the watch
155
+ command to watch a directory and upload files as they change.
156
+ email:
157
+ - john.duff@shopify.com
158
+ executables:
159
+ - theme
160
+ extensions: []
161
+ extra_rdoc_files: []
162
+ files:
163
+ - ".gitignore"
164
+ - ".travis.yml"
165
+ - CHANGELOG.md
166
+ - CONTRIBUTING
167
+ - Gemfile
168
+ - MIT-LICENSE
169
+ - README.md
170
+ - Rakefile
171
+ - bin/theme
172
+ - doc/API-key-and-password.jpg
173
+ - doc/how_to_find_theme_id.png
174
+ - haravan_theme.gemspec
175
+ - lib/certs/cacert.pem
176
+ - lib/haravan_theme.rb
177
+ - lib/haravan_theme/api_checker.rb
178
+ - lib/haravan_theme/cli.rb
179
+ - lib/haravan_theme/file_filters.rb
180
+ - lib/haravan_theme/filters/blacklist.rb
181
+ - lib/haravan_theme/filters/command_input.rb
182
+ - lib/haravan_theme/filters/whitelist.rb
183
+ - lib/haravan_theme/releases.rb
184
+ - lib/haravan_theme/version.rb
185
+ - shipit.rubygems.yml
186
+ - spec/cassettes/api_check_api_down.yml
187
+ - spec/cassettes/api_check_success.yml
188
+ - spec/cassettes/api_check_unauthorized.yml
189
+ - spec/cassettes/timber_releases.yml
190
+ - spec/smoke/ca_cert_spec.rb
191
+ - spec/spec_helper.rb
192
+ - spec/unit/api_checker_spec.rb
193
+ - spec/unit/cli_spec.rb
194
+ - spec/unit/file_filters_spec.rb
195
+ - spec/unit/filters/blacklist_spec.rb
196
+ - spec/unit/filters/command_input_spec.rb
197
+ - spec/unit/filters/whitelist_spec.rb
198
+ - spec/unit/releases_spec.rb
199
+ homepage: https://github.com/Haravan/haravan_theme
200
+ licenses:
201
+ - MIT
202
+ metadata: {}
203
+ post_install_message:
204
+ rdoc_options: []
205
+ require_paths:
206
+ - lib
207
+ required_ruby_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ required_rubygems_version: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '0'
217
+ requirements: []
218
+ rubyforge_project: haravan_theme
219
+ rubygems_version: 2.6.6
220
+ signing_key:
221
+ specification_version: 4
222
+ summary: Command line tool for developing themes
223
+ test_files:
224
+ - spec/cassettes/api_check_api_down.yml
225
+ - spec/cassettes/api_check_success.yml
226
+ - spec/cassettes/api_check_unauthorized.yml
227
+ - spec/cassettes/timber_releases.yml
228
+ - spec/smoke/ca_cert_spec.rb
229
+ - spec/spec_helper.rb
230
+ - spec/unit/api_checker_spec.rb
231
+ - spec/unit/cli_spec.rb
232
+ - spec/unit/file_filters_spec.rb
233
+ - spec/unit/filters/blacklist_spec.rb
234
+ - spec/unit/filters/command_input_spec.rb
235
+ - spec/unit/filters/whitelist_spec.rb
236
+ - spec/unit/releases_spec.rb