packager 0.0.1 → 0.0.2
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/lib/packager/rake_task.rb +35 -6
 - data/lib/packager/version.rb +1 -1
 - metadata +1 -1
 
    
        data/lib/packager/rake_task.rb
    CHANGED
    
    | 
         @@ -1,6 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'rake'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'rake/tasklib'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'bundler/setup'
         
     | 
| 
       4 
3 
     | 
    
         
             
            require 'erb'
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
5 
     | 
    
         
             
            module Packager
         
     | 
| 
         @@ -37,6 +36,10 @@ module Packager 
     | 
|
| 
       37 
36 
     | 
    
         | 
| 
       38 
37 
     | 
    
         
             
                  yield self if block_given?
         
     | 
| 
       39 
38 
     | 
    
         | 
| 
      
 39 
     | 
    
         
            +
                  if !@package_name || @package_name.empty?
         
     | 
| 
      
 40 
     | 
    
         
            +
                    raise "package_name is required"
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       40 
43 
     | 
    
         
             
                  @short_package_name ||= package_name.downcase.gsub(/\W+/,'-')
         
     | 
| 
       41 
44 
     | 
    
         | 
| 
       42 
45 
     | 
    
         
             
                  namespace group do
         
     | 
| 
         @@ -86,9 +89,9 @@ module Packager 
     | 
|
| 
       86 
89 
     | 
    
         
             
                  # HELPERS
         
     | 
| 
       87 
90 
     | 
    
         | 
| 
       88 
91 
     | 
    
         
             
                  def pkg_dependencies
         
     | 
| 
       89 
     | 
    
         
            -
                    [:make_pkg, "#{ 
     | 
| 
       90 
     | 
    
         
            -
                      "#{ 
     | 
| 
       91 
     | 
    
         
            -
                      "#{ 
     | 
| 
      
 92 
     | 
    
         
            +
                    [:make_pkg, "#{short_package_name}-pkg/Resources", "#{short_package_name}-pkg/#{short_package_name}.pkg",
         
     | 
| 
      
 93 
     | 
    
         
            +
                      "#{short_package_name}-pkg/Distribution", "#{short_package_name}-pkg/#{short_package_name}.pkg/Bom",
         
     | 
| 
      
 94 
     | 
    
         
            +
                      "#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo", "#{short_package_name}-pkg/#{short_package_name}.pkg/Payload"]
         
     | 
| 
       92 
95 
     | 
    
         
             
                  end
         
     | 
| 
       93 
96 
     | 
    
         | 
| 
       94 
97 
     | 
    
         
             
                  def get_details
         
     | 
| 
         @@ -103,12 +106,34 @@ module Packager 
     | 
|
| 
       103 
106 
     | 
    
         
             
                    end
         
     | 
| 
       104 
107 
     | 
    
         
             
                  end
         
     | 
| 
       105 
108 
     | 
    
         | 
| 
      
 109 
     | 
    
         
            +
                  def setup_bundler
         
     | 
| 
      
 110 
     | 
    
         
            +
                    require 'bundler/shared_helpers'
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                    unless Bundler::SharedHelpers.in_bundle?
         
     | 
| 
      
 113 
     | 
    
         
            +
                      raise "Must be in a Bundler bundle"
         
     | 
| 
      
 114 
     | 
    
         
            +
                    end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                    require 'bundler'
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 119 
     | 
    
         
            +
                      Bundler.setup
         
     | 
| 
      
 120 
     | 
    
         
            +
                    rescue Bundler::GemNotFound
         
     | 
| 
      
 121 
     | 
    
         
            +
                      # Do nothing yet, since we don't actually care
         
     | 
| 
      
 122 
     | 
    
         
            +
                    end
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                    # Add bundler to the load path after disabling system gems
         
     | 
| 
      
 125 
     | 
    
         
            +
                    bundler_lib = File.expand_path("../..", __FILE__)
         
     | 
| 
      
 126 
     | 
    
         
            +
                    $LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib)
         
     | 
| 
      
 127 
     | 
    
         
            +
                  end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
       106 
129 
     | 
    
         
             
                  # TASK DEFINITIONS
         
     | 
| 
       107 
130 
     | 
    
         | 
| 
       108 
131 
     | 
    
         
             
                  def bundle_file_task
         
     | 
| 
       109 
132 
     | 
    
         
             
                    file "#{package_name}/local/#{short_package_name}/bundle" => "Gemfile" do
         
     | 
| 
       110 
133 
     | 
    
         
             
                      require "rbconfig"
         
     | 
| 
       111 
134 
     | 
    
         | 
| 
      
 135 
     | 
    
         
            +
                      setup_bundler
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
       112 
137 
     | 
    
         
             
                      unless Config::CONFIG["target_cpu"] == "universal"
         
     | 
| 
       113 
138 
     | 
    
         
             
                        puts "Please use a universal binary copy of ruby"
         
     | 
| 
       114 
139 
     | 
    
         
             
                        exit 1
         
     | 
| 
         @@ -186,8 +211,10 @@ module Packager 
     | 
|
| 
       186 
211 
     | 
    
         
             
                  end
         
     | 
| 
       187 
212 
     | 
    
         | 
| 
       188 
213 
     | 
    
         
             
                  def distribution_file_task
         
     | 
| 
      
 214 
     | 
    
         
            +
                    erb_path = File.expand_path("../build/Distribution.erb", __FILE__)
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
       189 
216 
     | 
    
         
             
                    file "#{short_package_name}-pkg/Distribution" do
         
     | 
| 
       190 
     | 
    
         
            -
                      src = File.read  
     | 
| 
      
 217 
     | 
    
         
            +
                      src = File.read erb_path
         
     | 
| 
       191 
218 
     | 
    
         
             
                      erb = ERB.new(src)
         
     | 
| 
       192 
219 
     | 
    
         | 
| 
       193 
220 
     | 
    
         
             
                      File.open("#{short_package_name}-pkg/Distribution", "w") do |file|
         
     | 
| 
         @@ -197,8 +224,10 @@ module Packager 
     | 
|
| 
       197 
224 
     | 
    
         
             
                  end
         
     | 
| 
       198 
225 
     | 
    
         | 
| 
       199 
226 
     | 
    
         
             
                  def package_info_file_task
         
     | 
| 
      
 227 
     | 
    
         
            +
                    erb_path = File.expand_path("../build/PackageInfo.erb", __FILE__)
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
       200 
229 
     | 
    
         
             
                    file "#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo" do
         
     | 
| 
       201 
     | 
    
         
            -
                      src = File.read  
     | 
| 
      
 230 
     | 
    
         
            +
                      src = File.read erb_path
         
     | 
| 
       202 
231 
     | 
    
         
             
                      erb = ERB.new(src)
         
     | 
| 
       203 
232 
     | 
    
         | 
| 
       204 
233 
     | 
    
         
             
                      File.open("#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo", "w") do |file|
         
     | 
    
        data/lib/packager/version.rb
    CHANGED