spud 0.1.7 → 0.1.8
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/lib/build_tools/spud/file_context.rb +12 -14
 - data/lib/build_tools/spud/rule_context.rb +3 -10
 - data/lib/build_tools/spud/spud.rb +4 -1
 - data/lib/shell.rb +24 -5
 - data/lib/spud.rb +1 -6
 - data/lib/version.rb +1 -1
 - 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: 11082937f67da737d314d222eccb34f438de26fa5d0bb94186b1f99d89d29705
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4f6965f11798cb8af28f4f298954efd5ba831e8c8387ce63f642f02cd112e7c6
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fd4916032c22a3ea7268b38e418742fc265c7ef87c55acb2571cbfb74d7897035e2b819c945dde94c26931cd2766ef39e81cf9e5141745e26b430c096a9483d6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9667b5d3c7f3baf7b0bdce2f2886ee501e00595478b76c40b7bd3106c6d5825eae4a28f8aaae941a759ff8f7e67b35f71a08220c96bfbe252b46b8f914e684d2
         
     | 
| 
         @@ -3,33 +3,31 @@ require_relative 'rule' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module Spud::BuildTools
         
     | 
| 
       4 
4 
     | 
    
         
             
              module SpudBuild
         
     | 
| 
       5 
5 
     | 
    
         
             
                class FileContext
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :__rules
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(spud, filename)
         
     | 
| 
       9 
     | 
    
         
            -
                    @ 
     | 
| 
       10 
     | 
    
         
            -
                    @ 
     | 
| 
       11 
     | 
    
         
            -
                    @ 
     | 
| 
      
 9 
     | 
    
         
            +
                    @__spud = spud
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @__filename = filename
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @__rules = {}
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def require_relative(name)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    require(name)
         
     | 
| 
       12 
16 
     | 
    
         
             
                  end
         
     | 
| 
       13 
17 
     | 
    
         | 
| 
       14 
18 
     | 
    
         
             
                  def rule(name, *args, &block)
         
     | 
| 
       15 
19 
     | 
    
         
             
                    files = args.select { |arg| arg.is_a?(String) }
         
     | 
| 
       16 
20 
     | 
    
         
             
                    deps = args.select { |arg| arg.is_a?(Hash) }.reduce({}) { |hash, dep| hash.merge(dep) }
         
     | 
| 
       17 
21 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                     
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
      
 22 
     | 
    
         
            +
                    prefix = @__filename == 'Spudfile' ? '' : "#{File.basename(@__filename, '.rb')}."
         
     | 
| 
      
 23 
     | 
    
         
            +
                    name = "#{prefix}#{name}"
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    @__rules[name] = Rule.new(@__spud, self, @__filename, name, files, deps, block)
         
     | 
| 
       20 
26 
     | 
    
         
             
                  end
         
     | 
| 
       21 
27 
     | 
    
         | 
| 
       22 
28 
     | 
    
         
             
                  def method_missing(name, *args, &block)
         
     | 
| 
       23 
29 
     | 
    
         
             
                    rule(name, *args, &block)
         
     | 
| 
       24 
30 
     | 
    
         
             
                  end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                  def prefix_rule(name)
         
     | 
| 
       27 
     | 
    
         
            -
                    "#{prefix}#{name}"
         
     | 
| 
       28 
     | 
    
         
            -
                  end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                  def prefix
         
     | 
| 
       31 
     | 
    
         
            -
                    @prefix ||= @filename == 'Spudfile' ? '' : "#{File.basename(@filename, '.rb')}."
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
       33 
31 
     | 
    
         
             
                end
         
     | 
| 
       34 
32 
     | 
    
         
             
              end
         
     | 
| 
       35 
33 
     | 
    
         
             
            end
         
     | 
| 
         @@ -22,11 +22,7 @@ module Spud::BuildTools 
     | 
|
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                  def sh?(cmd)
         
     | 
| 
       24 
24 
     | 
    
         
             
                    puts cmd
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                    out = Spud::Shell.cmd(cmd)
         
     | 
| 
       27 
     | 
    
         
            -
                    puts out unless out.empty?
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                    out
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Spud::Shell.new(cmd)
         
     | 
| 
       30 
26 
     | 
    
         
             
                  end
         
     | 
| 
       31 
27 
     | 
    
         | 
| 
       32 
28 
     | 
    
         
             
                  def shh(cmd)
         
     | 
| 
         @@ -37,10 +33,7 @@ module Spud::BuildTools 
     | 
|
| 
       37 
33 
     | 
    
         
             
                  end
         
     | 
| 
       38 
34 
     | 
    
         | 
| 
       39 
35 
     | 
    
         
             
                  def shh?(cmd)
         
     | 
| 
       40 
     | 
    
         
            -
                     
     | 
| 
       41 
     | 
    
         
            -
                    puts out unless out.empty?
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                    out
         
     | 
| 
      
 36 
     | 
    
         
            +
                    Spud::Shell.new(cmd)
         
     | 
| 
       44 
37 
     | 
    
         
             
                  end
         
     | 
| 
       45 
38 
     | 
    
         | 
| 
       46 
39 
     | 
    
         
             
                  def shhh(cmd)
         
     | 
| 
         @@ -51,7 +44,7 @@ module Spud::BuildTools 
     | 
|
| 
       51 
