Class: Judojs::Configuration
- Inherits:
-
Object
- Object
- Judojs::Configuration
- Defined in:
- lib/judojs/configuration.rb
Instance Attribute Summary collapse
-
#app_filename ⇒ Object
readonly
Returns the value of attribute app_filename.
-
#asset_root ⇒ Object
readonly
Returns the value of attribute asset_root.
-
#autoload ⇒ Object
readonly
Returns the value of attribute autoload.
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(project_path, name = 'JudoApplication') ⇒ Configuration
constructor
A new instance of Configuration.
- #read ⇒ Object
- #set_config(config) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(project_path, name = 'JudoApplication') ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 18 19 |
# File 'lib/judojs/configuration.rb', line 13 def initialize(project_path, name = 'JudoApplication') @project_path = project_path @asset_root = project_path @name = name @output = 'expanded' @autoload = Array.new end |
Instance Attribute Details
#app_filename ⇒ Object (readonly)
Returns the value of attribute app_filename.
4 5 6 |
# File 'lib/judojs/configuration.rb', line 4 def app_filename @app_filename end |
#asset_root ⇒ Object (readonly)
Returns the value of attribute asset_root.
4 5 6 |
# File 'lib/judojs/configuration.rb', line 4 def asset_root @asset_root end |
#autoload ⇒ Object (readonly)
Returns the value of attribute autoload.
4 5 6 |
# File 'lib/judojs/configuration.rb', line 4 def autoload @autoload end |
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
4 5 6 |
# File 'lib/judojs/configuration.rb', line 4 def config_path @config_path end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
4 5 6 |
# File 'lib/judojs/configuration.rb', line 4 def directory @directory end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/judojs/configuration.rb', line 4 def name @name end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
4 5 6 |
# File 'lib/judojs/configuration.rb', line 4 def output @output end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
4 5 6 |
# File 'lib/judojs/configuration.rb', line 4 def project_path @project_path end |
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/judojs/configuration.rb', line 21 def create conf_exists = File.exists? "#{@project_path}judojs.conf" if conf_exists autoload = @autoload.empty? ? 'autoload: []' : 'autoload: ["' << @autoload.join('", "') << '"]' else autoload = @autoload.empty? ? '#autoload: ["<judojs/utilities/all>", "../plugins/local_lib_file"]' : @autoload.join('", "') end conf_content = <<-CONF project_path: #{@project_path} asset_root: #{@project_path} name: #{@name} output: #{@output} #{autoload} CONF File.open("#{@project_path}judojs.conf", "w+") do |conf_file| conf_file << conf_content end = conf_exists ? "judojs.conf updated" : "judojs.conf created" puts end |
#read ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/judojs/configuration.rb', line 46 def read begin raise IOError, "#{@project_path}judojs.conf does not exist", caller unless File.exists? "#{@project_path}judojs.conf" config_yaml = File.open("#{@project_path}judojs.conf", "r").readlines.join('') config = YAML::load config_yaml @project_path = config['project_path'] @asset_root = config['asset_root'] @name = config['name'] @app_filename = config['name'].downcase @output = config['output'] @autoload = config['autoload'] || Array.new rescue RuntimeError => e puts e. puts e.backtrace.inspect end end |
#set_config(config) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/judojs/configuration.rb', line 68 def set_config(config) @name = config[:name] unless config[:name].nil? @app_filename = config[:app_filename] unless config[:app_filename].nil? @directory = '/' @output = config[:output] unless config[:output].nil? @autoload = config[:autoload] || nil end |
#update ⇒ Object
64 65 66 |
# File 'lib/judojs/configuration.rb', line 64 def update create end |