Class: Linner::Bundler
- Inherits:
-
Object
- Object
- Linner::Bundler
- Defined in:
- lib/linner/bundler.rb
Defined Under Namespace
Classes: Bundle
Constant Summary collapse
- REPOSITORY =
File. "~/.linner/bundles"
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(env) ⇒ Bundler
constructor
A new instance of Bundler.
- #install ⇒ Object
- #perform ⇒ Object
Constructor Details
#initialize(env) ⇒ Bundler
Returns a new instance of Bundler.
16 17 18 19 20 21 22 |
# File 'lib/linner/bundler.rb', line 16 def initialize(env) @bundles = [] env.bundles.each do |name, props| @bundles << Bundle.new(name, props["version"], props["url"]) end @vendor = Pathname(".").join env.vendor_folder end |
Instance Method Details
#check ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/linner/bundler.rb', line 24 def check return [false, "Bundles didn't exsit!"] unless File.exist? REPOSITORY @bundles.each do |bundle| unless File.exist?(bundle.path) and File.exist?(File.join(@vendor, bundle.name)) return [false, "Bundle #{bundle.name} v#{bundle.version} didn't match!"] end end return [true, "Perfect bundled, ready to go!"] end |
#install ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/linner/bundler.rb', line 34 def install unless File.exist? REPOSITORY FileUtils.mkdir_p(REPOSITORY) end @bundles.each do |bundle| if bundle.version != "master" next if File.exist?(bundle.path) and File.exist?(File.join(@vendor, bundle.name)) end puts "Installing #{bundle.name} #{bundle.version}..." install_to_repository bundle if File.extname(bundle.path) == ".gz" link_and_extract_to_vendor bundle.path, File.join(@vendor, ".pkg", bundle.name, File.basename(bundle.path)), File.join(@vendor, bundle.name) else link_to_vendor bundle.path, File.join(@vendor, bundle.name) end end end |
#perform ⇒ Object
52 53 54 |
# File 'lib/linner/bundler.rb', line 52 def perform check and install end |