Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
250 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require 'hamster' | ||
|
||
module Nanoc::Int | ||
# Creates checksums for given objects. | ||
# | ||
|
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
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
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,7 +1,12 @@ | ||
module Nanoc | ||
class PostCompileItemView < Nanoc::ItemWithRepsView | ||
# @deprecated Use {#modified_reps} instead | ||
def modified | ||
reps.select { |rep| rep.unwrap.modified } | ||
modified_reps | ||
end | ||
|
||
def modified_reps | ||
reps.select { |rep| rep.unwrap.modified? } | ||
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 |
---|---|---|
|
@@ -23,5 +23,9 @@ def unwrap | |
def frozen? | ||
unwrap.frozen? | ||
end | ||
|
||
def inspect | ||
"<#{self.class}>" | ||
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
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,4 +1,19 @@ | ||
# FIXME: fix name | ||
describe Nanoc::ItemCollectionWithRepsView do | ||
let(:view_class) { Nanoc::ItemWithRepsView } | ||
it_behaves_like 'an identifiable collection' | ||
|
||
describe '#inspect' do | ||
let(:wrapped) do | ||
Nanoc::Int::IdentifiableCollection.new(config) | ||
end | ||
|
||
let(:view) { described_class.new(wrapped, view_context) } | ||
let(:view_context) { double(:view_context) } | ||
let(:config) { { string_pattern_type: 'glob' } } | ||
|
||
subject { view.inspect } | ||
|
||
it { is_expected.to eql('<Nanoc::ItemCollectionWithRepsView>') } | ||
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
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,4 +1,18 @@ | ||
describe Nanoc::LayoutCollectionView do | ||
let(:view_class) { Nanoc::LayoutView } | ||
it_behaves_like 'an identifiable collection' | ||
|
||
describe '#inspect' do | ||
let(:wrapped) do | ||
Nanoc::Int::IdentifiableCollection.new(config) | ||
end | ||
|
||
let(:view) { described_class.new(wrapped, view_context) } | ||
let(:view_context) { double(:view_context) } | ||
let(:config) { { string_pattern_type: 'glob' } } | ||
|
||
subject { view.inspect } | ||
|
||
it { is_expected.to eql('<Nanoc::LayoutCollectionView>') } | ||
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
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,11 +1,16 @@ | ||
describe Nanoc::MutableConfigView do | ||
describe '#[]=' do | ||
let(:config) { {} } | ||
let(:view) { described_class.new(config, nil) } | ||
let(:config) { {} } | ||
let(:view) { described_class.new(config, nil) } | ||
|
||
describe '#[]=' do | ||
it 'sets attributes' do | ||
view[:awesomeness] = 'rather high' | ||
expect(config[:awesomeness]).to eq('rather high') | ||
end | ||
end | ||
|
||
describe '#inspect' do | ||
subject { view.inspect } | ||
it { is_expected.to eql('<Nanoc::MutableConfigView>') } | ||
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
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,4 +1,13 @@ | ||
describe Nanoc::MutableLayoutView do | ||
let(:entity_class) { Nanoc::Int::Layout } | ||
it_behaves_like 'a mutable document view' | ||
|
||
describe '#inspect' do | ||
let(:item) { Nanoc::Int::Item.new('content', {}, '/asdf/') } | ||
let(:view) { described_class.new(item, nil) } | ||
|
||
subject { view.inspect } | ||
|
||
it { is_expected.to eql('<Nanoc::MutableLayoutView identifier=/asdf/>') } | ||
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
describe Nanoc::PostCompileItemView do | ||
shared_examples 'a method that returns modified reps only' do | ||
let(:item) { Nanoc::Int::Item.new('blah', {}, '/foo.md') } | ||
let(:rep_a) { Nanoc::Int::ItemRep.new(item, :no_mod) } | ||
let(:rep_b) { Nanoc::Int::ItemRep.new(item, :modded).tap { |r| r.modified = true } } | ||
|
||
let(:reps) do | ||
Nanoc::Int::ItemRepRepo.new.tap do |reps| | ||
reps << rep_a | ||
reps << rep_b | ||
end | ||
end | ||
|
||
let(:view_context) { double(:view_context, reps: reps) } | ||
let(:view) { described_class.new(item, view_context) } | ||
|
||
it 'returns only modified items' do | ||
expect(subject.size).to eq(1) | ||
expect(subject.map(&:name)).to eq(%i(modded)) | ||
end | ||
|
||
it 'returns an array' do | ||
expect(subject.class).to eql(Array) | ||
end | ||
end | ||
|
||
describe '#modified_reps' do | ||
subject { view.modified_reps } | ||
it_behaves_like 'a method that returns modified reps only' | ||
end | ||
|
||
describe '#modified' do | ||
subject { view.modified } | ||
it_behaves_like 'a method that returns modified reps only' | ||
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
describe 'GH-882', site: true, stdio: true do | ||
before do | ||
File.write('content/foo.md', 'I am foo!') | ||
File.write('content/bar.md', 'I am bar!') | ||
|
||
File.write('Rules', <<EOS) | ||
compile '/**/*' do | ||
write item.identifier.without_ext + '.html' | ||
end | ||
postprocess do | ||
modified_reps = items.flat_map(&:modified) | ||
modified_reps.each do |rep| | ||
puts "Modified: \#{rep.item.identifier} - \#{rep.name}" | ||
end | ||
end | ||
EOS | ||
end | ||
|
||
example do | ||
Nanoc::CLI.run(%w(compile)) | ||
|
||
File.write('content/bar.md', 'I am bar! Modified!') | ||
expect { Nanoc::CLI.run(%w(compile)) }.to output(%r{^Modified: /bar.md - default$}).to_stdout | ||
|
||
File.write('content/bar.md', 'I am bar! Modified again!') | ||
expect { Nanoc::CLI.run(%w(compile)) }.not_to output(%r{^Modified: /foo.md - default$}).to_stdout | ||
end | ||
end |
Oops, something went wrong.