class Besturder

Public Instance Methods

main() click to toggle source
# File lib/besturder.rb, line 22
def main
        if File.exist? $JSONFILE then
                json = JSON.parse File.read $JSONFILE
                dependencies = json["dependencies"]
                if dependencies.size != 0 then
                        Dir.mkdir "js"  unless Dir.exist? "js"
                        Dir.mkdir "css" unless Dir.exist? "css"
                        dependencies.each do |value|
                                value.downcase!
                                download(value) if $PACKS.keys.include? value
                                puts "The dependency #{value} doesn't exist" unless $PACKS.keys.include? value
                        end
                else
                        puts "You don't have dependencies in your #{$JSONFILE}"
                end
        else
                print "the file #{$JSONFILE} doesn't exist, do you want create it?[Y/N] "
                s_n = gets.chomp
                if s_n.upcase == "Y" then
                        print "\n  Write the dependencies (separated by commas and without spaces): "
                        dependencia = gets.chomp
                        dependencia = dependencia.split(",")
                        dependencia.each { |a| a.downcase! }
                        json = {dependencies:dependencia}
                        json = JSON.pretty_generate json
                        file = File.open("#{$JSONFILE}", "w") do |b|
                                b << json
                        end
                        puts "File created without errors!"
                else
                        exit
                end
        end
end
singleinstall(key) click to toggle source
# File lib/besturder.rb, line 56
def singleinstall(key)
        packs = JSON.parse(File.read("#{File.expand_path(File.dirname(__FILE__))}/packs.json"))
        dir = packs[key]["dir"]
        dir.each_index do |i|
                unless File.exist? dir[i]
                        dirsplit = dir[i].split '/'
                        dir0 = dirsplit[0]
                        Dir.mkdir dir0 unless Dir.exist? dir0
                        download(key)
                else
                        puts "The dependency #{key} is already installed"
                end
        end
end