Class: Lono::Script::Build
Constant Summary
Constants inherited from Base
Lono::Script::Base::SCRIPTS_INFO_PATH
Class Method Summary collapse
-
.scripts_name ⇒ Object
Only avaialble after script has been built.
Instance Method Summary collapse
- #create_tarball ⇒ Object
-
#md5sum ⇒ Object
cache this because the file will get removed.
-
#rename_with_md5! ⇒ Object
Apppend a md5 to file after it’s been created and moves it to output/scripts/scripts-.tgz.
- #reset ⇒ Object
- #run ⇒ Object
- #save_scripts_info(scripts_name) ⇒ Object
-
#scripts_name ⇒ Object
Only avaialble after script has been built.
- #sh(command) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Lono::Script::Base
Class Method Details
.scripts_name ⇒ Object
Only avaialble after script has been built.
7 8 9 |
# File 'lib/lono/script/build.rb', line 7 def self.scripts_name new.scripts_name end |
Instance Method Details
#create_tarball ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lono/script/build.rb', line 36 def create_tarball # https://apple.stackexchange.com/questions/14980/why-are-dot-underscore-files-created-and-how-can-i-avoid-them # using system to avoid displaying command system "cd app && dot_clean ." if system("type dot_clean > /dev/null 2>&1") # https://serverfault.com/questions/110208/different-md5sums-for-same-tar-contents # Using tar czf directly results in a new m5sum each time because the gzip # timestamp is included. So using: tar -c ... | gzip -n sh "cd app && tar -c scripts | gzip -n > scripts.tgz" # temporary app/scripts.tgz file rename_with_md5! end |
#md5sum ⇒ Object
cache this because the file will get removed
64 65 66 |
# File 'lib/lono/script/build.rb', line 64 def md5sum @md5sum ||= Digest::MD5.file("app/scripts.tgz").to_s[0..7] end |
#rename_with_md5! ⇒ Object
Apppend a md5 to file after it’s been created and moves it to output/scripts/scripts-.tgz
51 52 53 54 55 56 |
# File 'lib/lono/script/build.rb', line 51 def rename_with_md5! md5_path = "output/scripts/scripts-#{md5sum}.tgz" FileUtils.mkdir_p(File.dirname(md5_path)) FileUtils.mv("app/scripts.tgz", md5_path) md5_path end |
#reset ⇒ Object
32 33 34 |
# File 'lib/lono/script/build.rb', line 32 def reset FileUtils.rm_f(SCRIPTS_INFO_PATH) end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lono/script/build.rb', line 11 def run Lono::ProjectChecker.check reset if Dir["#{Lono.root}/app/scripts/*"].empty? puts "No detected app/scripts" return else puts "Detected app/scripts" end puts "Tarballing app/scripts folder to scripts.tgz" tarball_path = create_tarball save_scripts_info(tarball_path) puts "Tarball created at #{tarball_path}" end |
#save_scripts_info(scripts_name) ⇒ Object
58 59 60 61 |
# File 'lib/lono/script/build.rb', line 58 def save_scripts_info(scripts_name) FileUtils.mkdir_p(File.dirname(SCRIPTS_INFO_PATH)) IO.write(SCRIPTS_INFO_PATH, scripts_name) end |
#scripts_name ⇒ Object
Only avaialble after script has been built.
28 29 30 |
# File 'lib/lono/script/build.rb', line 28 def scripts_name IO.read(SCRIPTS_INFO_PATH).strip end |
#sh(command) ⇒ Object
68 69 70 71 |
# File 'lib/lono/script/build.rb', line 68 def sh(command) puts "=> #{command}" system command end |