Class: Xnlogic::CLI::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/xnlogic/cli/core.rb

Direct Known Subclasses

Application

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, thor) ⇒ Core

Returns a new instance of Core.



8
9
10
11
12
13
# File 'lib/xnlogic/cli/core.rb', line 8

def initialize(options, thor)
  @ignore_options ||= []
  @options = {}.merge options
  @thor = thor
  @app = Pathname.pwd
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



6
7
8
# File 'lib/xnlogic/cli/core.rb', line 6

def app
  @app
end

#ignore_optionsObject (readonly)

Returns the value of attribute ignore_options.



6
7
8
# File 'lib/xnlogic/cli/core.rb', line 6

def ignore_options
  @ignore_options
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/xnlogic/cli/core.rb', line 6

def options
  @options
end

#thorObject (readonly)

Returns the value of attribute thor.



6
7
8
# File 'lib/xnlogic/cli/core.rb', line 6

def thor
  @thor
end

Instance Method Details

#in_existing_projectObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/xnlogic/cli/core.rb', line 15

def in_existing_project
  if options_file.exist?
    previous_options = YAML.load_file(options_file.to_s)
    @options = previous_options.merge options
  else
    Xnlogic.ui.info "Not in an existing project. Please run the 'application' command first."
    exit 1
  end
  self
end

#write_optionsObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/xnlogic/cli/core.rb', line 26

def write_options
  Dir.mkdir(app.join('config')) unless app.join('config').exist?
  opts = options.clone
  ignore_options.each do |x|
    opts.delete x
  end
  File.open(options_file.to_s, 'w') do |f|
    f.puts YAML.dump opts
  end
end