Class: Tipsy::Runners::Compiler
- Inherits:
-
Object
- Object
- Tipsy::Runners::Compiler
- Includes:
- Utils::System
- Defined in:
- lib/tipsy/runners/compiler.rb
Defined Under Namespace
Classes: MockRequest, MockResponse
Instance Attribute Summary collapse
-
#dest_path ⇒ Object
readonly
Returns the value of attribute dest_path.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#source_path ⇒ Object
readonly
Returns the value of attribute source_path.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(args, site) ⇒ Compiler
constructor
A new instance of Compiler.
- #requested_compilers(args) ⇒ Object
- #skip_file?(src) ⇒ Boolean (also: #skip_path?)
Methods included from Utils::System
#copy_file, #copy_folder, #copy_tree, #empty_dir?, #enumerate_tree, #excluded?, #excludes, #excludes=, #log_action, #make_file, #mkdir_p, #normalize_path, #rm_rf, #unlink
Constructor Details
#initialize(args, site) ⇒ Compiler
Returns a new instance of Compiler.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tipsy/runners/compiler.rb', line 11 def initialize(args, site) ENV['TIPSY_ENV'] = "compile" @site = site @source_path = normalize_path(config.public_path) @dest_path = normalize_path(config.compile_to) excluded = [excludes, config.compile.preserve].flatten.uniq @_excludes = excluded clean_existing! requested_compilers(args).each do |m| send(:"compile_#{m}!") end cleanup! end |
Instance Attribute Details
#dest_path ⇒ Object (readonly)
Returns the value of attribute dest_path.
9 10 11 |
# File 'lib/tipsy/runners/compiler.rb', line 9 def dest_path @dest_path end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
9 10 11 |
# File 'lib/tipsy/runners/compiler.rb', line 9 def scope @scope end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
9 10 11 |
# File 'lib/tipsy/runners/compiler.rb', line 9 def site @site end |
#source_path ⇒ Object (readonly)
Returns the value of attribute source_path.
9 10 11 |
# File 'lib/tipsy/runners/compiler.rb', line 9 def source_path @source_path end |
Instance Method Details
#config ⇒ Object
28 29 30 |
# File 'lib/tipsy/runners/compiler.rb', line 28 def config Tipsy::Site.config end |
#requested_compilers(args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tipsy/runners/compiler.rb', line 32 def requested_compilers(args) args = [args].flatten.compact return [:public, :images, :assets, :templates] if args.empty? args.map!{ |a| a.to_s.strip.gsub(/^[-]+/, '') } comps = [] comps.push('templates') if args.include?('html') args.each do |arg| next unless self.private_methods.include?(:"compile_#{arg.to_s}!") comps << arg end comps end |
#skip_file?(src) ⇒ Boolean Also known as: skip_path?
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tipsy/runners/compiler.rb', line 49 def skip_file?(src) return false unless scope == :clean || scope == :public if scope == :public checks = config.compile.skip relative = ::Pathname.new(src).relative_path_from(::Pathname.new(source_path)) reldir = relative.dirname.to_s return checks.detect{ |path| path == src || path == relative.to_s || reldir.to_s == path } end config.compile.preserve.detect do |path| relative = src.to_s.gsub(Tipsy::Site.public_path, '').sub(/^\//, '') File.basename(src) == path || relative == path end end |