Skip to content

Commit

Permalink
Merge c7ccc10 into 1592d8f
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Oct 29, 2017
2 parents 1592d8f + c7ccc10 commit 96c436d
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 26 deletions.
3 changes: 0 additions & 3 deletions .rspec

This file was deleted.

3 changes: 3 additions & 0 deletions .rspec-nanoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r ./spec/spec_helper_nanoc.rb
--format Fuubar
--color
3 changes: 3 additions & 0 deletions .rspec-nanoc-live
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r ./spec/spec_helper_nanoc_live.rb
--format Fuubar
--color
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Security/MarshalLoad:

Security/Eval:
Exclude:
- 'nanoc.gemspec'
- 'test/**/*.rb'
- 'spec/**/*.rb'
- 'lib/nanoc/base/entities/code_snippet.rb'
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

source 'https://rubygems.org'

gemspec
gemspec name: 'nanoc'
gemspec name: 'nanoc-live'

group :devel do
gem 'codecov', require: false
Expand Down
28 changes: 25 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,43 @@ require 'rspec/core/rake_task'
require 'rake/testtask'
require 'coveralls/rake/task'

RuboCop::RakeTask.new(:rubocop)
### coverage

Coveralls::RakeTask.new

### style

RuboCop::RakeTask.new(:rubocop)

### test

Rake::TestTask.new(:test_all) do |t|
t.test_files = Dir['test/**/test_*.rb']
t.libs << 'test'
t.verbose = false
end

RSpec::Core::RakeTask.new(:spec) do |t|
### spec

RSpec::Core::RakeTask.new(:spec_nanoc) do |t|
t.verbose = true
t.rspec_opts =
'--options .rspec-nanoc ' \
'--exclude-pattern spec/nanoc/live/**/*_spec.rb'
end

RSpec::Core::RakeTask.new(:spec_nanoc_live) do |t|
t.verbose = false
t.rspec_opts = \
'--options .rspec-nanoc-live ' \
'--pattern spec/nanoc/live/**/*_spec.rb'
end

task test: %i[spec test_all rubocop]
task spec: %i[spec_nanoc spec_nanoc_live]

###

task test: %i[spec spec_nanoc_live test_all rubocop]
task test_ci: %i[test coveralls:push]

task default: :test
2 changes: 0 additions & 2 deletions lib/nanoc/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ def self.setup_commands

next if basename == 'nanoc'

next if basename == 'live' && !Nanoc::Feature.enabled?(Nanoc::Feature::LIVE_CMD)

cmd = load_command_at(cmd_filename)
add_command(cmd)
end
Expand Down
1 change: 0 additions & 1 deletion lib/nanoc/extra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module Nanoc::Extra
end

require_relative 'extra/link_collector.rb'
require_relative 'extra/live_recompiler'
require_relative 'extra/piper'
require_relative 'extra/jruby_nokogiri_warner'
require_relative 'extra/core_ext'
Expand Down
17 changes: 17 additions & 0 deletions lib/nanoc/live.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'nanoc'
require 'nanoc/cli'

module Nanoc
module Live
end
end

require_relative 'live/version'
require_relative 'live/live_recompiler'

Nanoc::CLI.after_setup do
cmd = Nanoc::CLI.load_command_at(__dir__ + '/live/command.rb', 'live')
Nanoc::CLI.root_command.add_command(cmd)
end
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run
Nanoc::CLI::Commands::View.new(options, [], self).run
end

Nanoc::Extra::LiveRecompiler.new(command_runner: self).run
Nanoc::Live::LiveRecompiler.new(command_runner: self).run
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Nanoc::Extra
module Nanoc::Live
class LiveRecompiler
def initialize(command_runner:)
@command_runner = command_runner
Expand Down
7 changes: 7 additions & 0 deletions lib/nanoc/live/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module Nanoc
module Live
VERSION = '0.0.1'
end
end
24 changes: 24 additions & 0 deletions nanoc-live.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require_relative 'lib/nanoc/version'
require_relative 'lib/nanoc/live/version'

