cody 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f1f0a386b9a31e991c4780b802ad8db436b1a7fc0a620eae0be450b44ea35bb
4
- data.tar.gz: b22ac1a609aca0baebe683b51818253b7eae58512e9bbd0c6f9c4019ab94d800
3
+ metadata.gz: 53eb7e5d569f9ac01fc442092dc96b291ecb6769b7a392b24fa3158b62afd294
4
+ data.tar.gz: 812af356ba1149b27a0fdd170b66c1b6d0a16257ce4339c46ae25597c22bc0b0
5
5
  SHA512:
6
- metadata.gz: bab07629f7f5762273e3a0c199514ef5cab34edd7350e725c26c1d55c8a25d92d2e5515ea5074b497c6272cde07861741586dd28951b71856a8cd5b07163d0c1
7
- data.tar.gz: 3e14ba65fcb5ab8d2abfe0cef22b370725cf65b779cbeacfa080f5e4a1bca526072f30b9b9993ebf8162f7a61b5315e00625099940a4192c69533c2c5220e594
6
+ metadata.gz: 563fbd9bffdc2a04a7124e6ce363c40a143dec815d382f6ecc05827e10d865eaa64b2793e56a05f28ae5ed18466a1eddb58eb59c2a9c0765184e5dbd4864b5c5
7
+ data.tar.gz: 808f60f39fd12071dd5bcc07e110f9b4e735edea2d9096a9fd149bc1ceebc64dc67e54a610aabf419c58ba3846c9e9af7bd919bd551cfa15215efd864efd75e9
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.8.2]
7
+ - #9 add cody stop command
8
+ - #10 add evaluate interface methods
9
+
6
10
  ## [0.8.1]
7
11
  - #8 report build time at end of logs
8
12
 
@@ -0,0 +1,21 @@
1
+ # Base only for Stop and Start currently.
2
+ module Cody
3
+ class Base
4
+ include AwsServices
5
+
6
+ def initialize(options)
7
+ @options = options
8
+ @project_name = options[:project_name] || inferred_project_name
9
+ @full_project_name = project_name_convention(@project_name)
10
+ end
11
+
12
+ def run_with_exception_handling
13
+ yield
14
+ rescue Aws::CodeBuild::Errors::ResourceNotFoundException => e
15
+ puts "ERROR: #{e.class}: #{e.message}".color(:red)
16
+ puts "CodeBuild project #{@full_project_name} not found."
17
+ rescue Aws::CodeBuild::Errors::InvalidInputException => e
18
+ puts "ERROR: #{e.class}: #{e.message}".color(:red)
19
+ end
20
+ end
21
+ end
@@ -41,6 +41,14 @@ module Cody
41
41
  Start.new(options.merge(project_name: project_name)).run
42
42
  end
43
43
 
44
+ desc "stop", "stop codebuild project."
45
+ long_desc Help.text(:stop)
46
+ option :build_id, desc: "Project build id. Defaults to most recent."
47
+ common_options.call
48
+ def stop(project_name=nil)
49
+ Stop.new(options.merge(project_name: project_name)).run
50
+ end
51
+
44
52
  desc "logs", "Prints out logs for codebuild project."
45
53
  long_desc Help.text(:logs)
46
54
  option :build_id, desc: "Project build id. Defaults to most recent."
@@ -1,5 +1,7 @@
1
1
  module Cody
2
2
  module Evaluate
3
+ include Interface
4
+
3
5
  def evaluate(path)
4
6
  source_code = IO.read(path)
5
7
  begin
@@ -0,0 +1,12 @@
1
+ module Cody::Evaluate
2
+ module Interface
3
+ # Useful interface methods if want to run more generalized code in the evaluated DSL files
4
+ def project_name
5
+ @options["project_name"]
6
+ end
7
+
8
+ def full_project_name
9
+ @options["full_project_name"]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ # Examples
2
+
3
+ cody stop # infers the name from the parent folder
4
+ cody stop stack-name # looks up project via CloudFormation stack
5
+ cody stop demo-project # looks up project via codebuild project name
6
+
7
+ ## Type Option
8
+
9
+ Examples
10
+
11
+ cody stop --type vpc
@@ -1,20 +1,9 @@
1
1
  module Cody
2
- class Logs
3
- include AwsServices
4
-
5
- def initialize(options)
6
- @options = options
7
- @project_name = options[:project_name] || inferred_project_name
8
- @full_project_name = project_name_convention(@project_name)
9
- end
10
-
2
+ class Logs < Base
11
3
  def run
12
- Tailer.new(@options, build_id).run
13
- rescue Aws::CodeBuild::Errors::ResourceNotFoundException => e
14
- puts "ERROR: #{e.class}: #{e.message}".color(:red)
15
- puts "CodeBuild project #{@full_project_name} not found."
16
- rescue Aws::CodeBuild::Errors::InvalidInputException => e
17
- puts "ERROR: #{e.class}: #{e.message}".color(:red)
4
+ run_with_exception_handling do
5
+ Tailer.new(@options, build_id).run
6
+ end
18
7
  end
19
8
 
20
9
  def build_id
@@ -0,0 +1,17 @@
1
+ module Cody
2
+ class Stop < Base
3
+ def run
4
+ run_with_exception_handling do
5
+ codebuild.stop_build(id: build_id)
6
+ puts "Build has been stopped: #{build_id}"
7
+ end
8
+ end
9
+
10
+ def build_id
11
+ return @options[:build_id] if @options[:build_id]
12
+
13
+ resp = codebuild.list_builds_for_project(project_name: @full_project_name)
14
+ resp.ids.first # most recent build_id
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Cody
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cody
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
@@ -263,6 +263,7 @@ files:
263
263
  - lib/cody/autoloader.rb
264
264
  - lib/cody/aws_services.rb
265
265
  - lib/cody/aws_services/helpers.rb
266
+ - lib/cody/base.rb
266
267
  - lib/cody/cli.rb
267
268
  - lib/cody/command.rb
268
269
  - lib/cody/completer.rb
@@ -278,6 +279,7 @@ files:
278
279
  - lib/cody/dsl/role.rb
279
280
  - lib/cody/dsl/schedule.rb
280
281
  - lib/cody/evaluate.rb
282
+ - lib/cody/evaluate/interface.rb
281
283
  - lib/cody/help.rb
282
284
  - lib/cody/help/completion.md
283
285
  - lib/cody/help/completion_script.md
@@ -285,6 +287,7 @@ files:
285
287
  - lib/cody/help/init.md
286
288
  - lib/cody/help/logs.md
287
289
  - lib/cody/help/start.md
290
+ - lib/cody/help/stop.md
288
291
  - lib/cody/init.rb
289
292
  - lib/cody/logs.rb
290
293
  - lib/cody/project.rb
@@ -294,6 +297,7 @@ files:
294
297
  - lib/cody/setting.rb
295
298
  - lib/cody/stack.rb
296
299
  - lib/cody/start.rb
300
+ - lib/cody/stop.rb
297
301
  - lib/cody/tailer.rb
298
302
  - lib/cody/update.rb
299
303
  - lib/cody/variables.rb