shiprails 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c41f419db3aec35abe63a8626d686127b848d811
4
- data.tar.gz: 8a846097d99b22a449d23554db3e5434592634ad
3
+ metadata.gz: 9f6d4d236056ae63cc0c45a01ffc84f1eb579046
4
+ data.tar.gz: 142517c6bdcec225dae78167de982fd257979ec3
5
5
  SHA512:
6
- metadata.gz: 0ea5aa16a9840fc0bcd813a078f94a30c372d512bda15d99be5490a7d5aa144b83d1ef6d9b5d1c3f3697b488c115cc65e609f86cf00868d139c338c4917c0310
7
- data.tar.gz: 08272990a67c8fa99cab6258ae71a296b9893386e1dd215423e065d8c26d12ff96bb5fbaae95e99a228193cd3e741860c14b1adf9c88ea75b734c1a76fce2def
6
+ metadata.gz: d63e1ae14db4b0e055082b48da424f1c365f77acc20acf72f1b82dbc4587534fec163c2fab5918905722c9585b5db46c214d9be6c2d0bd9f06bf24c66e3cd6c4
7
+ data.tar.gz: 78e7470fb2b5f4c98e41affeda518ad11438aa521f2788832b259335fb1d340defd52ccdf28b14ec427fc948179265f8d2331699a4f99a08029006200b2f3c6f
@@ -16,37 +16,45 @@ module Shiprails
16
16
  say "TODO: store development config vars"
17
17
  end
18
18
 
19
+ desc "exec", "Run interactive commands"
20
+ method_option "no-rm",
21
+ default: false,
22
+ desc: "Remove container changes after use",
23
+ type: :boolean
24
+ def exec(*command_args)
25
+ build_command_args = ["docker-compose", "run"]
26
+ build_command_args << "--rm" unless options['no-rm']
27
+ build_command_args << "app"
28
+ build_command_args += command_args
29
+ command_string = build_command_args.join(' ')
30
+ run command_string
31
+ end
32
+
19
33
  desc "up", "Hoist app and services"
20
34
  def up
21
35
  run "docker-compose up"
22
36
  end
23
37
 
24
- desc "bundle", "Run bundler commands"
25
- def bundle(*command)
26
- command_string = command.join(' ')
27
- if command_string.start_with?("exec")
28
- run "docker-compose run --rm app bundle #{command_string}"
29
- else
30
- run "docker-compose run app bundle #{command_string}"
31
- end
32
- end
33
-
34
- desc "rails", "Run rails commands"
35
- def rails(*command)
36
- command_string = command.join(' ')
37
- run "docker-compose run --rm app bundle exec rails #{command_string}"
38
+ def self.configuration
39
+ YAML.load(File.read(".shiprails.yml")).deep_symbolize_keys rescue {}
38
40
  end
39
41
 
40
- desc "bash", "Run bash commands"
41
- def bash(*command)
42
- command_string = command.join(' ')
43
- run "docker-compose run --rm app bash #{command_string}"
44
- end
45
-
46
- private
47
-
48
- def configuration
49
- YAML.load(File.read(".shiprails.yml")).deep_symbolize_keys
42
+ if commands = configuration[:exec]
43
+ commands.each do |name, command|
44
+ desc name, "port exec #{command}"
45
+ method_option "no-rm",
46
+ default: false,
47
+ desc: "Remove container changes after use",
48
+ type: :boolean
49
+ define_method name.to_sym do |*command_args|
50
+ build_command_args = ["docker-compose", "run"]
51
+ build_command_args << "--rm" unless options['no-rm']
52
+ build_command_args << "app"
53
+ build_command_args += command.split(' ') + command_args
54
+ command_string = build_command_args.join(' ')
55
+ run command_string
56
+ end
57
+ end
50
58
  end
51
59
 
52
60
  end
@@ -32,6 +32,16 @@ module Shiprails
32
32
  ecs_exec(region, cluster_name, service, command_string, ssh_private_key_path)
33
33
  end
34
34
 
35
+ no_commands do
36
+ def run_shorthand_command(command_args=nil, opts=nil)
37
+ options = opts unless opts.nil?
38
+ cluster_name = "#{project_name}_#{environment}"
39
+ command_string = command_args.join ' '
40
+ ssh_private_key_path = private_key
41
+ ecs_exec(region, cluster_name, service, command_string, ssh_private_key_path)
42
+ end
43
+ end
44
+
35
45
  private
36
46
 
37
47
  def configuration
@@ -1,4 +1,8 @@
1
1
  config_s3_bucket: '<%= config_s3_bucket %>'
2
+ exec:
3
+ bash: "bash"
4
+ bundle: "bundle exec"
5
+ rails: "bundle exec rails"
2
6
  private_key_path: '<%= ec2_ssh_private_key_path %>'
3
7
  project_name: '<%= project_name %>'
4
8
  services:
@@ -51,11 +51,40 @@ module Shiprails
51
51
  Scale.start
52
52
  end
53
53
 
54
- private
55
-
56
- def configuration
57
- YAML.load(File.read(".shiprails.yml")).deep_symbolize_keys
54
+ def self.configuration
55
+ YAML.load(File.read(".shiprails.yml")).deep_symbolize_keys rescue {}
58
56
  end
59
57
 
58
+ if commands = configuration[:exec]
59
+ commands.each do |name, command|
60
+ desc name, "ship exec #{command}"
61
+ method_option "path",
62
+ aliases: ["-p"],
63
+ default: ".",
64
+ desc: "Specify a configuration path"
65
+ method_option "environment",
66
+ aliases: ["-e"],
67
+ desc: "Specify the environment"
68
+ method_option "region",
69
+ aliases: ["-r"],
70
+ default: "us-west-2",
71
+ desc: "Specify the region"
72
+ method_option "service",
73
+ aliases: ["-a"],
74
+ default: "app",
75
+ desc: "Specify the service name"
76
+ method_option "private-key",
77
+ aliases: ["-pk"],
78
+ desc: "Specify the AWS SSH private key path"
79
+ define_method name.to_sym do |*command_args|
80
+ require "shiprails/ship/exec"
81
+ built_arguments = command.split(' ') + command_args
82
+ built_options = options.map{|k,v| "--#{k} #{v}"}
83
+ script = Exec.new built_arguments, built_options
84
+ script.run_shorthand_command built_arguments, options
85
+ end
86
+ end
87
+ end
88
+
60
89
  end
61
90
  end
@@ -1,3 +1,3 @@
1
1
  module Shiprails
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shiprails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zane Shannon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-22 00:00:00.000000000 Z
11
+ date: 2017-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  requirements: []
189
189
  rubyforge_project:
190
- rubygems_version: 2.5.1
190
+ rubygems_version: 2.6.11
191
191
  signing_key:
192
192
  specification_version: 4
193
193
  summary: Shiprails helps you deploy Rails to AWS ECS.