Gem::Specification.new do |s|
s.name = 'nanoc-live'
s.version = Nanoc::Live::VERSION
s.homepage = 'http://nanoc.ws/'
s.summary = 'Live command for Nanoc'

s.author = 'Denis Defreyne'
s.email = 'denis@stoneship.org'
s.license = 'MIT'

all_files = `git ls-files -z`.split("\x0")
s.files = all_files.select { |fn| fn =~ %r{nanoc[_/-]live} }
s.require_paths = ['lib']

s.required_ruby_version = '>= 2.3.0'

s.add_runtime_dependency('listen', '~> 3.0')
s.add_runtime_dependency('slow_enumerator_tools', '~> 1.0')
end
11 changes: 11 additions & 0 deletions nanoc-live.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.rspec-nanoc-live
nanoc-live.gemspec
nanoc-live.manifest

lib/nanoc/live.rb
lib/nanoc/live/version.rb
lib/nanoc/live/command.rb
lib/nanoc/live/live_recompiler.rb

spec/nanoc/live/live_recompiler_spec.rb
spec/spec_helper_nanoc_live.rb
6 changes: 5 additions & 1 deletion nanoc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ ignored_files = %w[
Guardfile
]

gemspecs = Dir['nanoc-*.gemspec'].map { |fn| eval(File.read(fn), binding, fn) }
plugin_files = gemspecs.flat_map(&:files).uniq

Gem::Specification.new do |s|
s.name = 'nanoc'
s.version = Nanoc::VERSION
Expand All @@ -24,7 +27,8 @@ Gem::Specification.new do |s|
s.email = 'denis@stoneship.org'
s.license = 'MIT'

s.files = `git ls-files -z`.split("\x0") - ignored_files
all_files = `git ls-files -z`.split("\x0")
s.files = all_files - plugin_files - ignored_files
s.executables = ['nanoc']
s.require_paths = ['lib']

Expand Down
7 changes: 2 additions & 5 deletions nanoc.manifest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.rspec
.rspec-nanoc
.rubocop.yml
Appraisals
CODE_OF_CONDUCT.md
Expand Down Expand Up @@ -171,7 +171,6 @@ lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb
lib/nanoc/cli/commands/compile.rb
lib/nanoc/cli/commands/create-site.rb
lib/nanoc/cli/commands/deploy.rb
lib/nanoc/cli/commands/live.rb
lib/nanoc/cli/commands/nanoc.rb
lib/nanoc/cli/commands/prune.rb
lib/nanoc/cli/commands/shell.rb
Expand Down Expand Up @@ -202,7 +201,6 @@ lib/nanoc/extra/core_ext/pathname.rb
lib/nanoc/extra/core_ext/time.rb
lib/nanoc/extra/jruby_nokogiri_warner.rb
lib/nanoc/extra/link_collector.rb
lib/nanoc/extra/live_recompiler.rb
lib/nanoc/extra/parallel_collection.rb
lib/nanoc/extra/piper.rb
lib/nanoc/filters.rb
Expand Down Expand Up @@ -374,7 +372,6 @@ spec/nanoc/cli/stream_cleaners/utf8_spec.rb
spec/nanoc/data_sources/filesystem_spec.rb
spec/nanoc/deploying/fog_spec.rb
spec/nanoc/deploying/git_spec.rb
spec/nanoc/extra/live_recompiler_spec.rb
spec/nanoc/extra/parallel_collection_spec.rb
spec/nanoc/filters/asciidoctor_spec.rb
spec/nanoc/filters/colorize_syntax/rouge_spec.rb
Expand Down Expand Up @@ -463,7 +460,7 @@ spec/nanoc/telemetry/stopwatch_spec.rb
spec/nanoc/telemetry/summary_spec.rb
spec/nanoc/telemetry/table_spec.rb
spec/regression_filenames_spec.rb
spec/spec_helper.rb
spec/spec_helper_nanoc.rb

