Class: Uki::Project
- Inherits:
-
Object
- Object
- Uki::Project
- Defined in:
- lib/uki/project.rb
Constant Summary collapse
- CJS_REGEXP =
%r{=\s*["']?(([^"' ]+).cjs)}
Instance Attribute Summary collapse
-
#dest ⇒ Object
Returns the value of attribute dest.
Instance Method Summary collapse
- #build(files, options = {}) ⇒ Object
- #create(options) ⇒ Object
- #create_class(template, fullName) ⇒ Object
- #create_function(template, fullName) ⇒ Object
- #ie_images(target) ⇒ Object
-
#initialize(dest) ⇒ Project
constructor
A new instance of Project.
-
#name ⇒ Object
def name File.basename File.expand_path(dest) end.
Constructor Details
#initialize(dest) ⇒ Project
Returns a new instance of Project.
14 15 16 |
# File 'lib/uki/project.rb', line 14 def initialize dest @dest = dest end |
Instance Attribute Details
#dest ⇒ Object
Returns the value of attribute dest.
12 13 14 |
# File 'lib/uki/project.rb', line 12 def dest @dest end |
Instance Method Details
#build(files, options = {}) ⇒ Object
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 61 62 63 |
# File 'lib/uki/project.rb', line 35 def build files, = {} cjs = [] containers = [] files.each do |file| path = to_path(file) next unless File.exists?(path) if file.match(/.html$/) cjs += extract_cjs(path) containers << path else cjs << path end end cjs.uniq! containers.uniq! output = to_path([:output]) FileUtils.rm_rf output if [:clean_output] FileUtils.mkdir_p output cjs.each do |path| File.open(File.join(output, File.basename(path)), 'w') do |f| f.write( Uki::Builder.new(path, :compress => [:compress]).code ) end end build_containers containers, output build_images output if [:images] end |
#create(options) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/uki/project.rb', line 26 def create verify_empty init_dest copy_frameworks copy_templates copy_images init_jspec if [:jspec] end |
#create_class(template, fullName) ⇒ Object
65 66 67 68 69 |
# File 'lib/uki/project.rb', line 65 def create_class template, fullName path = fullName.split('.') create_packages path[0..-2] write_class template, path end |
#create_function(template, fullName) ⇒ Object
71 72 73 74 75 |
# File 'lib/uki/project.rb', line 71 def create_function template, fullName path = fullName.split('.') create_packages path[0..-2] write_function template, path end |
#ie_images(target) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/uki/project.rb', line 77 def ie_images target contents = File.read(File.join(dest, target)) place = File.join(dest, 'tmp', 'theme') # button-full/normal-v.png contents.scan(%r{\[[^"]*"([^"]+)"[^"]+"data:image/png;base64,([^"]+)"[^"\]]*(?:"([^"]+)"[^"\]]*)?\]}) do p $1 file = File.join(place, $1) FileUtils.mkdir_p File.dirname(file) File.open(file, 'w') do |f| f.write Base64.decode64($2) end `convert #{File.join(place, $1)} #{File.join(place, $3)}` if $3 end place end |
#name ⇒ Object
def name
File.basename File.(dest)
end
22 23 24 |
# File 'lib/uki/project.rb', line 22 def name File.basename(File.(dest)).sub(/[^a-z0-9_$]+/, '_') end |