legionio 0.3.2 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +27 -10
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +7 -2
  5. data/CHANGELOG.md +21 -0
  6. data/Dockerfile +9 -0
  7. data/README.md +157 -45
  8. data/Rakefile +0 -6
  9. data/bitbucket-pipelines.yml +16 -52
  10. data/docker_deploy.rb +10 -0
  11. data/exe/legion +3 -51
  12. data/exe/legionio +53 -0
  13. data/exe/lex_gen +5 -0
  14. data/{legion.gemspec → legionio.gemspec} +25 -20
  15. data/lib/legion.rb +4 -0
  16. data/lib/legion/cli.rb +56 -0
  17. data/lib/legion/cli/chain.rb +35 -0
  18. data/lib/legion/cli/cohort.rb +10 -0
  19. data/lib/legion/cli/function.rb +41 -0
  20. data/lib/legion/cli/lex/actor.rb +31 -0
  21. data/lib/legion/cli/lex/exchange.rb +32 -0
  22. data/lib/legion/cli/lex/message.rb +32 -0
  23. data/lib/legion/cli/lex/queue.rb +45 -0
  24. data/lib/legion/cli/lex/runner.rb +70 -0
  25. data/lib/legion/cli/lex/templates/actor.erb +6 -0
  26. data/{docs/_build/html/_sources/overview.rst.txt → lib/legion/cli/lex/templates/actor_spec.erb} +0 -0
  27. data/lib/legion/cli/lex/templates/base/bitbucket.yml.erb +69 -0
  28. data/lib/legion/cli/lex/templates/base/gemfile.erb +3 -0
  29. data/lib/legion/cli/lex/templates/base/gemspec.erb +26 -0
  30. data/lib/legion/cli/lex/templates/base/gitignore.erb +11 -0
  31. data/lib/legion/cli/lex/templates/base/lex.erb +9 -0
  32. data/lib/legion/cli/lex/templates/base/lex_spec.erb +5 -0
  33. data/lib/legion/cli/lex/templates/base/lic.erb +21 -0
  34. data/lib/legion/cli/lex/templates/base/rakefile.erb +6 -0
  35. data/lib/legion/cli/lex/templates/base/readme.md.erb +2 -0
  36. data/lib/legion/cli/lex/templates/base/rubocop.yml.erb +15 -0
  37. data/lib/legion/cli/lex/templates/base/spec_helper.rb.erb +11 -0
  38. data/lib/legion/cli/lex/templates/base/version.erb +7 -0
  39. data/lib/legion/cli/lex/templates/exchange.erb +11 -0
  40. data/lib/legion/cli/lex/templates/exchange_spec.erb +0 -0
  41. data/lib/legion/cli/lex/templates/message.erb +23 -0
  42. data/lib/legion/cli/lex/templates/message_spec.erb +0 -0
  43. data/lib/legion/cli/lex/templates/queue.erb +12 -0
  44. data/lib/legion/cli/lex/templates/queue_helper.erb +24 -0
  45. data/lib/legion/cli/lex/templates/queue_spec.erb +11 -0
  46. data/lib/legion/cli/lex/templates/runner.erb +11 -0
  47. data/lib/legion/cli/lex/templates/runner_spec.erb +11 -0
  48. data/lib/legion/cli/relationship.rb +22 -0
  49. data/lib/legion/cli/task.rb +49 -0
  50. data/lib/legion/cli/trigger.rb +88 -0
  51. data/lib/legion/cli/version.rb +5 -0
  52. data/lib/legion/extensions.rb +35 -1
  53. data/lib/legion/extensions/actors/base.rb +0 -2
  54. data/lib/legion/extensions/actors/poll.rb +0 -1
  55. data/lib/legion/extensions/actors/subscription.rb +1 -0
  56. data/lib/legion/extensions/core.rb +9 -4
  57. data/lib/legion/extensions/helpers/base.rb +3 -3
  58. data/lib/legion/extensions/helpers/logger.rb +3 -6
  59. data/lib/legion/extensions/helpers/task.rb +1 -1
  60. data/lib/legion/lex.rb +89 -0
  61. data/lib/legion/service.rb +34 -3
  62. data/lib/legion/version.rb +1 -1
  63. metadata +196 -82
  64. data/bin/console +0 -16
  65. data/bin/legion +0 -49
  66. data/bin/setup +0 -8
  67. data/bin/test +0 -32
  68. data/docs/Makefile +0 -20
  69. data/docs/_build/doctrees/environment.pickle +0 -0
  70. data/docs/_build/doctrees/index.doctree +0 -0
  71. data/docs/_build/doctrees/overview.doctree +0 -0
  72. data/docs/_build/html/.buildinfo +0 -4
  73. data/docs/_build/html/_sources/index.rst.txt +0 -28
  74. data/docs/_build/html/_static/alabaster.css +0 -701
  75. data/docs/_build/html/_static/basic.css +0 -855
  76. data/docs/_build/html/_static/custom.css +0 -1
  77. data/docs/_build/html/_static/doctools.js +0 -315
  78. data/docs/_build/html/_static/documentation_options.js +0 -12
  79. data/docs/_build/html/_static/file.png +0 -0
  80. data/docs/_build/html/_static/jquery-3.5.1.js +0 -10872
  81. data/docs/_build/html/_static/jquery.js +0 -2
  82. data/docs/_build/html/_static/language_data.js +0 -297
  83. data/docs/_build/html/_static/minus.png +0 -0
  84. data/docs/_build/html/_static/plus.png +0 -0
  85. data/docs/_build/html/_static/pygments.css +0 -82
  86. data/docs/_build/html/_static/searchtools.js +0 -514
  87. data/docs/_build/html/_static/underscore-1.3.1.js +0 -999
  88. data/docs/_build/html/_static/underscore.js +0 -31
  89. data/docs/_build/html/genindex.html +0 -101
  90. data/docs/_build/html/index.html +0 -117
  91. data/docs/_build/html/objects.inv +0 -6
  92. data/docs/_build/html/overview.html +0 -98
  93. data/docs/_build/html/search.html +0 -110
  94. data/docs/_build/html/searchindex.js +0 -1
  95. data/docs/conf.py +0 -54
  96. data/docs/index.rst +0 -28
  97. data/docs/make.bat +0 -35
  98. data/lib/legion/exceptions/handled_task.rb +0 -6
  99. data/lib/legion/exceptions/invalidjson.rb +0 -5
  100. data/lib/legion/exceptions/missingargument.rb +0 -6
  101. data/lib/legion/exceptions/wrongtype.rb +0 -10
  102. data/lib/legion/exceptions/wrongtypes/array.rb +0 -8
  103. data/lib/legion/exceptions/wrongtypes/hash.rb +0 -8
  104. data/lib/legion/exceptions/wrongtypes/integer.rb +0 -8
  105. data/lib/legion/exceptions/wrongtypes/string.rb +0 -8
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require './lib/legion/version'
4
+ puts "Building docker image for Legion v#{Legion::VERSION}"
5
+ system("docker build --tag legionio/legion:v#{Legion::VERSION} .")
6
+ puts 'Pushing to hub.docker.com'
7
+ system("docker push legionio/legion:v#{Legion::VERSION}")
8
+ system("docker tag legionio/legion:v#{Legion::VERSION} legionio/legion:lastest")
9
+ system("docker push legionio/legion:v#{Legion::VERSION}")
10
+ puts 'completed'
data/exe/legion CHANGED
@@ -1,52 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'optparse'
5
-
6
- options = { action: :run }
7
-
8
- daemonize_help = 'run daemonized in the background (default: false)'
9
- pidfile_help = 'the pid filename'
10
- logfile_help = 'the log filename'
11
- include_help = 'an additional $LOAD_PATH (may be used more than once)'
12
- debug_help = 'set $DEBUG to true'
13
- warn_help = 'enable warnings'
14
- time_help = 'only run legion for X seconds'
15
-
16
- op = OptionParser.new
17
- op.banner = 'An example of how to daemonize a long running Ruby process.'
18
- op.separator ''
19
- op.separator 'Usage: server [options]'
20
- op.separator ''
21
-
22
- op.separator ''
23
- op.separator 'Process options:'
24
- op.on('-d', '--daemonize', daemonize_help) { options[:daemonize] = true }
25
- op.on('-p', '--pid PIDFILE', pidfile_help) { |value| options[:pidfile] = value }
26
- op.on('-l', '--log LOGFILE', logfile_help) { |value| options[:logfile] = value }
27
- op.on('-t', '--time 10', time_help) { |value| options[:time_limit] = value }
28
-
29
- op.separator ''
30
- op.separator 'Ruby options:'
31
- op.on('-I', '--include PATH', include_help) do |value|
32
- $LOAD_PATH.unshift(*value.split(':').map do |v|
33
- File.expand_path(v)
34
- end)
35
- end
36
- op.on('--debug', debug_help) { $DEBUG = true }
37
- op.on('--warn', warn_help) { $-w = true }
38
-
39
- op.separator ''
40
- op.separator 'Common options:'
41
- op.on('-h', '--help') { options[:action] = :help }
42
- op.on('-v', '--version') { options[:action] = :version }
43
-
44
- op.separator ''
45
- op.parse!(ARGV)
46
-
47
- unless options[:action] == :help
48
- require 'legion'
49
- Legion.start
50
- require 'legion/process'
51
- Legion::Process.new(options).run!
52
- end
2
+ require 'thor'
3
+ require 'legion/cli'
4
+ Legion::CLI.start
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+
6
+ require 'optparse'
7
+ options = { action: :run }
8
+
9
+ daemonize_help = 'run daemonized in the background (default: false)'
10
+ pidfile_help = 'the pid filename'
11
+ logfile_help = 'the log filename'
12
+ include_help = 'an additional $LOAD_PATH (may be used more than once)'
13
+ debug_help = 'set $DEBUG to true'
14
+ warn_help = 'enable warnings'
15
+ time_help = 'only run legion for X seconds'
16
+
17
+ op = OptionParser.new
18
+ op.banner = 'An example of how to daemonize a long running Ruby process.'
19
+ op.separator ''
20
+ op.separator 'Usage: server [options]'
21
+ op.separator ''
22
+
23
+ op.separator ''
24
+ op.separator 'Process options:'
25
+ op.on('-d', '--daemonize', daemonize_help) { options[:daemonize] = true }
26
+ op.on('-p', '--pid PIDFILE', pidfile_help) { |value| options[:pidfile] = value }
27
+ op.on('-l', '--log LOGFILE', logfile_help) { |value| options[:logfile] = value }
28
+ op.on('-t', '--time 10', time_help) { |value| options[:time_limit] = value }
29
+
30
+ op.separator ''
31
+ op.separator 'Ruby options:'
32
+ op.on('-I', '--include PATH', include_help) do |value|
33
+ $LOAD_PATH.unshift(*value.split(':').map do |v|
34
+ File.expand_path(v)
35
+ end)
36
+ end
37
+ op.on('--debug', debug_help) { $DEBUG = true }
38
+ op.on('--warn', warn_help) { $-w = true }
39
+
40
+ op.separator ''
41
+ op.separator 'Common options:'
42
+ op.on('-h', '--help') { options[:action] = :help }
43
+ op.on('-v', '--version') { options[:action] = :version }
44
+
45
+ op.separator ''
46
+ op.parse!(ARGV)
47
+
48
+ unless options[:action] == :help
49
+ require 'legion'
50
+ Legion.start
51
+ require 'legion/process'
52
+ Legion::Process.new(options).run!
53
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thor'
3
+ require 'legion/lex'
4
+
5
+ Legion::Cli::LexBuilder.start
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'legion/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = (RUBY_ENGINE == 'jruby' ? 'legionio-java' : 'legionio')
8
+ spec.name = 'legionio'
9
9
  spec.version = Legion::VERSION
