Class: ExtJS::MVC::Builder::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/xmvc/builders/base.rb

Instance Method Summary collapse

Instance Method Details

#buildObject

Does the actual building - just concatenates file_list and optionally minifies



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xmvc/builders/base.rb', line 13

def build
  concatenate(file_list, output_filename)
  system('growlnotify -m "Built ' + name + '"')
    
  if should_minify
    minify output_filename
    system('growlnotify -m "Minified ' + name + '"')
  end
    
  puts message
end

#build_file_nameObject



51
52
53
# File 'lib/xmvc/builders/base.rb', line 51

def build_file_name
  "#{directory_name}/build"
end

#descriptionObject



38
39
40
# File 'lib/xmvc/builders/base.rb', line 38

def description
  directory_name
end

#directory_nameObject

Subclasses can override this method to return the string name of the directory under while the file_list resides



56
57
58
# File 'lib/xmvc/builders/base.rb', line 56

def directory_name
  "./"
end

#file_listObject

Returns an array of all files to be concatenated, in the order they should be included



43
44
45
# File 'lib/xmvc/builders/base.rb', line 43

def file_list
  has_build_file? ? order_from_build_file : guess_build_order
end

#guess_build_orderObject

Returns an array of all the .js files found in the plugin dir, in the order in which they are found (ignores the ‘PluginName-all.js’ file)



83
84
85
# File 'lib/xmvc/builders/base.rb', line 83

def guess_build_order
  js_files_in_glob("#{directory_name}/**/*.js")
end

#has_build_file?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/xmvc/builders/base.rb', line 47

def has_build_file?
  File.exists?(build_file_name)
end

#js_files_in_glob(glob) ⇒ Object



87
88
89
# File 'lib/xmvc/builders/base.rb', line 87

def js_files_in_glob(glob)
  Dir[glob].select {|fileName| Regexp.new(output_filename).match(fileName).nil?}
end

#messageObject



34
35
36
# File 'lib/xmvc/builders/base.rb', line 34

def message
  "Build complete"
end

#nameObject



30
31
32
# File 'lib/xmvc/builders/base.rb', line 30

def name
  "Unknown Package"
end

#order_from_build_fileObject

Returns an array of all of the files listed in the build file



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/xmvc/builders/base.rb', line 61

def order_from_build_file
  build_files = []
  file        = File.open(build_file_name, "r")
    
  while (line = file.gets)
    line.gsub!(/\n/, '')
    next if line =~ /^#/ || line.length.zero?
      
    filename = "#{directory_name}/#{line}"
      
    if File.exists?(filename)
      build_files.push(filename) unless build_files.include?(filename)
    else
      js_files_in_glob(filename).each {|filename| build_files.push(filename) unless build_files.include?(filename)}
    end
  end
    
  build_files
end

#output_filenameObject

Subclasses must implement this method to return the name of the file that concatenated output will be saved to



8
9
10
# File 'lib/xmvc/builders/base.rb', line 8

def output_filename
  raise 
end

#should_minifyObject

Indicates whether the outputted filename should also be minified (defaults to false)



26
27
28
# File 'lib/xmvc/builders/base.rb', line 26

def should_minify
  false
end