Class: SourceFile

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/chosen-rails/source_file.rb

Instance Method Summary collapse

Instance Method Details

#cleanupObject



37
38
39
40
41
# File 'lib/chosen-rails/source_file.rb', line 37

def cleanup
  self.destination_root = "vendor/assets"
  remove_file "stylesheets/chosen.css"
  remove_file "VERSION"
end

#convertObject



27
28
29
30
31
32
33
34
# File 'lib/chosen-rails/source_file.rb', line 27

def convert
  self.destination_root = "vendor/assets"
  inside destination_root do
    run("sass-convert -F css -T sass stylesheets/chosen.css stylesheets/chosen.css.sass")
    gsub_file 'stylesheets/chosen.css.sass', '(chosen-sprite.png)', "('chosen-sprite.png')"
    gsub_file 'stylesheets/chosen.css.sass', ' url', ' image-url'
  end
end

#fetchObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chosen-rails/source_file.rb', line 7

def fetch
  self.destination_root = "vendor/assets"
  remote = "https://github.com/fatfreecrm/chosen"
  branch = "master"
  get "#{remote}/raw/#{branch}/chosen/chosen-sprite.png", "images/chosen-sprite.png"
  get "#{remote}/raw/#{branch}/chosen/chosen.css", "stylesheets/chosen.css"
  get "#{remote}/raw/#{branch}/coffee/lib/abstract-chosen.coffee", "javascripts/lib/abstract-chosen.coffee"
  get "#{remote}/raw/#{branch}/coffee/lib/select-parser.coffee", "javascripts/lib/select-parser.coffee"
  get "#{remote}/raw/#{branch}/coffee/chosen.jquery.coffee", "javascripts/chosen.jquery.coffee"
  get "#{remote}/raw/#{branch}/coffee/chosen.proto.coffee", "javascripts/chosen.proto.coffee"
  get "#{remote}/raw/#{branch}/VERSION", "VERSION"
  inside destination_root do
    version = File.read("VERSION").sub("\n", "")
    gsub_file "../../lib/chosen-rails/version.rb", /VERSION\s=\s"(\d|\.)+"$/ do |match|
      %Q{VERSION = "#{version}"}
    end
  end
end