run_tasks 1.2.1 → 1.2.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.
- checksums.yaml +4 -4
 - data/src/run.rb +51 -26
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 55d34286c7c424f5bb48204f7b237e7ae844f1a1dd3829cd2b75191597ba5b79
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5801a9e3917159b46a0cb3ff1990e7457d818171ebc54a8203597af60e1b9a74
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 55de0b11daec5bbbee761655371805af0ee927a5fb39a79156f8de4db643f87eb9770822401d4907e35d6b192156484715ddfffb10f8a195fd6b31909fe4f6bc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3850279419812cc7b24b5db29b90cf99f00e5a60d07f90dac4e5d05e2cc56926a30630c21082b197b2a85688f36e2180a4a794db80f6aaa7bc2e1852ee863d7a
         
     | 
    
        data/src/run.rb
    CHANGED
    
    | 
         @@ -7,9 +7,16 @@ require "readline" 
     | 
|
| 
       7 
7 
     | 
    
         
             
            require "rubygems"
         
     | 
| 
       8 
8 
     | 
    
         
             
            require "securerandom"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
            ##########################################################################################
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            GEMSPEC_PATH = "#{__dir__}/../run_tasks.gemspec"
         
     | 
| 
      
 13 
     | 
    
         
            +
            GEM = if File.exist?(GEMSPEC_PATH)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    Gem::Specification::load(GEMSPEC_PATH) # Development.
         
     | 
| 
      
 15 
     | 
    
         
            +
                  else
         
     | 
| 
      
 16 
     | 
    
         
            +
                    Gem::Specification::find_by_name("run_tasks") rescue nil # Production.
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
            VERSION = GEM&.version
         
     | 
| 
      
 19 
     | 
    
         
            +
            HOMEPAGE = GEM&.homepage
         
     | 
| 
       13 
20 
     | 
    
         | 
| 
       14 
21 
     | 
    
         
             
            ##########################################################################################
         
     | 
| 
       15 
22 
     | 
    
         | 
| 
         @@ -62,11 +69,15 @@ end 
     | 
|
| 
       62 
69 
     | 
    
         
             
            # Define a task.
         
     | 
| 
       63 
70 
     | 
    
         
             
            def task(name, help = "", &block)
         
     | 
| 
       64 
71 
     | 
    
         
             
              if !name.is_a?(Symbol)
         
     | 
| 
       65 
     | 
    
         
            -
                puts 
     | 
| 
      
 72 
     | 
    
         
            +
                puts
         
     | 
| 
      
 73 
     | 
    
         
            +
                puts "First task parameter must be a symbol".red
         
     | 
| 
      
 74 
     | 
    
         
            +
                puts
         
     | 
| 
       66 
75 
     | 
    
         
             
                exit 6
         
     | 
| 
       67 
76 
     | 
    
         
             
              end
         
     | 
| 
       68 
77 
     | 
    
         
             
              if !help.is_a?(String)
         
     | 
| 
       69 
     | 
    
         
            -
                puts 
     | 
| 
      
 78 
     | 
    
         
            +
                puts
         
     | 
| 
      
 79 
     | 
    
         
            +
                puts "Second task parameter must be a string".red
         
     | 
| 
      
 80 
     | 
    
         
            +
                puts
         
     | 
| 
       70 
81 
     | 
    
         
             
                exit 6
         
     | 
| 
       71 
82 
     | 
    
         
             
              end
         
     | 
| 
       72 
83 
     | 
    
         
             
              @tasks.store(name, { :help => help, :block => block })
         
     | 
| 
         @@ -102,8 +113,10 @@ def require_remote(uri) 
     | 
|
| 
       102 
113 
     | 
    
         
             
              end
         
     | 
| 
       103 
114 
     | 
    
         
             
              eval File.read(cache_path)
         
     | 
| 
       104 
115 
     | 
    
         
             
            rescue => error
         
     | 
| 
      
 116 
     | 
    
         
            +
              puts
         
     | 
| 
       105 
117 
     | 
    
         
             
              puts "Unable to load #{uri}:".red
         
     | 
| 
       106 
118 
     | 
    
         
             
              puts "#{error.class}: #{error.message}".red
         
     | 
| 
      
 119 
     | 
    
         
            +
              puts
         
     | 
| 
       107 
120 
     | 
    
         
             
              exit 8
         
     | 
| 
       108 
121 
     | 
    
         
             
            end
         
     | 
| 
       109 
122 
     | 
    
         | 
| 
         @@ -117,14 +130,18 @@ end 
     | 
|
| 
       117 
130 
     | 
    
         
             
            RUNFILE = "Runfile.rb"
         
     | 
| 
       118 
131 
     | 
    
         | 
| 
       119 
132 
     | 
    
         
             
            if !File.exists?(RUNFILE)
         
     | 
| 
       120 
     | 
    
         
            -
              puts 
     | 
| 
      
 133 
     | 
    
         
            +
              puts
         
     | 
| 
      
 134 
     | 
    
         
            +
              puts "#{RUNFILE} does not exist".red
         
     | 
| 
      
 135 
     | 
    
         
            +
              puts
         
     | 
| 
       121 
136 
     | 
    
         
             
              exit 7
         
     | 
| 
       122 
137 
     | 
    
         
             
            end
         
     | 
| 
       123 
138 
     | 
    
         | 
| 
       124 
139 
     | 
    
         
             
            begin
         
     | 
| 
       125 
140 
     | 
    
         
             
              require "./#{RUNFILE}"
         
     | 
| 
       126 