10
10
  spec.authors = ['Esity']
11
11
  spec.email = ['matthewdiverson@gmail.com']
@@ -13,47 +13,52 @@ Gem::Specification.new do |spec|
13
13
  spec.summary = 'Legion Core Software to string it all together'
14
14
  spec.description = 'Legion Core runs Legion Framwork'
15
15
  spec.homepage = 'https://bitbucket.org/legion-io/legion/'
16
- spec.license = 'MIT'
16
+ spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/legion/src/master/'
17
+ spec.metadata['documentation_uri'] = 'https://legionio.atlassian.net/wiki/spaces/LEGION/overview'
18
+ spec.metadata['bug_tracker_uri'] = 'https://legionio.atlassian.net/browse/LEG'
19
+ spec.license = 'MIT'
17
20
  spec.required_ruby_version = '>= 2.5.0'
18
21
 
19
22
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
23
  f.match(%r{^(test|spec|features)/})
21
24
  end
25
+
22
26
  spec.bindir = 'exe'
23
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
28
  spec.require_paths = ['lib']
25
29
 
26
- if RUBY_ENGINE == 'jruby'
27
- spec.add_dependency 'jrjackson'
28
- spec.add_dependency 'legion-data-java'
29
- spec.add_dependency 'legion-transport-java'
30
- spec.add_dependency 'march_hare'
31
- else
32
- spec.add_dependency 'concurrent-ruby-ext'
33
- spec.add_dependency 'legion-data'
34
- spec.add_dependency 'legion-transport'
35
- spec.add_dependency 'oj'
36
- end
37
-
38
- spec.add_dependency 'concurrent-ruby'
39
- spec.add_dependency 'daemons'
40
- spec.add_dependency 'hashdiff'
30
+ spec.add_dependency 'concurrent-ruby', '>= 1.1.7'
31
+ spec.add_dependency 'concurrent-ruby-ext', '>= 1.1.7'
32
+ spec.add_dependency 'daemons', '>= 1.3.1'
33
+ spec.add_dependency 'oj', '>= 3.10'
34
+ spec.add_dependency 'thor', '>= 1'
41
35
 
