New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename identifier_style and pattern_syntax #593

Merged
merged 5 commits into from May 19, 2015
Jump to file or symbol
Failed to load files and symbols.
+40 −37
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Rename pattern_syntax to pattern_type

  • Loading branch information...
ddfreyne committed May 18, 2015
commit 3c09009ffcfa28e3a0c0b65237e844992fdb8b16
View
@@ -6,7 +6,8 @@ Changes:
* Removed `ItemCollectionView#at`
* Removed support for calling `ItemCollectionView#[]` with an integer
* Renamed `identifier_type` to `identifier_type`, and made its values be `"full"` or `"legacy"`.
* Renamed `identifier_style` to `identifier_type`, and made its values be `"full"` or `"legacy"`.
* Renamed `pattern_syntax` to `pattern_type`, and made its values be `"glob"` or `"legacy"`.
Enhancements:
@@ -45,7 +46,7 @@ Fixes:
Features:
* Glob patterns (opt-in by setting `pattern_syntax` to `"glob"` in the site configuration)
* Identifiers with extensions (opt-in by setting `identifier_type` to `"full"` in the data source configuration)
* Identifiers with extensions (opt-in by setting `identifier_style` to `"full"` in the data source configuration)
Enhancements:
@@ -260,14 +260,14 @@ def include_rules(name)
# @api private
def create_pattern(arg)
case @config[:pattern_syntax]
case @config[:pattern_type]
when 'glob'
Nanoc::Int::Pattern.from(arg)
when nil
when 'legacy'
Nanoc::Int::Pattern.from(identifier_to_regex(arg))
else
raise Nanoc::Int::Errors::GenericTrivial,
"Invalid pattern_syntax: #{@config[:pattern_syntax]}"
"Invalid pattern_type: #{@config[:pattern_type]}"
end
end
@@ -105,7 +105,7 @@ def layout_with_identifier(layout_identifier)
end
def use_globs?
@compiler.site.config[:pattern_syntax] == 'glob'
@compiler.site.config[:pattern_type] == 'glob'
end
end
end
@@ -75,7 +75,7 @@ def build_mapping
end
def use_globs?
@config[:pattern_syntax] == 'glob'
@config[:pattern_type] == 'glob'
end
end
end
@@ -41,7 +41,7 @@ class Site
index_filenames: ['index.html'],
enable_output_diff: false,
prune: { auto_prune: false, exclude: ['.git', '.hg', '.svn', 'CVS'] },
pattern_syntax: 'glob',
pattern_type: 'glob',
}
# Creates a site object for the site specified by the given
@@ -23,7 +23,7 @@ def array_to_yaml(array)
# The syntax to use for patterns in the Rules file. Can be either `"glob"`
# (default) or `null`. The former will enable glob patterns, which behave like
# Ruby’s File.fnmatch. The latter will enable nanoc 3.x-style patterns.
pattern_syntax: glob
pattern_type: glob
# A list of file extensions that nanoc will consider to be textual rather than
# binary. If an item with an extension not in this list is found, the file
@@ -5,7 +5,7 @@
let(:view) { described_class.new(wrapped) }
let(:config) do
{ pattern_syntax: 'glob' }
{ pattern_type: 'glob' }
end
describe '#unwrap' do
@@ -86,7 +86,7 @@
let(:arg) { '/home.*' }
context 'globs not enabled' do
let(:config) { { pattern_syntax: nil } }
let(:config) { { pattern_type: 'legacy' } }
it 'returns nil' do
expect(subject).to be_nil
@@ -6,7 +6,7 @@
it_behaves_like 'a mutable identifiable collection'
let(:config) do
{ pattern_syntax: 'glob' }
{ pattern_type: 'glob' }
end
describe '#create' do
@@ -6,7 +6,7 @@
it_behaves_like 'a mutable identifiable collection'
let(:config) do
{ pattern_syntax: 'glob' }
{ pattern_type: 'glob' }
end
describe '#create' do
@@ -177,7 +177,7 @@ def test_passthrough_priority
def test_passthrough_with_full_identifiers
with_site do
File.open('nanoc.yaml', 'w') do |io|
io << 'pattern_syntax: null' << "\n"
io << 'pattern_type: legacy' << "\n"
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
@@ -267,15 +267,17 @@ def test_ignore_priority
end
end
def test_create_pattern_with_string
def test_create_pattern_with_string_with_no_config
compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {})
pattern = compiler_dsl.create_pattern('/foo/*')
assert pattern.match?('/foo/a/a/a/a')
err = assert_raises(Nanoc::Int::Errors::GenericTrivial) do
compiler_dsl.create_pattern('/foo/*')
end
assert_equal 'Invalid pattern_type: ', err.message
end
def test_create_pattern_with_string_with_glob_pattern_syntax
compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, { pattern_syntax: 'glob' })
def test_create_pattern_with_string_with_glob_pattern_type
compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, { pattern_type: 'glob' })
pattern = compiler_dsl.create_pattern('/foo/*')
assert pattern.match?('/foo/aaaa')
@@ -284,19 +286,19 @@ def test_create_pattern_with_string_with_glob_pattern_syntax
end
def test_create_pattern_with_regex
compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {})
compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, { pattern_type: 'glob' })
pattern = compiler_dsl.create_pattern(%r<\A/foo/a*/>)
assert pattern.match?('/foo/aaaa/')
end
def test_create_pattern_with_string_with_unknown_pattern_syntax
compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, { pattern_syntax: 'donkey' })
def test_create_pattern_with_string_with_unknown_pattern_type
compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, { pattern_type: 'donkey' })
err = assert_raises(Nanoc::Int::Errors::GenericTrivial) do
compiler_dsl.create_pattern('/foo/*')
end
assert_equal 'Invalid pattern_syntax: donkey', err.message
assert_equal 'Invalid pattern_type: donkey', err.message
end
def test_identifier_to_regex_without_wildcards
@@ -27,7 +27,7 @@ def test_enumerable
end
def test_brackets_with_glob
@items = Nanoc::Int::IdentifiableCollection.new({ pattern_syntax: 'glob' })
@items = Nanoc::Int::IdentifiableCollection.new({ pattern_type: 'glob' })
@items << @one
@items << @two
@@ -283,7 +283,7 @@ def test_outdated_if_config_outdated
FileUtils.cd('foo') do
File.open('nanoc.yaml', 'w') do |io|
io << 'awesome: true' << "\n"
io << 'pattern_syntax: null' << "\n"
io << 'pattern_type: legacy' << "\n"
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
@@ -50,7 +50,7 @@ def test_auto_prune
end
File.open('nanoc.yaml', 'w') do |io|
io.write "pattern_syntax: null\n"
io.write "pattern_type: legacy\n"
io.write "prune:\n"
io.write " auto_prune: false\n"
end
@@ -64,7 +64,7 @@ def test_auto_prune
assert File.file?('output/stray.html')
File.open('nanoc.yaml', 'w') do |io|
io.write "pattern_syntax: null\n"
io.write "pattern_type: legacy\n"
io.write "prune:\n"
io.write " auto_prune: true\n"
end
@@ -100,7 +100,7 @@ def test_auto_prune_with_exclude
Dir.mkdir('output/excluded_dir')
File.open('nanoc.yaml', 'w') do |io|
io.write "pattern_syntax: null\n"
io.write "pattern_type: legacy\n"
io.write "prune:\n"
io.write " auto_prune: false\n"
end
@@ -114,7 +114,7 @@ def test_auto_prune_with_exclude
assert File.file?('output/stray.html')
File.open('nanoc.yaml', 'w') do |io|
io.write "pattern_syntax: null\n"
io.write "pattern_type: legacy\n"
io.write "prune:\n"
io.write " auto_prune: true\n"
io.write " exclude: [ 'excluded_dir' ]\n"
@@ -72,7 +72,7 @@ def test_default_encoding
# Try with encoding = specific
File.open('nanoc.yaml', 'w') do |io|
io.write("pattern_syntax: glob\n")
io.write("pattern_type: glob\n")
io.write("data_sources:\n")
io.write(" -\n")
io.write(" type: filesystem_unified\n")
@@ -4,7 +4,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
def test_run_without_yes
with_site do |_site|
# Set output dir
File.open('nanoc.yaml', 'w') { |io| io.write "output_dir: output2\npattern_syntax: null\n" }
File.open('nanoc.yaml', 'w') { |io| io.write "output_dir: output2\npattern_type: legacy\n" }
FileUtils.mkdir_p('output2')
# Create source files
@@ -28,7 +28,7 @@ def test_run_with_yes
# Set output dir
File.open('nanoc.yaml', 'w') do |io|
io << 'output_dir: output2' << "\n"
io << 'pattern_syntax: null' << "\n"
io << 'pattern_type: legacy' << "\n"
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
@@ -53,7 +53,7 @@ def test_run_with_yes
def test_run_with_dry_run
with_site do |_site|
# Set output dir
File.open('nanoc.yaml', 'w') { |io| io.write "pattern_syntax: null\noutput_dir: output2" }
File.open('nanoc.yaml', 'w') { |io| io.write "pattern_type: legacy\noutput_dir: output2" }
FileUtils.mkdir_p('output2')
# Create source files
@@ -76,7 +76,7 @@ def test_run_with_exclude
File.open('nanoc.yaml', 'w') do |io|
io << 'prune:' << "\n"
io << ' exclude: [ "good-dir", "good-file.html" ]' << "\n"
io << 'pattern_syntax: null' << "\n"
io << 'pattern_type: legacy' << "\n"
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
@@ -47,7 +47,7 @@ def test_run_excluded
assert Dir['content/*'].empty?
assert Dir['output/*'].empty?
File.open('nanoc.yaml', 'w') { |io| io.write "pattern_syntax: null\nprune:\n exclude: [ 'excluded.html' ]" }
File.open('nanoc.yaml', 'w') { |io| io.write "pattern_type: legacy\nprune:\n exclude: [ 'excluded.html' ]" }
File.open('content/index.html', 'w') { |io| io.write('stuff') }
File.open('output/excluded.html', 'w') { |io| io.write('stuff') }
assert calc_issues.empty?
@@ -59,7 +59,7 @@ def test_run_excluded_with_broken_config
assert Dir['content/*'].empty?
assert Dir['output/*'].empty?
File.open('nanoc.yaml', 'w') { |io| io.write "pattern_syntax: null\nprune:\n blah: meh" }
File.open('nanoc.yaml', 'w') { |io| io.write "pattern_type: legacy\nprune:\n blah: meh" }
File.open('content/index.html', 'w') { |io| io.write('stuff') }
File.open('output/excluded.html', 'w') { |io| io.write('stuff') }
refute calc_issues.empty?
View
@@ -104,7 +104,7 @@ def with_site(params = {})
end
File.open('nanoc.yaml', 'w') do |io|
io << 'pattern_syntax: null' << "\n"
io << 'pattern_type: legacy' << "\n"
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
ProTip! Use n and p to navigate between commits in a pull request.