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
View
@@ -6,6 +6,7 @@ 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"`.

This comment has been minimized.

@bobthecow

bobthecow May 18, 2015

Member

Renamed identifier_type to identifier_type

:P

@bobthecow

bobthecow May 18, 2015

Member

Renamed identifier_type to identifier_type

:P

This comment has been minimized.

@ddfreyne

ddfreyne May 18, 2015

Member

Yup. I’m on to that right now. :)

@ddfreyne

ddfreyne May 18, 2015

Member

Yup. I’m on to that right now. :)

Enhancements:
@@ -44,7 +45,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_style` to `"full"` in the data source configuration)
* Identifiers with extensions (opt-in by setting `identifier_type` to `"full"` in the data source configuration)
Enhancements:
@@ -16,10 +16,10 @@ def self.from(obj)
end
def initialize(string, params = {})
@style = params.fetch(:style, :stripped)
@style = params.fetch(:style, :legacy)

This comment has been minimized.

@bobthecow

bobthecow May 18, 2015

Member

should this variable be renamed as well?

@bobthecow

bobthecow May 18, 2015

Member

should this variable be renamed as well?

This comment has been minimized.

@ddfreyne

ddfreyne May 18, 2015

Member

Good catch.

@ddfreyne

ddfreyne May 18, 2015

Member

Good catch.

case @style
when :stripped
when :legacy
@string = "/#{string}/".gsub(/^\/+|\/+$/, '/').freeze
when :full
if string !~ /\A\//
@@ -77,7 +77,7 @@ def prefix(string)
# @return [String]
def with_ext(ext)
if @style == :stripped
unless full?
raise Nanoc::Int::Errors::Generic,
'Cannot use #with_ext on identifier that does not include the file extension'
end
@@ -25,7 +25,7 @@ class Site
items_root: '/',
layouts_root: '/',
config: {},
identifier_style: 'full',
identifier_type: 'full',
}
# The default configuration for a site. A site's configuration overrides
@@ -89,7 +89,7 @@ def array_to_yaml(array)
# UTF-8 (which they should be!), change this.
encoding: utf-8
identifier_style: full
identifier_type: full
# Configuration for the “check” command, which run unit tests on the site.
checks:
@@ -129,7 +129,7 @@ def all_split_files_in(dir_name)
unless [0, 1].include?(meta_filenames.size)
raise "Found #{meta_filenames.size} meta files for #{basename}; expected 0 or 1"
end
unless config[:identifier_style] == 'full'
unless config[:identifier_type] == 'full'
unless [0, 1].include?(content_filenames.size)
raise "Found #{content_filenames.size} content files for #{basename}; expected 0 or 1"
end
@@ -87,7 +87,7 @@ def filename_for(base_filename, ext)
# Returns the identifier derived from the given filename, first stripping
# the given directory name off the filename.
def identifier_for_filename(filename)
if config[:identifier_style] == 'full'
if config[:identifier_type] == 'full'
return Nanoc::Identifier.new(filename, style: :full)
end
@@ -61,7 +61,7 @@ def filename_for(base_filename, ext)
# See {Nanoc::DataSources::Filesystem#identifier_for_filename}.
def identifier_for_filename(filename)
if config[:identifier_style] == 'full'
if config[:identifier_type] == 'full'
return Nanoc::Identifier.new(filename, style: :full)
end
@@ -2,7 +2,7 @@
describe Nanoc::Identifier do
describe '#initialize' do
context 'stripped style' do
context 'legacy style' do
it 'does not convert already clean paths' do
expect(described_class.new('/foo/bar/').to_s).to eql('/foo/bar/')
end
@@ -59,7 +59,7 @@
subject { identifier.inspect }
it { should == '<Nanoc::Identifier style=stripped "/foo/bar/">' }
it { should == '<Nanoc::Identifier style=legacy "/foo/bar/">' }
end
describe '#== and #eql?' do
@@ -197,7 +197,7 @@
describe '#with_ext' do
subject { identifier.with_ext(ext) }
context 'stripped style' do
context 'legacy style' do
let(:identifier) { described_class.new('/foo/') }
let(:ext) { 'html' }
@@ -266,7 +266,7 @@
describe '#without_ext' do
subject { identifier.without_ext }
context 'stripped style' do
context 'legacy style' do
let(:identifier) { described_class.new('/foo/') }
it 'raises an error' do
@@ -181,7 +181,7 @@ def test_passthrough_with_full_identifiers
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
io << ' identifier_style: full' << "\n"
io << ' identifier_type: full' << "\n"
end
# Create rules
@@ -287,7 +287,7 @@ def test_outdated_if_config_outdated
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
io << ' identifier_style: stripped' << "\n"
io << ' identifier_type: legacy' << "\n"
end
end
View
@@ -185,7 +185,7 @@ def test_setup_child_parent_links
FileUtils.mkdir_p('content/parent')
FileUtils.mkdir_p('content/parent/bar')
data = File.read('nanoc.yaml').sub('identifier_style: full', 'identifier_style: stripped')
data = File.read('nanoc.yaml').sub('identifier_type: full', 'identifier_type: legacy')
File.open('nanoc.yaml', 'w') { |io| io << data }
File.open('content/parent.md', 'w') { |io| io << 'asdf' }
@@ -76,7 +76,7 @@ def test_default_encoding
io.write("data_sources:\n")
io.write(" -\n")
io.write(" type: filesystem_unified\n")
io.write(" identifier_style: full\n")
io.write(" identifier_type: full\n")
end
site = Nanoc::Int::Site.new('.')
site.compile
@@ -32,7 +32,7 @@ def test_run_with_yes
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
io << ' identifier_style: stripped' << "\n"
io << ' identifier_type: legacy' << "\n"
end
FileUtils.mkdir_p('output2')
@@ -80,7 +80,7 @@ def test_run_with_exclude
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
io << ' identifier_style: stripped' << "\n"
io << ' identifier_type: legacy' << "\n"
end
FileUtils.mkdir_p('output')
@@ -98,7 +98,7 @@ def test_all_split_files_in_with_multiple_dirs
def test_all_split_files_in_with_same_extensions
# Create data source
config = { identifier_style: 'full' }
config = { identifier_type: 'full' }
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, config)
# Write sample files
@@ -75,7 +75,7 @@ def ==(other)
def test_load_objects_with_same_extensions
# Create data source
data_source = new_data_source({ identifier_style: 'full' })
data_source = new_data_source({ identifier_type: 'full' })
# Create a fake class
klass = Class.new do
@@ -133,7 +133,7 @@ def test_load_binary_layouts
def test_identifier_for_filename_with_full_style_identifier
# Create data source
data_source = new_data_source({ identifier_style: 'full' })
data_source = new_data_source({ identifier_type: 'full' })
# Get input and expected output
expected = {
View
@@ -108,7 +108,7 @@ def with_site(params = {})
io << 'data_sources:' << "\n"
io << ' -' << "\n"
io << ' type: filesystem_unified' << "\n"
io << ' identifier_style: stripped' << "\n"
io << ' identifier_type: legacy' << "\n"
end
File.open('Rules', 'w') { |io| io.write(rules_content) }
ProTip! Use n and p to navigate between commits in a pull request.