Skip to content

Commit

Permalink
move SourceFile to source_file.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
tsechingho committed Dec 22, 2011
1 parent 8f05069 commit 308ddea
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
42 changes: 2 additions & 40 deletions Rakefile
100644 → 100755
Original file line number Original file line Diff line number Diff line change
@@ -1,46 +1,8 @@
#!/usr/bin/env rake #!/usr/bin/env rake
require "bundler/gem_tasks" require "bundler/gem_tasks"
require "thor" require File.expand_path('../lib/chosen-rails/source_file', __FILE__)


class SourceFile < Thor desc "Update with Harvest's Chosen Library"
include Thor::Actions

desc "fetch source files", "fetch source files from GitHub"
def fetch
self.destination_root = "vendor/assets"
remote = "https://github.com/harvesthq/chosen"
get "#{remote}/raw/master/chosen/chosen-sprite.png", "images/chosen-sprite.png"
get "#{remote}/raw/master/chosen/chosen.css", "stylesheets/chosen.css"
get "#{remote}/raw/master/coffee/lib/abstract-chosen.coffee", "javascripts/lib/abstract-chosen.coffee"
get "#{remote}/raw/master/coffee/lib/select-parser.coffee", "javascripts/lib/select-parser.coffee"
get "#{remote}/raw/master/coffee/chosen.jquery.coffee", "javascripts/chosen.jquery.coffee"
get "#{remote}/raw/master/coffee/chosen.proto.coffee", "javascripts/chosen.proto.coffee"
get "#{remote}/raw/master/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

desc "convert css to sass file", "convert css to sass file by sass-convert"
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")
end
end

desc "clean up useless files", "clean up useless files"
def cleanup
self.destination_root = "vendor/assets"
remove_file "stylesheets/chosen.css"
remove_file "VERSION"
end
end

desc "Update Harvest's Chosen Library"
task "update-chosen" do task "update-chosen" do
files = SourceFile.new files = SourceFile.new
files.fetch files.fetch
Expand Down
39 changes: 39 additions & 0 deletions lib/chosen-rails/source_file.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,39 @@
require "thor"

class SourceFile < Thor
include Thor::Actions

desc "fetch source files", "fetch source files from GitHub"
def fetch
self.destination_root = "vendor/assets"
remote = "https://github.com/harvesthq/chosen"
get "#{remote}/raw/master/chosen/chosen-sprite.png", "images/chosen-sprite.png"
get "#{remote}/raw/master/chosen/chosen.css", "stylesheets/chosen.css"
get "#{remote}/raw/master/coffee/lib/abstract-chosen.coffee", "javascripts/lib/abstract-chosen.coffee"
get "#{remote}/raw/master/coffee/lib/select-parser.coffee", "javascripts/lib/select-parser.coffee"
get "#{remote}/raw/master/coffee/chosen.jquery.coffee", "javascripts/chosen.jquery.coffee"
get "#{remote}/raw/master/coffee/chosen.proto.coffee", "javascripts/chosen.proto.coffee"
get "#{remote}/raw/master/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

desc "convert css to sass file", "convert css to sass file by sass-convert"
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")
end
end

desc "clean up useless files", "clean up useless files"
def cleanup
self.destination_root = "vendor/assets"
remove_file "stylesheets/chosen.css"
remove_file "VERSION"
end
end

0 comments on commit 308ddea

Please sign in to comment.