141 
     | 
    
         
             
            rescue SyntaxError
         
     | 
| 
      
 142 
     | 
    
         
            +
              puts
         
     | 
| 
       127 
143 
     | 
    
         
             
              puts "The Runfile contains a syntax error.".red
         
     | 
| 
      
 144 
     | 
    
         
            +
              puts
         
     | 
| 
       128 
145 
     | 
    
         
             
              exit 5
         
     | 
| 
       129 
146 
     | 
    
         
             
            end
         
     | 
| 
       130 
147 
     | 
    
         | 
| 
         @@ -133,7 +150,11 @@ end 
     | 
|
| 
       133 
150 
     | 
    
         
             
            # Show the help screen if there is no provided task, or if it's explicitly requested.
         
     | 
| 
       134 
151 
     | 
    
         
             
            if ARGV.size == 0 || (ARGV.size == 1 && ARGV[0] == "help")
         
     | 
| 
       135 
152 
     | 
    
         
             
              puts
         
     | 
| 
       136 
     | 
    
         
            -
               
     | 
| 
      
 153 
     | 
    
         
            +
              if VERSION
         
     | 
| 
      
 154 
     | 
    
         
            +
                puts " Run v#{VERSION}".bright_blue
         
     | 
| 
      
 155 
     | 
    
         
            +
              else
         
     | 
| 
      
 156 
     | 
    
         
            +
                puts " Run".bright_blue
         
     | 
| 
      
 157 
     | 
    
         
            +
              end
         
     | 
| 
       137 
158 
     | 
    
         
             
              puts
         
     | 
| 
       138 
159 
     | 
    
         
             
              # Compute the max task names size.
         
     | 
| 
       139 
160 
     | 
    
         
             
              max_size = @tasks.keys.reduce(0) do |max, name|
         
     | 
| 
         @@ -148,32 +169,36 @@ if ARGV.size == 0 || (ARGV.size == 1 && ARGV[0] == "help") 
     | 
|
| 
       148 
169 
     | 
    
         
             
            end
         
     | 
| 
       149 
170 
     | 
    
         | 
| 
       150 
171 
     | 
    
         
             
            # Verify the latest release version.
         
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
               
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
                 
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
      
 172 
     | 
    
         
            +
            if VERSION && HOMEPAGE
         
     | 
| 
      
 173 
     | 
    
         
            +
              Thread.new do
         
     | 
| 
      
 174 
     | 
    
         
            +
                contents = URI.parse("#{HOMEPAGE}/master/run.gemspec")
         
     | 
| 
      
 175 
     | 
    
         
            +
                              .open
         
     | 
| 
      
 176 
     | 
    
         
            +
                              .read
         
     | 
| 
      
 177 
     | 
    
         
            +
                version = /^\s*s.version\s*=\s*"(.+?)"\s*$/.match(contents)
         
     | 
| 
      
 178 
     | 
    
         
            +
                if !version.nil?
         
     | 
| 
      
 179 
     | 
    
         
            +
                  next if File.exists?("/tmp/run_dismiss_#{version}")
         
     | 
| 
      
 180 
     | 
    
         
            +
                  current = VERSION.split "."
         
     | 
| 
      
 181 
     | 
    
         
            +
                  latest = version[1].split "."
         
     | 
| 
      
 182 
     | 
    
         
            +
                  if current[0].to_i < latest[0].to_i ||
         
     | 
| 
      
 183 
     | 
    
         
            +
                    current[1].to_i < latest[1].to_i ||
         
     | 
| 
      
 184 
     | 
    
         
            +
                    current[2].to_i < latest[2].to_i
         
     | 
| 
      
 185 
     | 
    
         
            +
                    puts "New ".cyan + version[1].yellow + " version released!".cyan
         
     | 
| 
      
 186 
     | 
    
         
            +
                    puts
         
     | 
| 
      
 187 
     | 
    
         
            +
                    puts "You can upgrade with:".cyan + "gem update run_tasks".yellow
         
     | 
| 
      
 188 
     | 
    
         
            +
                    puts
         
     | 
| 
      
 189 
     | 
    
         
            +
                    File.write "/tmp/run_dismiss_#{version}", ""
         
     | 
| 
      
 190 
     | 
    
         
            +
                  end
         
     | 
| 
       168 
191 
     | 
    
         
             
                end
         
     | 
| 
      
 192 
     | 
    
         
            +
              rescue
         
     | 
| 
       169 
193 
     | 
    
         
             
              end
         
     | 
| 
       170 
     | 
    
         
            -
            rescue
         
     | 
| 
       171 
194 
     | 
    
         
             
            end
         
     | 
| 
       172 
195 
     | 
    
         | 
| 
       173 
196 
     | 
    
         
             
            # Run the requested task.
         
     | 
| 
       174 
197 
     | 
    
         
             
            name = ARGV[0].to_sym
         
     | 
| 
       175 
198 
     | 
    
         
             
            if !@tasks.include?(name)
         
     | 
| 
       176 
     | 
    
         
            -
              puts 
     | 
| 
      
 199 
     | 
    
         
            +
              puts
         
     | 
| 
      
 200 
     | 
    
         
            +
              puts "Unknown '#{name}' task".red
         
     | 
| 
      
 201 
     | 
    
         
            +
              puts
         
     | 
| 
       177 
202 
     | 
    
         
             
              exit 2
         
     | 
| 
       178 
203 
     | 
    
         
             
            end
         
     | 
| 
       179 
204 
     | 
    
         
             
            begin
         
     |