44 
     | 
    
         
             
                  end
         
     | 
| 
       52 
45 
     | 
    
         | 
| 
       53 
46 
     | 
    
         
             
                  def shhh?(cmd)
         
     | 
| 
       54 
     | 
    
         
            -
                    Spud::Shell. 
     | 
| 
      
 47 
     | 
    
         
            +
                    Spud::Shell.new(cmd, silent: true)
         
     | 
| 
       55 
48 
     | 
    
         
             
                  end
         
     | 
| 
       56 
49 
     | 
    
         | 
| 
       57 
50 
     | 
    
         
             
                  def invoke(name, *args, **kwargs)
         
     | 
| 
         @@ -14,9 +14,12 @@ module Spud::BuildTools 
     | 
|
| 
       14 
14 
     | 
    
         
             
                    filenames.each do |filename|
         
     | 
| 
       15 
15 
     | 
    
         
             
                      source = File.read(filename)
         
     | 
| 
       16 
16 
     | 
    
         
             
                      @ctx = FileContext.new(@spud, filename)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                      $LOAD_PATH << File.dirname(filename)
         
     | 
| 
       17 
19 
     | 
    
         
             
                      @ctx.instance_eval(source)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      $LOAD_PATH.pop
         
     | 
| 
       18 
21 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                      @rules.merge!(@ctx. 
     | 
| 
      
 22 
     | 
    
         
            +
                      @rules.merge!(@ctx.__rules)
         
     | 
| 
       20 
23 
     | 
    
         
             
                    end
         
     | 
| 
       21 
24 
     | 
    
         
             
                  end
         
     | 
| 
       22 
25 
     | 
    
         
             
                end
         
     | 
    
        data/lib/shell.rb
    CHANGED
    
    | 
         @@ -1,14 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'open3'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Spud
         
     | 
| 
       2 
4 
     | 
    
         
             
              class Shell < String
         
     | 
| 
       3 
5 
     | 
    
         
             
                attr_accessor :status
         
     | 
| 
       4 
6 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                def  
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 7 
     | 
    
         
            +
                def initialize(cmd, silent: false)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  @pid = nil
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @status = nil
         
     | 
| 
      
 10 
     | 
    
         
            +
                  output = StringIO.new
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  Open3.popen3(cmd) do |_, stdout, _, thread|
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @pid = thread.pid
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 16 
     | 
    
         
            +
                      while line = stdout.gets
         
     | 
| 
      
 17 
     | 
    
         
            +
                        puts line unless silent
         
     | 
| 
      
 18 
     | 
    
         
            +
                        output.puts line
         
     | 
| 
      
 19 
     | 
    
         
            +
                      end
         
     | 
| 
      
 20 
     | 
    
         
            +
                    rescue Interrupt
         
     | 
| 
      
 21 
     | 
    
         
            +
                      exit
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  @status = $?
         
     | 
| 
      
 26 
     | 
    
         
            +
                  super(output.string)
         
     | 
| 
       7 
27 
     | 
    
         
             
                end
         
     | 
| 
       8 
28 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                def  
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
       11 
     | 
    
         
            -
                  @status = status
         
     | 
| 
      
 29 
     | 
    
         
            +
                def kill!
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Process.kill('HUP', @pid)
         
     | 
| 
       12 
31 
     | 
    
         
             
                end
         
     | 
| 
       13 
32 
     | 
    
         
             
              end
         
     | 
| 
       14 
33 
     | 
    
         
             
            end
         
     | 
    
        data/lib/spud.rb
    CHANGED
    
    | 
         @@ -35,11 +35,6 @@ module Spud 
     | 
|
| 
       35 
35 
     | 
    
         
             
                rescue BuildTools::SpudBuild::ShellError => e
         
     | 
| 
       36 
36 
     | 
    
         
             
                  raise e if options[:debug]
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
                rescue Error => e
         
     | 
| 
       39 
     | 
    
         
            -
                  raise e if options[:debug]
         
     | 
| 
       40 
     | 
    
         
            -
                  puts e.message
         
     | 
| 
       41 
     | 
    
         
            -
                  exit 1
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
38 
     | 
    
         
             
                rescue => e
         
     | 
| 
       44 
39 
     | 
    
         
             
                  raise e if options[:debug]
         
     | 
| 
       45 
40 
     | 
    
         
             
                  puts e.message
         
     | 
| 
         @@ -118,7 +113,7 @@ module Spud 
     | 
|
| 
       118 
113 
     | 
    
         
             
                  help.puts 'options:'
         
     | 
| 
       119 
114 
     | 
    
         
             
                  help.puts '  -h, --help           show this help dialog dialog'
         
     | 
| 
       120 
115 
     | 
    
         
             
                  help.puts '  -v, --version        show spud version'
         
     | 
| 
       121 
     | 
    
         
            -
                  help.puts '  -w, --watch <files>   
     | 
| 
      
 116 
     | 
    
         
            +
                  help.puts '  -w, --watch <files>  watch files for changes'
         
     | 
| 
       122 
117 
     | 
    
         
             
                  help.puts '  --debug              run in debug mode'
         
     | 
| 
       123 
118 
     | 
    
         | 
| 
       124 
119 
     | 
    
         
             
                  puts help.string
         
     | 
    
        data/lib/version.rb
    CHANGED