test/base/test_compiler.rb
test/base/test_dependency_tracker.rb
Expand Down
28 changes: 21 additions & 7 deletions spec/manifest_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
# frozen_string_literal: true

describe 'manifest', chdir: false do
let(:gem_names) do
Dir['*.gemspec'].map { |fn| fn.sub(/\.gemspec$/, '') }
end

let(:manifest_lines) do
File.readlines('nanoc.manifest').map(&:chomp).reject(&:empty?)
gem_names.each_with_object({}) do |gem_name, memo|
raw_lines = File.readlines(gem_name + '.manifest')
memo[gem_name] = raw_lines.map(&:chomp).reject(&:empty?)
end
end

let(:gemspec_lines) do
gemspec = eval(File.read('nanoc.gemspec'), binding, 'nanoc.gemspec')
gemspec.files
gem_names.each_with_object({}) do |gem_name, memo|
gemspec_filename = gem_name + '.gemspec'
gemspec = eval(File.read(gemspec_filename), binding, gemspec_filename)
memo[gem_name] = gemspec.files
end
end

it 'contains all files in gemspec' do
missing_from_manifest = gemspec_lines - manifest_lines
expect(missing_from_manifest).to be_empty, "Found files that appear in the gemspec, but not in the manifest: #{missing_from_manifest.join(', ')}"
gem_names.each do |gem_name|
missing_from_manifest = gemspec_lines.fetch(gem_name) - manifest_lines.fetch(gem_name)
expect(missing_from_manifest).to be_empty, "Found files that appear in the gemspec, but not in the manifest: #{missing_from_manifest.join(', ')}"
end
end

it 'contains no files not in gemspec' do
extra_in_manifest = manifest_lines - gemspec_lines
expect(extra_in_manifest).to be_empty, "Found files that appear in the manifest, but not in the gemspec: #{extra_in_manifest.join(', ')}"
gem_names.each do |gem_name|
extra_in_manifest = manifest_lines.fetch(gem_name) - gemspec_lines.fetch(gem_name)
expect(extra_in_manifest).to be_empty, "Found files that appear in the manifest, but not in the gemspec: #{extra_in_manifest.join(', ')}"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Nanoc::Extra::LiveRecompiler, site: true, stdio: true do
describe Nanoc::Live::LiveRecompiler, site: true, stdio: true do
it 'detects content changes' do
command = nil
command_runner = Nanoc::CLI::CommandRunner.new({}, [], command)
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb → spec/spec_helper_nanoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require 'nanoc'
require 'nanoc/cli'
require 'nanoc/spec'
require 'nanoc/live'

require 'ddbuffer'
require 'timecop'
Expand Down
59 changes: 59 additions & 0 deletions spec/spec_helper_nanoc_live.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

require 'simplecov'
SimpleCov.start

require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov

require 'nanoc/live'

require 'rspec/its'
require 'fuubar'

RSpec.configure do |c|
c.fuubar_progress_bar_options = {
format: '%c/%C |<%b>%i| %p%%',
}

c.around(:each) do |example|
Dir.mktmpdir('nanoc-test') do |dir|
Dir.chdir(dir) { example.run }
end
end

c.around(:each, chdir: false) do |example|
Dir.chdir(__dir__ + '/..')
example.run
end

c.before(:each) do
Nanoc::Int::NotificationCenter.reset
end

c.around(:each, stdio: true) do |example|
orig_stdout = $stdout
orig_stderr = $stderr

unless ENV['QUIET'] == 'false'
$stdout = StringIO.new
$stderr = StringIO.new
end

example.run

$stdout = orig_stdout
$stderr = orig_stderr
end

c.before(:each, site: true) do
FileUtils.mkdir_p('content')
FileUtils.mkdir_p('layouts')
FileUtils.mkdir_p('lib')
FileUtils.mkdir_p('output')

File.write('nanoc.yaml', '{}')

File.write('Rules', 'passthrough "/**/*"')
end
end

0 comments on commit 96c436d

Please sign in to comment.