Class: Wad::Compiler
- Inherits:
-
Object
- Object
- Wad::Compiler
- Defined in:
- lib/wad/compiler.rb
Instance Attribute Summary collapse
-
#bundle ⇒ Object
readonly
Returns the value of attribute bundle.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #compile ⇒ Object
- #copy_files(target) ⇒ Object
- #empty(target) ⇒ Object
-
#initialize(root) ⇒ Compiler
constructor
Constructs a new compiler which will do its work in root/vendor, copying vendor/bundle to vendor/lib.
Constructor Details
Instance Attribute Details
#bundle ⇒ Object (readonly)
Returns the value of attribute bundle.
17 18 19 |
# File 'lib/wad/compiler.rb', line 17 def bundle @bundle end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
16 17 18 |
# File 'lib/wad/compiler.rb', line 16 def reporter @reporter end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
15 16 17 |
# File 'lib/wad/compiler.rb', line 15 def root @root end |
Instance Method Details
#bundle_install ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/wad/compiler.rb', line 44 def bundle_install status = false # declare local var reporter.report_bundle_install do status = bundle.install do |line| reporter.report_bundle_install_line(line) end end status end |
#compile ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/wad/compiler.rb', line 30 def compile target = Target.new(root, 'vendor/lib', reporter) empty(target) bundle_install or raise "Please fix bundler failures first." copy_files(target) end |
#copy_files(target) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/wad/compiler.rb', line 56 def copy_files target reporter.report_copy_phase(target) # my editor messes up highlighting upon encountering 'gem'... so ghem it is. each_gem do |ghem| reporter.report_copy_for(ghem) do ghem.each_lib_file do |file| # We can't 'copy' directories next if file.directory? file.copy(target) end end end end |
#empty(target) ⇒ Object
38 39 40 41 42 |
# File 'lib/wad/compiler.rb', line 38 def empty target reporter.(target) # Danger. FileUtils.rm_rf(target.path) end |