grache 0.0.11 → 0.0.12
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/TODO.md +4 -0
 - data/lib/grache.rb +1 -1
 - data/lib/grache/cli/commands/pack_cmd.rb +34 -0
 - data/lib/grache/packer/packer.rb +103 -3
 - data/lib/grache/templates/stub.rb.erb +50 -0
 - data/lib/grache/version.rb +1 -1
 - data/lib/grache/zip/zip_generator.rb +18 -6
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 142a17fd6cc7a443f637a087f01faf5dd7ffc552
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7b3552ad7ec801b4ca19ba114195d25732eeed92
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2dcc4af2a35bf18a5e126fa8fc8698c5fd44f06d01407ee7ed54ebab5dadbff22b3e9841bd0cdd8343e7e2e6b95fc3ed0effa0e9fa1d8835039471dcaef3d809
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0e1c8911b4b5a04b9620042be45f3906dd2d154e16ffe9849d2acede29f35b7aa5ee81ea6bef940a3221121ad3b61f4f450fa822ac044e09cefd2209622d90bb
         
     | 
    
        data/TODO.md
    ADDED
    
    
    
        data/lib/grache.rb
    CHANGED
    
    
| 
         @@ -31,5 +31,39 @@ Grache::CLI.module_eval do 
     | 
|
| 
       31 
31 
     | 
    
         
             
                    Grache::Packer.new.zip
         
     | 
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         
             
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                c.desc 'Deploy created pack'
         
     | 
| 
      
 36 
     | 
    
         
            +
                c.command :deploy do |cmd|
         
     | 
| 
      
 37 
     | 
    
         
            +
                  cmd.desc 'AWS S3 Access Key Id'
         
     | 
| 
      
 38 
     | 
    
         
            +
                  cmd.default_value nil
         
     | 
| 
      
 39 
     | 
    
         
            +
                  cmd.flag 'access-key-id'
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  cmd.desc 'AWS S3 Secret Access Key'
         
     | 
| 
      
 42 
     | 
    
         
            +
                  cmd.default_value nil
         
     | 
| 
      
 43 
     | 
    
         
            +
                  cmd.flag 'secret-access-key'
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  cmd.action do |global_options, options, _args|
         
     | 
| 
      
 46 
     | 
    
         
            +
                    opts = options.merge(global_options)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    access_key_id = opts['access-key-id']
         
     | 
| 
      
 49 
     | 
    
         
            +
                    secret_access_key = opts['secret-access-key']
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                    Grache::Packer.new.deploy({access_key_id: access_key_id, secret_access_key: secret_access_key })
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                c.desc 'Release pack - build, zip, deploy'
         
     | 
| 
      
 56 
     | 
    
         
            +
                c.command :release do |cmd|
         
     | 
| 
      
 57 
     | 
    
         
            +
                  cmd.action do |global_options, options, _args|
         
     | 
| 
      
 58 
     | 
    
         
            +
                    _opts = options.merge(global_options)
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    ['pack build', 'pack zip', 'pack deploy'].each do |act|
         
     | 
| 
      
 61 
     | 
    
         
            +
                      act_cmd = "#{$0} #{act}"
         
     | 
| 
      
 62 
     | 
    
         
            +
                      system(act_cmd)
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                    # Grache::Packer.new.install
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
       34 
68 
     | 
    
         
             
              end
         
     | 
| 
       35 
69 
     | 
    
         
             
            end
         
     | 
    
        data/lib/grache/packer/packer.rb
    CHANGED
    
    | 
         @@ -1,5 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            require 'aws-sdk'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require 'digest'
         
     | 
| 
       4 
5 
     | 
    
         
             
            require 'fileutils'
         
     | 
| 
       5 
6 
     | 
    
         
             
            require 'json'
         
     | 
| 
         @@ -17,6 +18,8 @@ require_relative '../zip/zip' 
     | 
|
| 
       17 
18 
     | 
    
         | 
| 
       18 
19 
     | 
    
         
             
            module Grache
         
     | 
| 
       19 
20 
     | 
    
         
             
              class Packer
         
     | 
