Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
Fixes a few minor mistakes, preparing for release
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Saunders committed Sep 2, 2015
1 parent c18edca commit 03f3f3b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/shopify_theme/cli.rb
Expand Up @@ -58,7 +58,7 @@ def check(exit_on_failure=false)

desc "configure API_KEY PASSWORD STORE THEME_ID", "generate a config file for the store to connect to"
def configure(api_key=nil, password=nil, store=nil, theme_id=nil)
config = {:api_key => api_key, :password => password, :store => store, :theme_id => theme_id}
config = {:api_key => api_key, :password => password, :store => store, :theme_id => theme_id, :whitelist_files => Filters::Whitelist::DEFAULT_WHITELIST}
create_file('config.yml', config.to_yaml)
check(true)
end
Expand All @@ -73,7 +73,7 @@ def configure_oauth(access_token=nil, store=nil, theme_id=nil)
method_option :master, :type => :boolean, :default => false
method_option :version, :type => :string, :default => "latest"
def bootstrap(api_key=nil, password=nil, store=nil, theme_name=nil)
ShopifyTheme.config = {:api_key => api_key, :password => password, :store => store}
ShopifyTheme.config = {:api_key => api_key, :password => password, :store => store, :whitelist_files => Filters::Whitelist::DEFAULT_WHITELIST}
check(true)

theme_name ||= 'Timber'
Expand Down Expand Up @@ -215,7 +215,7 @@ def shop_theme_url

private
def assets_for(keys=[], files=[])
filter = FileFilter.new(CommandInput.new(keys))
filter = FileFilters.new(Filters::CommandInput.new(keys))
filter.select(files)
end

Expand Down
1 change: 1 addition & 0 deletions lib/shopify_theme/file_filters.rb
@@ -1,5 +1,6 @@
require 'shopify_theme/filters/blacklist'
require 'shopify_theme/filters/whitelist'
require 'shopify_theme/filters/command_input'

module ShopifyTheme
class FileFilters
Expand Down
13 changes: 7 additions & 6 deletions lib/shopify_theme/filters/command_input.rb
@@ -1,16 +1,17 @@
module ShopifyTheme
module Filters
class CommandInput
attr_reader :patterns
def initialize(inputs=[])
@patterns = inputs.map { |i| Regexp.compile(i) }
end
end

def select(list)
return list if inputs.empty?
list.select { |entry|
patterns.any? { |pat| pat.match(entry) }
}
def select(list)
return list if patterns.empty?
list.select { |entry|
patterns.any? { |pat| pat.match(entry) }
}
end
end
end
end
2 changes: 1 addition & 1 deletion lib/shopify_theme/version.rb
@@ -1,3 +1,3 @@
module ShopifyTheme
VERSION = "0.0.23"
VERSION = "0.0.24"
end
18 changes: 18 additions & 0 deletions spec/unit/filters/command_input_spec.rb
@@ -0,0 +1,18 @@
require 'spec_helper'
require 'shopify_theme/filters/command_input'

module ShopifyTheme
module Filters
describe "CommandInput" do
it "should return the entire list if initialized with nothing" do
filter = CommandInput.new([])
assert_equal %w(a b c d e f), filter.select(%w(a b c d e f))
end

it "should return a subset if initialized with some values" do
filter = CommandInput.new(%w(a c d))
assert_equal %w(a c d a), filter.select(%w(a b c d e a f))
end
end
end
end

0 comments on commit 03f3f3b

Please sign in to comment.