Skip to content

Commit

Permalink
[Command::Build] fix new flag --no-cache + add some more verbose logs
Browse files Browse the repository at this point in the history
refs #11
  • Loading branch information
Roman Kříž committed May 29, 2016
1 parent bbbbd44 commit 2b1d924
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/epuber/command/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(argv)
@should_check = argv.flag?('check', false)
@should_write = argv.flag?('write', false)
@release_version = argv.flag?('release', false)
@no_cache = argv.flag?('no-cache', false)
@use_cache = argv.flag?('cache', true)

super(argv)
end
Expand Down Expand Up @@ -82,7 +82,7 @@ def run
targets.each do |target|
compiler = Epuber::Compiler.new(book, target)
build_path = Epuber::Config.instance.build_path(target)
compiler.compile(build_path, check: @should_check, write: @should_write, verbose: verbose?, no_cache: @no_cache)
compiler.compile(build_path, check: @should_check, write: @should_write, verbose: verbose?, use_cache: @use_cache)
archive_path = compiler.archive(configuration_suffix: 'debug')

system(%(epubcheck "#{archive_path}")) if @should_check
Expand Down
4 changes: 2 additions & 2 deletions lib/epuber/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def initialize(book, target)
#
# @return [void]
#
def compile(build_folder, check: false, write: false, release: false, verbose: false, no_cache: false)
def compile(build_folder, check: false, write: false, release: false, verbose: false, use_cache: true)
@file_resolver = FileResolver.new(Config.instance.project_path, build_folder)
compilation_context.file_resolver = @file_resolver
compilation_context.should_check = check
compilation_context.should_write = write
compilation_context.release_build = release
compilation_context.verbose = verbose
compilation_context.no_cache = no_cache
compilation_context.use_cache = use_cache

self.class.globals_catcher.catch do
@build_folder = build_folder
Expand Down
4 changes: 2 additions & 2 deletions lib/epuber/compiler/compilation_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def perform_plugin_things(klass, source_type)

# @return [Bool]
#
attr_accessor :no_cache
attr_accessor :use_cache

# @return [Bool]
#
Expand All @@ -97,7 +97,7 @@ def debug?
end

def incremental_build?
!no_cache
use_cache
end

def initialize(book, target)
Expand Down
4 changes: 3 additions & 1 deletion lib/epuber/compiler/file_types/generated_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def process(compilation_context)

def write_generate(content)
if self.class.write_to_file?(content, final_destination_path)
UI.print_processing_debug_info("Writing generated content to #{pkg_destination_path}")
UI.print_processing_debug_info("#{pkg_destination_path}: Writing generated content")
self.class.write_to_file!(content, final_destination_path)
else
UI.print_processing_debug_info("#{pkg_destination_path}: Not writing to disk ... generated content is same")
end
end
end
Expand Down
14 changes: 9 additions & 5 deletions lib/epuber/compiler/file_types/source_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def process(_compilation_context)
# @return [Bool]
#
def source_file_up_to_date?
return false if compilation_context.no_cache
return false unless compilation_context.incremental_build?

source_db = compilation_context.source_file_database
source_db.up_to_date?(source_path)
Expand All @@ -53,7 +53,7 @@ def source_file_up_to_date?
# @return [Bool]
#
def destination_file_up_to_date?
return false if compilation_context.no_cache
return false unless compilation_context.incremental_build?

source_db = compilation_context.source_file_database
target_db = compilation_context.target_file_database
Expand Down Expand Up @@ -81,9 +81,9 @@ def update_metadata!
end

def default_file_copy
ok = destination_file_up_to_date? && destination_file_exist?

unless ok
if destination_file_up_to_date?
UI.print_processing_debug_info("Destination path #{pkg_destination_path} is up-to-date")
else
UI.print_processing_debug_info("Copying to #{pkg_destination_path}")
self.class.file_copy!(abs_source_path, final_destination_path)
end
Expand All @@ -95,13 +95,17 @@ def write_compiled(content)
if self.class.write_to_file?(content, final_destination_path)
UI.print_processing_debug_info("Writing compiled version to #{pkg_destination_path}")
self.class.write_to_file!(content, final_destination_path)
else
UI.print_processing_debug_info("Not writing to disk ... compiled version at #{pkg_destination_path} is same")
end
end

def write_processed(content)
if self.class.write_to_file?(content, final_destination_path)
UI.print_processing_debug_info("Writing processed version to #{pkg_destination_path}")
self.class.write_to_file!(content, final_destination_path)
else
UI.print_processing_debug_info("Not writing to disk ... processed version at #{pkg_destination_path} is same")
end
end
end
Expand Down

0 comments on commit 2b1d924

Please sign in to comment.