Class: Cor::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/cor.rb

Class Method Summary collapse

Class Method Details

.analyze_argument(args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/cor.rb', line 28

def self.analyze_argument(args)
  command = args.shift.to_s

  result = {
      :command => command.gsub(':', '_').to_sym,
      :args => args
  }

  result
end

.call_command(args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cor.rb', line 13

def self.call_command(args)
  command = self.analyze_argument(args)

  if command[:command].to_s == ''
    command[:command] = :help
  end

  if self.methods(false).include?(command[:command])
    self.send(command[:command], command[:args])
  else
    puts "undefined command #{args[0]}"
    puts "ARGS: #{args.join(', ')}"
  end
end

.help(args) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/cor.rb', line 92

def self.help(args)
  puts <<-EOS
Cor gem provides convenient commands for Code on Rmake.

  Usage:
cor help
cor version
cor command [arguments...]

  Commands:
cor version
cor project:create my_game_directory

  Information:
https://github.com/akasata/cor-gem

  About Code on Rmake:
https://core.rmake.jp/

EOS

end

.init(args) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/cor.rb', line 39

def self.init(args)
  FileUtils.mkdir_p(%w(./bin ./projects ./materials ./packages))
  unless File.exists?('./rmake.yml')
    source_root = File.expand_path('..', File.dirname(__FILE__))
    FileUtils.cp("#{source_root}/template_rmake.yml", './rmake.yml')
  end
end

.install(args) ⇒ Object



84
85
86
# File 'lib/cor.rb', line 84

def self.install(args)

end

.project_checkout(args) ⇒ Object



72
73
74
# File 'lib/cor.rb', line 72

def self.project_checkout(args)

end

.project_create(args) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cor.rb', line 47

def self.project_create(args)
  project_type = args[0]
  project_name = args[1].to_s

  unless Cor::Project_Types.include? project_type
    puts "Wrong Project Type #{project_type}"
    return
  end

  if project_name =~  /\w+/
    project_dir = "./projects/#{project_name}"
    if !File.exists?(project_dir)
      FileUtils.mkdir_p(%W(#{project_dir} #{project_dir}/materials #{project_dir}/data #{project_dir}/src))
    else
      puts "#{project_name} Project is already exists. "
    end
  else
    puts "Wrong Project Name #{project_name}. You can use [a-zA-Z_]."
  end
end

.project_packaging(args) ⇒ Object



68
69
70
# File 'lib/cor.rb', line 68

def self.project_packaging(args)

end

.project_release(args) ⇒ Object



80
81
82
# File 'lib/cor.rb', line 80

def self.project_release(args)

end

.project_upload(args) ⇒ Object



76
77
78
# File 'lib/cor.rb', line 76

def self.project_upload(args)

end

.update(args) ⇒ Object



88
89
90
# File 'lib/cor.rb', line 88

def self.update(args)

end

.version(args) ⇒ Object



9
10
11
# File 'lib/cor.rb', line 9

def self.version(args)
  puts "Code on Rmake gem Version #{Cor::VERSION}"
end