Class: Jitai::Rake::JitaiTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Jitai::Rake::JitaiTask
- Defined in:
- lib/rake/jitaitask.rb
Instance Attribute Summary collapse
-
#cwd ⇒ Object
Returns the value of attribute cwd.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :kana) {|_self| ... } ⇒ JitaiTask
constructor
A new instance of JitaiTask.
- #new ⇒ Object
Constructor Details
#initialize(name = :kana) {|_self| ... } ⇒ JitaiTask
Returns a new instance of JitaiTask.
13 14 15 16 17 18 19 |
# File 'lib/rake/jitaitask.rb', line 13 def initialize(name = :kana) @name = name @cwd = "public/fonts/" yield self if block_given? define end |
Instance Attribute Details
#cwd ⇒ Object
Returns the value of attribute cwd.
11 12 13 |
# File 'lib/rake/jitaitask.rb', line 11 def cwd @cwd end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/rake/jitaitask.rb', line 10 def name @name end |
Instance Method Details
#define ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rake/jitaitask.rb', line 25 def define desc "Sets the font directory for Jitai to operate." task "jitai:set" do # TODO kana should accept a directory argument @cwd = "public/fonts/" end desc "Refreshes the CSS files in the font directory" task "jitai:refresh" do Dir.mkdir(@cwd) if !(File.directory? @cwd) Dir.foreach(@cwd) do |font_file| if !(File.directory?(font_file)) # Search for two different formats conversion_type = (File.extname(font_file).downcase.eql? ".ttf")? ".eot" : ".ttf" other_basename = font_file.split(".")[0] + conversion_type other_file = "./#{@cwd}#{other_basename}" file = "./#{@cwd}#{font_file}" # TODO edit ttf2eot so that it's actually installed in the system if !File.exists?(other_file) puts "===== #{conversion_type.upcase} format not found. Attempting to convert... =====" %x{cd lib/ttf2eot && ./ttf2eot < #{'../../' + @cwd + font_file} > #{'../../' + @cwd + font_file.split(".")[0] + conversion_type}} end # Rename files, account for conventions. %x{mv #{other_file} #{other_file.downcase}} if !(File.exists?(other_file.downcase)) %x{mv #{file} #{file.downcase}} if !(File.exists?(file.downcase)) font = Jitai::Font.new(font_file) font.to_css end end end self end |
#new ⇒ Object
21 22 23 |
# File 'lib/rake/jitaitask.rb', line 21 def new initialize end |