Sha256: 71e2598b17f2d9918bef82f9f3d3df3ccf993f062b5baf570dda3f994d6875ab

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

module Assetify
  class Assetfile
    class << self


      #
      # Assetfile stuff
      #
      def missing!
        print "Assetfile not found, create one? [Y/n] "
        res = $stdin.gets.chomp # dont forget stdin
        unless res =~ /n|N/
          File.open("Assetfile", "w+") do |f|
            f.print <<TXT
#
# #{Dir.pwd.split('/').last.capitalize} Assetfile
#

js  :jquery, "http://jquery.com"
css :reset,  "http://prefered/rset/url"

group :forms do
  js :validator, "http://..."
end

TXT
          end
          puts "Assetfile created!"
          exit 0
        end
      end

      #
      # Assetfile find/read
      #
      #
      def find
        missing! unless File.exists?("Assetfile")
      end

      def read
        file = File.open("Assetfile") # ruby 1.8/1.9 (ugly) fix
        code = file.send(file.respond_to?(:lines) ? :lines : :readlines).map do |line|
          # Parse options
          if line =~ /^\w{2,3}path/
            key, val = line.split(" ")
            Opt[key.to_sym] = val
            next
          end
          line
        end.reject(&:nil?)
        DSL.parse code.join("")
      end

      # def write
      # end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
assetify-2.0.1 lib/assetify/assetfile.rb
assetify-2.0.0 lib/assetify/assetfile.rb
assetify-1.0.0 lib/assetify/assetfile.rb