Class: Ninjs::Configuration
- Inherits:
-
Object
- Object
- Ninjs::Configuration
- Defined in:
- lib/ninjs/configuration.rb
Instance Attribute Summary collapse
-
#asset_root ⇒ Object
Returns the value of attribute asset_root.
-
#asset_root_relative ⇒ Object
Returns the value of attribute asset_root_relative.
-
#autoload ⇒ Object
Returns the value of attribute autoload.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#dest_dir ⇒ Object
Returns the value of attribute dest_dir.
-
#module_alias ⇒ Object
Returns the value of attribute module_alias.
-
#name ⇒ Object
Returns the value of attribute name.
-
#output ⇒ Object
Returns the value of attribute output.
-
#root ⇒ Object
Returns the value of attribute root.
-
#src_dir ⇒ Object
Returns the value of attribute src_dir.
Instance Method Summary collapse
- #array_to_yml(array) ⇒ Object
-
#initialize(project_path) ⇒ Configuration
constructor
A new instance of Configuration.
- #read ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(project_path) ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ninjs/configuration.rb', line 15 def initialize(project_path) @root = File. project_path @name = 'application' @src_dir = 'modules' @dest_dir = 'application' @asset_root_relative = '../' @asset_root = File.('../', @root) @output = 'expanded' @dependencies = ['<jquery/latest>'] @autoload = ['../lib/utilities'] @module_alias = 'mod' read if File.exists? "#{@root}/ninjs.conf" end |
Instance Attribute Details
#asset_root ⇒ Object
Returns the value of attribute asset_root.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def asset_root @asset_root end |
#asset_root_relative ⇒ Object
Returns the value of attribute asset_root_relative.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def asset_root_relative @asset_root_relative end |
#autoload ⇒ Object
Returns the value of attribute autoload.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def autoload @autoload end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def dependencies @dependencies end |
#dest_dir ⇒ Object
Returns the value of attribute dest_dir.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def dest_dir @dest_dir end |
#module_alias ⇒ Object
Returns the value of attribute module_alias.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def module_alias @module_alias end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def name @name end |
#output ⇒ Object
Returns the value of attribute output.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def output @output end |
#root ⇒ Object
Returns the value of attribute root.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def root @root end |
#src_dir ⇒ Object
Returns the value of attribute src_dir.
4 5 6 |
# File 'lib/ninjs/configuration.rb', line 4 def src_dir @src_dir end |
Instance Method Details
#array_to_yml(array) ⇒ Object
59 60 61 |
# File 'lib/ninjs/configuration.rb', line 59 def array_to_yml(array) yml = array.empty? ? '[]' : %Q{['#{array.join("', '")}']} end |
#read ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ninjs/configuration.rb', line 45 def read config = YAML.load_file("#{@root}/ninjs.conf") @name = config['name'] @src_dir = config['src_dir'] @dest_dir = config['dest_dir'] @asset_root_relative = config['asset_root'] || @asset_root_relative @asset_root = File.(@asset_root_relative, @root) @output = config['output'] @dependencies = config['dependencies'] || Array.new @autoload = config['autoload'] || Array.new @module_alias = config['module_alias'] || 'mod' end |
#write ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ninjs/configuration.rb', line 30 def write File.open("#{@root}/ninjs.conf", "w+") do |conf_file| conf_file << "name: #{@name}\n" conf_file << "src_dir: #{@src_dir}\n" conf_file << "dest_dir: #{@dest_dir}\n" conf_file << "asset_root: #{@asset_root_relative} # relative to project root\n" conf_file << "output: #{@output}\n" conf_file << "dependencies: #{array_to_yml @dependencies}\n" conf_file << "autoload: #{array_to_yml @autoload}\n" conf_file << "module_alias: #{@module_alias}\n" end puts Ninjs::Notification.notify "ninjs.conf created", :added end |