This repository has been archived by the owner on Apr 27, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes a few minor mistakes, preparing for release
- Loading branch information
Chris Saunders
committed
Sep 2, 2015
1 parent
c18edca
commit 03f3f3b
Showing
5 changed files
with
30 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ShopifyTheme | ||
VERSION = "0.0.23" | ||
VERSION = "0.0.24" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |