Class: Architect::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/architecture-js/architect.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Application



19
20
21
22
23
24
25
# File 'lib/architecture-js/architect.rb', line 19

def initialize(path = nil)
  if path
    @root = File.expand_path(path)
  else
    @root = File.expand_path(Dir.getwd)
  end
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



15
16
17
# File 'lib/architecture-js/architect.rb', line 15

def args
  @args
end

#commandObject (readonly)

Returns the value of attribute command.



15
16
17
# File 'lib/architecture-js/architect.rb', line 15

def command
  @command
end

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/architecture-js/architect.rb', line 15

def options
  @options
end

Instance Method Details

#compileObject



60
61
62
63
64
65
66
# File 'lib/architecture-js/architect.rb', line 60

def compile
  @project = ArchitectureJS::Blueprint.init_with_config(@root)
  compress = @options[:c] || @options[:compress]
  @project.update(compress)
rescue Exception => e
  puts ArchitectureJS::Notification.error e.message
end

#createObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/architecture-js/architect.rb', line 40

def create
  app_name = @args.first
  if @args[1]
    sub_dir = @args[1] unless @args[1].match(/^-/)
  end
  blueprint = @options[:blueprint]

  raise 'You must specify a project name: architect create [project_name]' if args[0].nil?

  @root = File.expand_path sub_dir if sub_dir
  config = { name: app_name, blueprint: blueprint }

  require "#{blueprint}-architecture" unless blueprint == 'default'

  @project = ArchitectureJS::BLUEPRINTS[blueprint].new(config, @root)
  @project.create
rescue Exception => e
  puts ArchitectureJS::Notification.error e.message
end

#runObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/architecture-js/architect.rb', line 27

def run
  parse_command
  parse_options
  parse_arguments

  if @command
      self.send @command unless @command =~ /^-/
  else
    help
  end

end

#src_filesObject



77
78
79
80
81
82
83
# File 'lib/architecture-js/architect.rb', line 77

def src_files
  @project = ArchitectureJS::Blueprint.init_with_config(@root)
  puts "Source files:"
  @project.src_files.each { |f| puts "  - #{File.basename f}" }
rescue Exception => e
  puts ArchitectureJS::Notification.error e.message
end

#watchObject



68
69
70
71
72
73
74
75
# File 'lib/architecture-js/architect.rb', line 68

def watch
  @project = ArchitectureJS::Blueprint.init_with_config(@root)
  @project.update
  @watcher = @project.watch("architect is watching for changes. Type 'quit' or 'exit' to stop.")
  start_interactive_session
rescue Exception => e
  puts ArchitectureJS::Notification.error e.message
end