Sha256: 3d2f357c9d5bd67f55ad1b6c60e88b9a25ae914cdedf52c3f6de3e452636a2b3

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module Assetify
  #
  # The Assetfile!
  #
  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.exist?('Assetfile')
      end

      def read
        file = File.open('Assetfile') # ruby 1.8/1.9 (ugly) fix
        code = file.each_line.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

1 entries across 1 versions & 1 rubygems

Version Path
assetify-3.0.0 lib/assetify/assetfile.rb