| 
      
 21 
     | 
    
         
            +
                GEMFILE_RE = Regexp.new(/^\s*gem\s+['"]([^'"]+)['"]\s*,\s*:git\s+=>\s+['"]([^'"]+)['"](\s*,\s*:branch\s+=>\s+['""]([^'"]+)['""])?$/)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       20 
23 
     | 
    
         
             
                DEFAULT_INSTALL_OPTIONS = {
         
     | 
| 
       21 
24 
     | 
    
         
             
                }
         
     | 
| 
       22 
25 
     | 
    
         | 
| 
         @@ -41,7 +44,9 @@ module Grache 
     | 
|
| 
       41 
44 
     | 
    
         
             
                  'bundle-pack' => 'bundle pack --gemfile=%s --all',
         
     | 
| 
       42 
45 
     | 
    
         | 
| 
       43 
46 
     | 
    
         
             
                  # gemspec path
         
     | 
| 
       44 
     | 
    
         
            -
                  'gem-build' => 'gem build %s' # spec path
         
     | 
| 
      
 47 
     | 
    
         
            +
                  'gem-build' => 'gem build %s', # spec path
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  'gem-generate-index' => 'gem generate_index'
         
     | 
| 
       45 
50 
     | 
    
         
             
                }
         
     | 
| 
       46 
51 
     | 
    
         | 
| 
       47 
52 
     | 
    
         
             
                class << self
         
     | 
| 
         @@ -146,6 +151,10 @@ module Grache 
     | 
|
| 
       146 
151 
     | 
    
         
             
                    puts "Gemfile located at #{gemfile}" if gemfile
         
     | 
| 
       147 
152 
     | 
    
         
             
                    gem_dir = File.dirname(gemfile)
         
     | 
| 
       148 
153 
     | 
    
         | 
| 
      
 154 
     | 
    
         
            +
                    gemfile = process_gemfile(gemfile)
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
                    # exit(0)
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
       149 
158 
     | 
    
         
             
                    # TODO: Read gemfile programatically
         
     | 
| 
       150 
159 
     | 
    
         
             
                    uses_gemspec = File.open(gemfile).read.index(/^gemspec$/) != nil
         
     | 
| 
       151 
160 
     | 
    
         
             
                    if(uses_gemspec)
         
     | 
| 
         @@ -165,14 +174,79 @@ module Grache 
     | 
|
| 
       165 
174 
     | 
    
         
             
                      exec_cmd(cmd)
         
     | 
| 
       166 
175 
     | 
    
         
             
                    end
         
     | 
| 
       167 
176 
     | 
    
         | 
| 
       168 
     | 
    
         
            -
                    cache_dir = File.join(gem_dir, 'vendor')
         
     | 
| 
      
 177 
     | 
    
         
            +
                    cache_dir = File.join(gem_dir, 'vendor', 'cache')
         
     | 
| 
      
 178 
     | 
    
         
            +
                    gems_dir = File.join(gem_dir, 'vendor', 'gems')
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                    # Delete cache directory
         
     | 
| 
       169 
181 
     | 
    
         
             
                    if File.directory?(cache_dir)
         
     | 
| 
       170 
182 
     | 
    
         
             
                      puts "Deleting cache #{cache_dir}"
         
     | 
| 
       171 
183 
     | 
    
         
             
                      FileUtils.rm_rf cache_dir
         
     | 
| 
       172 
184 
     | 
    
         
             
                    end
         
     | 
| 
       173 
185 
     | 
    
         | 
| 
      
 186 
     | 
    
         
            +
                    FileUtils.mkdir_p cache_dir
         
     | 
| 
      
 187 
     | 
    
         
            +
             
     | 
| 
      
 188 
     | 
    
         
            +
                    # Move built gems to cache
         
     | 
| 
      
 189 
     | 
    
         
            +
                    Dir.glob("#{gems_dir}/**/*.gem").each do |gem|
         
     | 
| 
      
 190 
     | 
    
         
            +
                      dest = File.join(cache_dir, File.basename(gem))
         
     | 
| 
      
 191 
     | 
    
         
            +
                      puts "Moving #{gem} -> #{dest}"
         
     | 
| 
      
 192 
     | 
    
         
            +
                      FileUtils.mv(gem, dest)
         
     | 
| 
      
 193 
     | 
    
         
            +
                    end
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                    # Pack gems
         
     | 
| 
       174 
196 
     | 
    
         
             
                    cmd = CMDS['bundle-pack'] % gemfile
         
     | 
| 
       175 
197 
     | 
    
         
             
                    exec_cmd(cmd)
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                    # Generate local gem index, see http://stackoverflow.com/questions/5633939/how-do-i-specify-local-gem-files-in-my-gemfile
         
     | 
| 
      
 200 
     | 
    
         
            +
                    # Dir.chdir(cache_dir) do
         
     | 
| 
      
 201 
     | 
    
         
            +
                    #   # Pack gems
         
     | 
| 
      
 202 
     | 
    
         
            +
                    #   cmd = CMDS['gem-generate-index'] % gemfile
         
     | 
| 
      
 203 
     | 
    
         
            +
                    #   exec_cmd(cmd)
         
     | 
| 
      
 204 
     | 
    
         
            +
                    # end
         
     | 
| 
      
 205 
     | 
    
         
            +
                  end
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                  def process_gemfile(gemfile_path)
         
     | 
| 
      
 208 
     | 
    
         
            +
                    new_gemfile = ''
         
     | 
| 
      
 209 
     | 
    
         
            +
                    git_gems = {}
         
     | 
| 
      
 210 
     | 
    
         
            +
                    File.open(gemfile_path, 'r') do |f|
         
     | 
| 
      
 211 
     | 
    
         
            +
                      f.each_line do |l|
         
     | 
| 
      
 212 
     | 
    
         
            +
                        m = GEMFILE_RE.match(l)
         
     | 
| 
      
 213 
     | 
    
         
            +
                        if(m)
         
     | 
| 
      
 214 
     | 
    
         
            +
                          branch = m[4] || 'master'
         
     | 
| 
      
 215 
     | 
    
         
            +
                          new_gemfile += "gem '#{m[1]}',  :path => './vendor/gems/#{m[1]}'\n"
         
     | 
| 
      
 216 
     | 
    
         
            +
                          git_gems[m[1]] = {
         
     | 
| 
      
 217 
     | 
    
         
            +
                            :branch => branch,
         
     | 
| 
      
 218 
     | 
    
         
            +
                            :git => m[2]
         
     | 
| 
      
 219 
     | 
    
         
            +
                          }
         
     | 
| 
      
 220 
     | 
    
         
            +
                        else
         
     | 
| 
      
 221 
     | 
    
         
            +
                          new_gemfile += l
         
     | 
| 
      
 222 
     | 
    
         
            +
                        end
         
     | 
| 
      
 223 
     | 
    
         
            +
                      end
         
     | 
| 
      
 224 
     | 
    
         
            +
                    end
         
     | 
| 
      
 225 
     | 
    
         
            +
                    puts new_gemfile
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
                    gem_dir = File.join(File.dirname(gemfile_path), 'vendor', 'gems')
         
     | 
| 
      
 228 
     | 
    
         
            +
                    FileUtils.mkdir_p gem_dir
         
     | 
| 
      
 229 
     | 
    
         
            +
                    Dir.chdir(gem_dir) do
         
     | 
| 
      
 230 
     | 
    
         
            +
                      git_gems.each do |name, gem|
         
     | 
| 
      
 231 
     | 
    
         
            +
                        FileUtils.rm_rf(name)
         
     | 
| 
      
 232 
     | 
    
         
            +
                        cmd = "git clone #{gem[:git]} #{name}"
         
     | 
| 
      
 233 
     | 
    
         
            +
                        puts cmd
         
     | 
| 
      
 234 
     | 
    
         
            +
                        system cmd
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                        Dir.chdir(name) do
         
     | 
| 
      
 237 
     | 
    
         
            +
                          cmd = "git checkout #{gem[:branch]}"
         
     | 
| 
      
 238 
     | 
    
         
            +
                          puts cmd
         
     | 
| 
      
 239 
     | 
    
         
            +
                          system cmd
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
                          cmd = "gem build *.gemspec"
         
     | 
| 
      
 242 
     | 
    
         
            +
                          system(cmd)
         
     | 
| 
      
 243 
     | 
    
         
            +
                        end
         
     | 
| 
      
 244 
     | 
    
         
            +
                      end
         
     | 
| 
      
 245 
     | 
    
         
            +
                    end
         
     | 
| 
      
 246 
     | 
    
         
            +
             
     | 
| 
      
 247 
     | 
    
         
            +
                    new_gemfile_path = "#{gemfile_path}.Generated"
         
     | 
| 
      
 248 
     | 
    
         
            +
                    File.open(new_gemfile_path, 'w') { |file| file.write(new_gemfile) }
         
     | 
| 
      
 249 
     | 
    
         
            +
                    new_gemfile_path
         
     | 
| 
       176 
250 
     | 
    
         
             
                  end
         
     | 
| 
       177 
251 
     | 
    
         | 
| 
       178 
252 
     | 
    
         
             
                  def zip(opts = DEFAULT_ZIP_OPTIONS)
         
     | 
| 
         @@ -190,7 +264,8 @@ module Grache 
     | 
|
| 
       190 
264 
     | 
    
         
             
                    return unless gemfile
         
     | 
| 
       191 
265 
     | 
    
         | 
| 
       192 
266 
     | 
    
         
             
                    gem_dir = File.dirname(gemfile)
         
     | 
| 
       193 
     | 
    
         
            -
                     
     | 
| 
      
 267 
     | 
    
         
            +
                    gems_dir = File.join(gem_dir, 'gems')
         
     | 
| 
      
 268 
     | 
    
         
            +
                    vendor_dir = File.join(gem_dir, 'vendor')
         
     | 
| 
       194 
269 
     | 
    
         | 
| 
       195 
270 
     | 
    
         
             
                    unless File.directory?(vendor_dir)
         
     | 
| 
       196 
271 
     | 
    
         
             
                      puts "Vendor directory does not exists. Run 'grache pack build' first!"
         
     | 
| 
         @@ -203,6 +278,7 @@ module Grache 
     | 
|
| 
       203 
278 
     | 
    
         
             
                    archive = "grache-#{sha}.zip"
         
     | 
| 
       204 
279 
     | 
    
         
             
                    FileUtils.rm archive, :force => true
         
     | 
| 
       205 
280 
     | 
    
         | 
| 
      
 281 
     | 
    
         
            +
                    # ZipGenerator.new(gems_dir, archive).write
         
     | 
| 
       206 
282 
     | 
    
         
             
                    ZipGenerator.new(vendor_dir, archive).write
         
     | 
| 
       207 
283 
     | 
    
         | 
| 
       208 
284 
     | 
    
         
             
                    puts "Created #{archive}"
         
     | 
| 
         @@ -210,6 +286,30 @@ module Grache 
     | 
|
| 
       210 
286 
     | 
    
         
             
                end
         
     | 
| 
       211 
287 
     | 
    
         | 
| 
       212 
288 
     | 
    
         | 
| 
      
 289 
     | 
    
         
            +
                def deploy(opts = {access_key_id: nil, secret_access_key: nil})
         
     | 
| 
      
 290 
     | 
    
         
            +
                  bucket_name = 'gdc-ms-grache'
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
                  access_key_id = opts[:access_key_id]
         
     | 
| 
      
 293 
     | 
    
         
            +
                  if access_key_id.nil?
         
     | 
| 
      
 294 
     | 
    
         
            +
                    print 'Access Key ID? '
         
     | 
| 
      
 295 
     | 
    
         
            +
                    access_key_id = $stdin.gets.chomp
         
     | 
| 
      
 296 
     | 
    
         
            +
                  end
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
                  secret_access_key = opts[:secret_access_key]
         
     | 
| 
      
 299 
     | 
    
         
            +
                  if secret_access_key.nil?
         
     | 
| 
      
 300 
     | 
    
         
            +
                    print 'Secret access key? '
         
     | 
| 
      
 301 
     | 
    
         
            +
                    secret_access_key = $stdin.gets.chomp
         
     | 
| 
      
 302 
     | 
    
         
            +
                  end
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
      
 304 
     | 
    
         
            +
                  s3 = AWS::S3.new(:access_key_id => access_key_id, :secret_access_key => secret_access_key)
         
     | 
| 
      
 305 
     | 
    
         
            +
             
     | 
| 
      
 306 
     | 
    
         
            +
                  Dir.glob("**/grache-*.zip").each do |grache_file|
         
     | 
| 
      
 307 
     | 
    
         
            +
                    key = File.basename(grache_file)
         
     | 
| 
      
 308 
     | 
    
         
            +
                    s3.buckets[bucket_name].objects[key].write(:file => grache_file)
         
     | 
| 
      
 309 
     | 
    
         
            +
                    puts "Uploading file #{grache_file} to bucket #{bucket_name}."
         
     | 
| 
      
 310 
     | 
    
         
            +
                  end
         
     | 
| 
      
 311 
     | 
    
         
            +
                end
         
     | 
| 
      
 312 
     | 
    
         
            +
             
     | 
| 
       213 
313 
     | 
    
         
             
                def find_gemfile(path)
         
     | 
| 
       214 
314 
     | 
    
         
             
                  Packer.find_gemfile(path)
         
     | 
| 
       215 
315 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #! /usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'bundler/cli'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require_relative 'core'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            $SCRIPT_PARAMS ||= {}
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            FETCH_GEMS = $SCRIPT_PARAMS['FETCH_GEMS'] || true
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            repo_gems = [
         
     | 
| 
      
 13 
     | 
    
         
            +
                    'https://github.com/korczis/grache/archive/master.zip'
         
     | 
| 
      
 14 
     | 
    
         
            +
            ]
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            if FETCH_GEMS
         
     | 
| 
      
 17 
     | 
    
         
            +
                repo_gems.each do |repo_gem|
         
     | 
| 
      
 18 
     | 
    
         
            +
                    cmd = "curl -LOk --retry 3 #{repo_gem} 2>&1"
         
     | 
| 
      
 19 
     | 
    
         
            +
                    puts cmd
         
     | 
| 
      
 20 
     | 
    
         
            +
                    system(cmd)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                    repo_gem_file = repo_gem.split('/').last
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    cmd = "unzip -o #{repo_gem_file} 2>&1"
         
     | 
| 
      
 25 
     | 
    
         
            +
                    puts cmd
         
     | 
| 
      
 26 
     | 
    
         
            +
                    system(cmd)
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    FileUtils.rm repo_gem_file
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            grash('cp -a grache-master/lib/* .')
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            require_relative 'grache'
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            puts "Grache::VERSION = #{Grache::VERSION}"
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            # Fetch grache pack
         
     | 
| 
      
 39 
     | 
    
         
            +
            Grache::Packer.new.install
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            Grache::Packer.new.install()
         
     | 
| 
      
 42 
     | 
    
         
            +
            Bundler::CLI.new.invoke(:install, [], :gemfile => 'Gemfile', :local => true, :deployment => true, :verbose => true, :binstubs => './bin')
         
     | 
| 
      
 43 
     | 
    
         
            +
            # require 'bundler/setup'
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            grash('cat .bundle/config')
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            # Show installed gems
         
     | 
| 
      
 48 
     | 
    
         
            +
            Bundler::CLI.new.invoke(:show, [], :verbose => true)
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            require_relative './main.rb'
         
     | 
    
        data/lib/grache/version.rb
    CHANGED
    
    
| 
         @@ -23,16 +23,20 @@ module Grache 
     | 
|
| 
       23 
23 
     | 
    
         
             
                end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                # Zip the input directory.
         
     | 
| 
       26 
     | 
    
         
            -
                def write()
         
     | 
| 
       27 
     | 
    
         
            -
                  entries = Dir.entries(@inputDir) 
     | 
| 
      
 26 
     | 
    
         
            +
                def write(root = '')
         
     | 
| 
      
 27 
     | 
    
         
            +
                  entries = Dir.entries(@inputDir)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  entries.delete('.')
         
     | 
| 
      
 29 
     | 
    
         
            +
                  entries.delete('..')
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       28 
31 
     | 
    
         
             
                  io = Zip::File.open(@outputFile, Zip::File::CREATE);
         
     | 
| 
       29 
     | 
    
         
            -
                  writeEntries(entries, '', io)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  writeEntries(entries, '', io, root)
         
     | 
| 
       30 
33 
     | 
    
         
             
                  io.close();
         
     | 
| 
       31 
34 
     | 
    
         
             
                end
         
     | 
| 
       32 
35 
     | 
    
         | 
| 
       33 
36 
     | 
    
         
             
                # A helper method to make the recursion work.
         
     | 
| 
       34 
37 
     | 
    
         
             
                private
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                def writeEntries(entries, path, io, root = '')
         
     | 
| 
       36 
40 
     | 
    
         
             
                  entries.each { |e|
         
     | 
| 
       37 
41 
     | 
    
         
             
                    zipFilePath = path == '' ? e : File.join(path, e)
         
     | 
| 
       38 
42 
     | 
    
         
             
                    diskFilePath = File.join(@inputDir, zipFilePath)
         
     | 
| 
         @@ -40,10 +44,18 @@ module Grache 
     | 
|
| 
       40 
44 
     | 
    
         | 
| 
       41 
45 
     | 
    
         
             
                    if File.directory?(diskFilePath)
         
     | 
| 
       42 
46 
     | 
    
         
             
                      io.mkdir(zipFilePath)
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                      subdir = Dir.entries(diskFilePath)
         
     | 
| 
      
 49 
     | 
    
         
            +
                      subdir.delete('.')
         
     | 
| 
      
 50 
     | 
    
         
            +
                      subdir.delete('..')
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
       44 
52 
     | 
    
         
             
                      writeEntries(subdir, zipFilePath, io)
         
     | 
| 
       45 
53 
     | 
    
         
             
                    else
         
     | 
| 
       46 
     | 
    
         
            -
                       
     | 
| 
      
 54 
     | 
    
         
            +
                      iop = root.empty? ? zipFilePath : File.join(root, zipFilePath)
         
     | 
| 
      
 55 
     | 
    
         
            +
                      # puts "IOP: #{iop}"
         
     | 
| 
      
 56 
     | 
    
         
            +
                      io.get_output_stream(iop) do |f|
         
     | 
| 
      
 57 
     | 
    
         
            +
                        f.print(File.open(diskFilePath, 'rb').read())
         
     | 
| 
      
 58 
     | 
    
         
            +
                      end
         
     | 
| 
       47 
59 
     | 
    
         
             
                    end
         
     | 
| 
       48 
60 
     | 
    
         
             
                  }
         
     | 
| 
       49 
61 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: grache
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.12
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tomas Korcak
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-02- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-02-24 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: coveralls
         
     | 
| 
         @@ -464,6 +464,7 @@ files: 
     | 
|
| 
       464 
464 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       465 
465 
     | 
    
         
             
            - README.md
         
     | 
| 
       466 
466 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 467 
     | 
    
         
            +
            - TODO.md
         
     | 
| 
       467 
468 
     | 
    
         
             
            - bin/grache
         
     | 
| 
       468 
469 
     | 
    
         
             
            - lib/grache.rb
         
     | 
| 
       469 
470 
     | 
    
         
             
            - lib/grache/bundler/bundler.rb
         
     | 
| 
         @@ -473,6 +474,7 @@ files: 
     | 
|
| 
       473 
474 
     | 
    
         
             
            - lib/grache/cli/hooks.rb
         
     | 
| 
       474 
475 
     | 
    
         
             
            - lib/grache/cli/shared.rb
         
     | 
| 
       475 
476 
     | 
    
         
             
            - lib/grache/packer/packer.rb
         
     | 
| 
      
 477 
     | 
    
         
            +
            - lib/grache/templates/stub.rb.erb
         
     | 
| 
       476 
478 
     | 
    
         
             
            - lib/grache/version.rb
         
     | 
| 
       477 
479 
     | 
    
         
             
            - lib/grache/zip/zip.rb
         
     | 
| 
       478 
480 
     | 
    
         
             
            - lib/grache/zip/zip_generator.rb
         
     |