42
- spec.add_dependency 'bunny'
43
36
  spec.add_dependency 'legion-cache'
44
- spec.add_dependency 'legion-crypt'
37
+ spec.add_dependency 'legion-crypt', '>= 0.2.0'
45
38
  spec.add_dependency 'legion-exceptions'
46
39
  spec.add_dependency 'legion-json'
47
40
  spec.add_dependency 'legion-logging'
48
41
  spec.add_dependency 'legion-settings'
42
+ spec.add_dependency 'legion-transport', '>= 1.1.8'
49
43
 
50
44
  spec.add_dependency 'lex-node'
51
45
 
52
- spec.add_development_dependency 'bundler'
53
46
  spec.add_development_dependency 'codecov'
47
+ spec.add_development_dependency 'legion-data'
54
48
  spec.add_development_dependency 'rake'
55
49
  spec.add_development_dependency 'rspec'
56
50
  spec.add_development_dependency 'rspec_junit_formatter'
57
51
  spec.add_development_dependency 'rubocop'
52
+ spec.add_development_dependency 'rubocop-rake'
53
+ spec.add_development_dependency 'rubocop-rspec'
58
54
  spec.add_development_dependency 'simplecov'
55
+
56
+ spec.add_development_dependency 'lex-conditioner'
57
+ spec.add_development_dependency 'lex-health'
58
+ spec.add_development_dependency 'lex-http'
59
+ spec.add_development_dependency 'lex-lex'
60
+ spec.add_development_dependency 'lex-log'
61
+ spec.add_development_dependency 'lex-scheduler'
62
+ spec.add_development_dependency 'lex-tasker'
63
+ spec.add_development_dependency 'lex-transformer'
59
64
  end
