sinatra-packrat 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/packrat +25 -8
 - metadata +2 -2
 
    
        data/bin/packrat
    CHANGED
    
    | 
         @@ -5,20 +5,37 @@ require "yaml" 
     | 
|
| 
       5 
5 
     | 
    
         
             
            config_path = ARGV[0]
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            unless File.exists? config_path
         
     | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
      
 8 
     | 
    
         
            +
              print "#{config_path} does not exist!"
         
     | 
| 
       9 
9 
     | 
    
         
             
              exit
         
     | 
| 
       10 
10 
     | 
    
         
             
            end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            config = YAML::load_file(config_path)
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            unless config["modules"] and config["modules"].respond_to? :each
         
     | 
| 
       15 
     | 
    
         
            -
               
     | 
| 
      
 15 
     | 
    
         
            +
              print "Config file requires a 'module' array"
         
     | 
| 
       16 
16 
     | 
    
         
             
              exit
         
     | 
| 
       17 
17 
     | 
    
         
             
            end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
            current_user = `whoami`.strip
         
     | 
| 
      
 20 
     | 
    
         
            +
            print "Please provide a username [#{current_user}]: \n"
         
     | 
| 
      
 21 
     | 
    
         
            +
            name = $stdin.gets.strip
         
     | 
| 
      
 22 
     | 
    
         
            +
            name = current_user if name.empty?
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       19 
25 
     | 
    
         
             
            config["modules"].each do |mod|
         
     | 
| 
       20 
26 
     | 
    
         
             
              next unless mod["git"]
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
              
         
     | 
| 
      
 28 
     | 
    
         
            +
              git_path_possibly_with_protocol = mod["git"]
         
     | 
| 
      
 29 
     | 
    
         
            +
              
         
     | 
| 
      
 30 
     | 
    
         
            +
              git_path_possibly_with_protocol = mod["git"]
         
     | 
| 
      
 31 
     | 
    
         
            +
              parts = git_path_possibly_with_protocol.split('://')
         
     | 
| 
      
 32 
     | 
    
         
            +
              
         
     | 
| 
      
 33 
     | 
    
         
            +
              protocol = parts.shift + '://' if parts.length > 1  
         
     | 
| 
      
 34 
     | 
    
         
            +
              git_path_without_protocol = parts.join('')
         
     | 
| 
      
 35 
     | 
    
         
            +
              
         
     | 
| 
      
 36 
     | 
    
         
            +
              full_git_path = "#{name}@#{git_path_without_protocol}"
         
     | 
| 
      
 37 
     | 
    
         
            +
              full_git_path = full_git_path.insert(0, protocol) if protocol
         
     | 
| 
      
 38 
     | 
    
         
            +
              
         
     | 
| 
       22 
39 
     | 
    
         
             
              if mod["path"]
         
     | 
| 
       23 
40 
     | 
    
         
             
                repo_path = mod["path"]
         
     | 
| 
       24 
41 
     | 
    
         
             
              else
         
     | 
| 
         @@ -28,11 +45,11 @@ config["modules"].each do |mod| 
     | 
|
| 
       28 
45 
     | 
    
         | 
| 
       29 
46 
     | 
    
         
             
              if File.directory? repo_path
         
     | 
| 
       30 
47 
     | 
    
         
             
                Dir.chdir repo_path do
         
     | 
| 
       31 
     | 
    
         
            -
                   
     | 
| 
       32 
     | 
    
         
            -
                  `git pull #{ 
     | 
| 
      
 48 
     | 
    
         
            +
                  print "Pulling from #{full_git_path} into #{repo_path} \n"
         
     | 
| 
      
 49 
     | 
    
         
            +
                  `git pull #{full_git_path} master`
         
     | 
| 
       33 
50 
     | 
    
         
             
                end
         
     | 
| 
       34 
51 
     | 
    
         
             
              else
         
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                `git clone #{ 
     | 
| 
      
 52 
     | 
    
         
            +
                print "Cloning #{full_git_path} into #{repo_path} \n"
         
     | 
| 
      
 53 
     | 
    
         
            +
                `git clone #{full_git_path} #{repo_path}`
         
     | 
| 
       37 
54 
     | 
    
         
             
              end
         
     | 
| 
       38 
     | 
    
         
            -
            end
         
     | 
| 
      
 55 
     | 
    
         
            +
            end if config["modules"].respond_to? :each
         
     |