@@ -18,4 +18,8 @@ module Legion
18
18
  def self.shutdown
19
19
  @service.shutdown
20
20
  end
21
+
22
+ def self.reload
23
+ @service.reload
24
+ end
21
25
  end
@@ -0,0 +1,56 @@
1
+ # require 'legion/cli/version'
2
+ require 'thor'
3
+ require 'legion'
4
+ require 'legion/service'
5
+
6
+ require 'legion/lex'
7
+ require 'legion/cli/cohort'
8
+
9
+ require 'legion/cli/relationship'
10
+ require 'legion/cli/task'
11
+ require 'legion/cli/chain'
12
+ require 'legion/cli/trigger'
13
+ require 'legion/cli/function'
14
+
15
+ module Legion
16
+ class CLI < Thor
17
+ include Thor::Actions
18
+ check_unknown_options!
19
+
20
+ def self.exit_on_failure?
21
+ true
22
+ end
23
+
24
+ def self.source_root
25
+ File.dirname(__FILE__)
26
+ end
27
+
28
+ desc 'version', 'Display MyGem version'
29
+ map %w[-v --version] => :version
30
+
31
+ def version
32
+ say "Legion::CLI #{VERSION}"
33
+ end
34
+
35
+ desc 'lex', 'used to build LEXs'
36
+ subcommand 'lex', Legion::Cli::LexBuilder
37
+
38
+ desc 'cohort', ''
39
+ subcommand 'cohort', Legion::Cli::Cohort
40
+
41
+ desc 'function', 'deal with functions'
42
+ subcommand 'function', Legion::Cli::Function
43
+
44
+ desc 'relationship', 'creates and manages relationships'
45
+ subcommand 'relationship', Legion::Cli::Relationship
46
+
47
+ desc 'task', 'creates and manages tasks'
48
+ subcommand 'task', Legion::Cli::Task
49
+
50
+ desc 'chain', 'creates and manages chains'
51
+ subcommand 'chain', Legion::Cli::Chain
52
+
53
+ desc 'trigger', 'sends a task to a worker'
54
+ subcommand 'trigger', Legion::Cli::Trigger
55
+ end
56
+ end
@@ -0,0 +1,35 @@
1
+ module Legion
2
+ class Cli
3
+ class Chain < Thor
4
+ desc 'create', 'create'
5
+ def create(name)
6
+ Legion::Service.new(cache: false, crypt: false, extensions: false, log_level: 'error')
7
+ say "chain created, id: #{Legion::Data::Model::Chain.insert({ name: name })}", :green
8
+ end
9
+
10
+ desc 'show', 'show'
11
+ option :limit, type: :numeric, required: true, default: 10, desc: 'how many tasks to return'
12
+ def show
13
+ Legion::Service.new(cache: false, crypt: false, extensions: false, log_level: 'error')
14
+ rows = [%w[id name active]]
15
+ Legion::Data::Model::Chain.limit(options[:limit]).order(:id).reverse_each do |row|
16
+ rows.push([row.values[:id], row.values[:name], row.values[:active]])
17
+ end
18
+
19
+ print_table rows
20
+ end
21
+
22
+ desc 'delete', 'delete'
23
+ option :confirm, type: :boolean
24
+ def delete(id)
25
+ Legion::Service.new(cache: false, crypt: false, extensions: false, log_level: 'error')
26
+ return if !options[:confirm] && !(yes? "Are you sure you want to delete chain #{id} and all dependent relationships", :red)
27
+
28
+ Legion::Data::Model::Chain[id].delete
29
+ say 'Deleted!'
30
+ end
31
+
32
+ default_task :show
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ module Legion
2
+ class Cli
3
+ class Cohort < Thor
4
+ desc 'import :id', 'imports a cohort for usage'
5
+ def import(id)
6
+ say "Importing Cohort #{id}", :green
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,41 @@
1
+ module Legion
2
+ class Cli
3
+ class Function < Thor
4
+ desc 'find', 'find'
5
+ option :internal, type: :boolean, default: false
6
+ def find
7
+ Legion::Service.new(cache: false, crypt: false, extensions: false, log_level: 'error')
8
+ response = ask 'trigger extension?', limited_to: Legion::Data::Model::Extension.map(:name)
9
+ trigger_extension = Legion::Data::Model::Extension.where(name: response).first
10
+ runners = Legion::Data::Model::Runner.where(extension_id: trigger_extension.values[:id])
11
+ if runners.count == 1
12
+ trigger_runner = runners.first
13
+ say "Auto selecting #{trigger_runner.values[:name]} since it is the only option"
14
+ else
15
+ response = ask 'trigger runner?', limited_to: runners.map(:name)
16
+ trigger_runner = Legion::Data::Model::Runner.where(name: response).where(extension_id: trigger_extension.values[:id]).first
17
+ end
18
+
19
+ functions = Legion::Data::Model::Function.where(runner_id: trigger_runner.values[:id])
20
+
21
+ if functions.count == 1
22
+ trigger_function = functions.first
23
+ say "Auto selecting #{trigger_function.values[:name]} since it is the only option"
24
+ else
25
+ response = ask 'trigger function?', limited_to: Legion::Data::Model::Function.where(runner_id: trigger_runner.values[:id]).map(:name)
26
+ trigger_function = trigger_runner.functions(name: response).first
27
+ end
28
+ # say "#{trigger_runner.values[:namespace]}.#{trigger_function.values[:name]} selected as trigger", :green, :italicized
29
+ # mute { trigger_function.values[:id] }
30
+ say trigger_function.values[:id]
31
+ # puts self.methods(false)
32
+ end
33
+
34
+ desc 'delete', 'delete'
35
+ def delete; end
36
+
37
+ desc 'activate', 'activate'
38
+ def activate; end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,31 @@
1
+ module Legion
2
+ class Cli
3
+ module Lex
4
+ class Actor < Thor
5
+ include Thor::Actions
6
+
7
+ def self.source_root
8
+ File.dirname(__FILE__)
9
+ end
10
+
11
+ no_commands do
12
+ def lex
13
+ Dir.pwd.split('/').last.split('-').last
14
+ end
15
+ end
16
+
17
+ desc 'create :name', 'creates a new actor'
18
+ method_option :type, enum: %w[subscription every poll once loop], default: 'subscription'
19
+ def create(name)
20
+ template('templates/actor.erb', "#{lex}/lib/actors/#{name}.rb", { name: name, lex: lex, type: options[:type] })
21
+ end
22
+
23
+ desc 'delete :name', 'deletes an actor'
24
+ def delete(name)
25
+ remove_file("lib/legion/extensions/#{lex}/actors/#{name}.rb")
26
+ remove_file("spec/actors/#{name}_spec.rb")
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ module Legion
2
+ class Cli
3
+ module Lex
4
+ class Exchange < Thor
5
+ include Thor::Actions
6
+
7
+ def self.source_root
8
+ File.dirname(__FILE__)
9
+ end
10
+
11
+ no_commands do
12
+ def lex
13
+ Dir.pwd.split('/').last.split('-').last
14
+ end
15
+ end
16
+
17
+ desc 'create :name', 'creates a new exchange class'
18
+ def create(name)
19
+ template('templates/queue.erb', "lib/legion/extensions/#{lex}/transport/exchanges/#{name}.rb", { name: name, lex: lex })
20
+ template('templates/queue_spec.erb', "spec/exchanges/#{name}_spec.rb", { name: name, lex: lex })
21
+ end
22
+
23
+ desc 'delete :name', 'deletes an exchange class'
24
+ def delete(name)
25
+ remove_file("lib/legion/extensions/#{lex}/transport/exchanges/#{name}.rb")
26
+ remove_file("spec/exchanges/#{name}_spec.rb")
27
+ remove_file("spec/transport/exchanges/#{name}_spec.rb")
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module Legion
2
+ class Cli
3
+ module Lex
4
+ class Message < Thor
5
+ include Thor::Actions
6
+
7
+ def self.source_root
8
+ File.dirname(__FILE__)
9
+ end
10
+
11
+ no_commands do
12
+ def lex
13
+ Dir.pwd.split('/').last.split('-').last
14
+ end
15
+ end
16
+
17
+ desc 'create :name', 'creates a new message'
18
+ def create(name)
19
+ template('templates/message.erb', "lib/legion/extensions/#{lex}/transport/messages/#{name}.rb", { name: name, lex: lex })
20
+ template('templates/message_spec.erb', "spec/messages/#{name}_spec.rb", { name: name, lex: lex })
21
+ end
22
+
23
+ desc 'delete :name', 'deletes a message class'
24
+ def delete(name)
25
+ remove_file("lib/legion/extensions/#{lex}/transport/messages/#{name}.rb")
26
+ remove_file("spec/messages/#{name}_spec.rb")
27
+ remove_file("spec/transport/messages/#{name}_spec.rb")
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end