codebuild 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: eddc827d24d5707f612e5fc445c838a5ff90293e21518ecb3b65f33211601788
4
+ data.tar.gz: ee1885f87b9a060622957287f4d35f772d02924acb3de20ad9e08faa442063e9
5
+ SHA512:
6
+ metadata.gz: 8f49961753e2106d88252b038bfdc268517be497f2a4361f7edc8a1694bcc4c2c146ec872ae8fa94ac1d42168f250c92b4aa2e41f812ae3cf4cde3b9c6bc9710
7
+ data.tar.gz: 98133343e44e59f1dcb33db2136995a4caf121c865b51eb2ac978e2277984bbd930bcd8565bbe6c7673608810d00568f98e6febf4e3f47a6c158f125b446b32b
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ _yardoc
7
+ coverage
8
+ doc/
9
+ InstalledFiles
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,7 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
+
6
+ ## [0.1.0]
7
+ - Initial release.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem dependencies in codebuild.gemspec
4
+ gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
@@ -0,0 +1,80 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ codebuild (0.1.0)
5
+ activesupport
6
+ aws-sdk-codebuild
7
+ rainbow
8
+ thor
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (5.2.3)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 0.7, < 2)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ aws-eventstream (1.0.2)
19
+ aws-partitions (1.148.0)
20
+ aws-sdk-codebuild (1.32.0)
21
+ aws-sdk-core (~> 3, >= 3.48.2)
22
+ aws-sigv4 (~> 1.1)
23
+ aws-sdk-core (3.48.3)
24
+ aws-eventstream (~> 1.0, >= 1.0.2)
25
+ aws-partitions (~> 1.0)
26
+ aws-sigv4 (~> 1.1)
27
+ jmespath (~> 1.0)
28
+ aws-sigv4 (1.1.0)
29
+ aws-eventstream (~> 1.0, >= 1.0.2)
30
+ byebug (11.0.1)
31
+ cli_markdown (0.1.0)
32
+ codeclimate-test-reporter (1.0.9)
33
+ simplecov (<= 0.13)
34
+ concurrent-ruby (1.1.5)
35
+ diff-lcs (1.3)
36
+ docile (1.1.5)
37
+ i18n (1.6.0)
38
+ concurrent-ruby (~> 1.0)
39
+ jmespath (1.4.0)
40
+ json (2.2.0)
41
+ minitest (5.11.3)
42
+ rainbow (3.0.0)
43
+ rake (12.3.2)
44
+ rspec (3.8.0)
45
+ rspec-core (~> 3.8.0)
46
+ rspec-expectations (~> 3.8.0)
47
+ rspec-mocks (~> 3.8.0)
48
+ rspec-core (3.8.0)
49
+ rspec-support (~> 3.8.0)
50
+ rspec-expectations (3.8.2)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.8.0)
53
+ rspec-mocks (3.8.0)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.8.0)
56
+ rspec-support (3.8.0)
57
+ simplecov (0.13.0)
58
+ docile (~> 1.1.0)
59
+ json (>= 1.8, < 3)
60
+ simplecov-html (~> 0.10.0)
61
+ simplecov-html (0.10.2)
62
+ thor (0.20.3)
63
+ thread_safe (0.3.6)
64
+ tzinfo (1.2.5)
65
+ thread_safe (~> 0.1)
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ bundler
72
+ byebug
73
+ cli_markdown
74
+ codebuild!
75
+ codeclimate-test-reporter
76
+ rake
77
+ rspec
78
+
79
+ BUNDLED WITH
80
+ 2.0.1
@@ -0,0 +1,19 @@
1
+ guard "bundler", cmd: "bundle" do
2
+ watch("Gemfile")
3
+ watch(/^.+\.gemspec/)
4
+ end
5
+
6
+ guard :rspec, cmd: "bundle exec rspec" do
7
+ require "guard/rspec/dsl"
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Tung Nguyen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # Codebuild
2
+
3
+ CodeBuild tool.
4
+
5
+ ## Usage
6
+
7
+ codebuild init
8
+ codebuild create
9
+ codebuild update
10
+ codebuild start
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem "codebuild"
17
+
18
+ And then execute:
19
+
20
+ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ gem install codebuild
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am "Add some feature"`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ task default: :spec
5
+
6
+ RSpec::Core::RakeTask.new
7
+
8
+ require_relative "lib/codebuild"
9
+ require "cli_markdown"
10
+ desc "Generates cli reference docs as markdown"
11
+ task :docs do
12
+ CliMarkdown::Creator.create_all(cli_class: Codebuild::CLI, cli_name: "codebuild")
13
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "codebuild/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "codebuild"
8
+ spec.version = Codebuild::VERSION
9
+ spec.authors = ["Tung Nguyen"]
10
+ spec.email = ["tongueroo@gmail.com"]
11
+ spec.summary = "Codebuild tool"
12
+ spec.homepage = "https://github.com/tongueroo/codebuild"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "activesupport"
22
+ spec.add_dependency "rainbow"
23
+ spec.add_dependency "thor"
24
+ spec.add_dependency "aws-sdk-codebuild"
25
+
26
+ spec.add_development_dependency "bundler"
27
+ spec.add_development_dependency "byebug"
28
+ spec.add_development_dependency "cli_markdown"
29
+ spec.add_development_dependency "rake"
30
+ spec.add_development_dependency "rspec"
31
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Trap ^C
4
+ Signal.trap("INT") {
5
+ puts "\nCtrl-C detected. Exiting..."
6
+ sleep 1
7
+ exit
8
+ }
9
+
10
+ $:.unshift(File.expand_path("../../lib", __FILE__))
11
+ require "codebuild"
12
+ require "codebuild/cli"
13
+
14
+ Codebuild::CLI.start(ARGV)
@@ -0,0 +1,15 @@
1
+ $:.unshift(File.expand_path("../", __FILE__))
2
+ require "aws-sdk-codebuild"
3
+ require "codebuild/version"
4
+ require "rainbow/ext/string"
5
+
6
+ module Codebuild
7
+ class Error < StandardError; end
8
+
9
+ autoload :CLI, "codebuild/cli"
10
+ autoload :Command, "codebuild/command"
11
+ autoload :Completer, "codebuild/completer"
12
+ autoload :Completion, "codebuild/completion"
13
+ autoload :Help, "codebuild/help"
14
+ autoload :Sub, "codebuild/sub"
15
+ end
@@ -0,0 +1,29 @@
1
+ module Codebuild
2
+ class CLI < Command
3
+ class_option :verbose, type: :boolean
4
+ class_option :noop, type: :boolean
5
+
6
+ desc "init", "Initialize project with .codebuild files"
7
+ long_desc Help.text(:init)
8
+ def init
9
+ puts "init called"
10
+ end
11
+
12
+ desc "completion *PARAMS", "Prints words for auto-completion."
13
+ long_desc Help.text("completion")
14
+ def completion(*params)
15
+ Completer.new(CLI, *params).run
16
+ end
17
+
18
+ desc "completion_script", "Generates a script that can be eval to setup auto-completion."
19
+ long_desc Help.text("completion_script")
20
+ def completion_script
21
+ Completer::Script.generate
22
+ end
23
+
24
+ desc "version", "prints version"
25
+ def version
26
+ puts VERSION
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,82 @@
1
+ require "thor"
2
+
3
+ # Override thor's long_desc identation behavior
4
+ # https://github.com/erikhuda/thor/issues/398
5
+ class Thor
6
+ module Shell
7
+ class Basic
8
+ def print_wrapped(message, options = {})
9
+ message = "\n#{message}" unless message[0] == "\n"
10
+ stdout.puts message
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ module Codebuild
17
+ class Command < Thor
18
+ class << self
19
+ def dispatch(m, args, options, config)
20
+ # Allow calling for help via:
21
+ # codebuild command help
22
+ # codebuild command -h
23
+ # codebuild command --help
24
+ # codebuild command -D
25
+ #
26
+ # as well thor's normal way:
27
+ #
28
+ # codebuild help command
29
+ help_flags = Thor::HELP_MAPPINGS + ["help"]
30
+ if args.length > 1 && !(args & help_flags).empty?
31
+ args -= help_flags
32
+ args.insert(-2, "help")
33
+ end
34
+
35
+ # codebuild version
36
+ # codebuild --version
37
+ # codebuild -v
38
+ version_flags = ["--version", "-v"]
39
+ if args.length == 1 && !(args & version_flags).empty?
40
+ args = ["version"]
41
+ end
42
+
43
+ super
44
+ end
45
+
46
+ # Override command_help to include the description at the top of the
47
+ # long_description.
48
+ def command_help(shell, command_name)
49
+ meth = normalize_command_name(command_name)
50
+ command = all_commands[meth]
51
+ alter_command_description(command)
52
+ super
53
+ end
54
+
55
+ def alter_command_description(command)
56
+ return unless command
57
+
58
+ # Add description to beginning of long_description
59
+ long_desc = if command.long_description
60
+ "#{command.description}\n\n#{command.long_description}"
61
+ else
62
+ command.description
63
+ end
64
+
65
+ # add reference url to end of the long_description
66
+ unless website.empty?
67
+ full_command = [command.ancestor_name, command.name].compact.join('-')
68
+ url = "#{website}/reference/codebuild-#{full_command}"
69
+ long_desc += "\n\nHelp also available at: #{url}"
70
+ end
71
+
72
+ command.long_description = long_desc
73
+ end
74
+ private :alter_command_description
75
+
76
+ # meant to be overriden
77
+ def website
78
+ ""
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,161 @@
1
+ =begin
2
+ Code Explanation:
3
+
4
+ There are 3 types of things to auto-complete:
5
+
6
+ 1. command: the command itself
7
+ 2. parameters: command parameters.
8
+ 3. options: command options
9
+
10
+ Here's an example:
11
+
12
+ mycli hello name --from me
13
+
14
+ * command: hello
15
+ * parameters: name
16
+ * option: --from
17
+
18
+ When command parameters are done processing, the remaining completion words will be options. We can tell that the command params are completed based on the method arity.
19
+
20
+ ## Arity
21
+
22
+ For example, say you had a method for a CLI command with the following form:
23
+
24
+ ufo scale service count --cluster development
25
+
26
+ It's equivalent ruby method:
27
+
28
+ scale(service, count) = has an arity of 2
29
+
30
+ So typing:
31
+
32
+ ufo scale service count [TAB] # there are 3 parameters including the "scale" command according to Thor's CLI processing.
33
+
34
+ So the completion should only show options, something like this:
35
+
36
+ --noop --verbose --cluster
37
+
38
+ ## Splat Arguments
39
+
40
+ When the ruby method has a splat argument, it's arity is negative. Here are some example methods and their arities.
41
+
42
+ ship(service) = 1
43
+ scale(service, count) = 2
44
+ ships(*services) = -1
45
+ foo(example, *rest) = -2
46
+
47
+ Fortunately, negative and positive arity values are processed the same way. So we take simply take the absolute value of the arity and process it the same.
48
+
49
+ Here are some test cases, hit TAB after typing the command:
50
+
51
+ codebuild completion
52
+ codebuild completion hello
53
+ codebuild completion hello name
54
+ codebuild completion hello name --
55
+ codebuild completion hello name --noop
56
+
57
+ codebuild completion
58
+ codebuild completion sub:goodbye
59
+ codebuild completion sub:goodbye name
60
+
61
+ ## Subcommands and Thor::Group Registered Commands
62
+
63
+ Sometimes the commands are not simple thor commands but are subcommands or Thor::Group commands. A good specific example is the ufo tool.
64
+
65
+ * regular command: ufo ship
66
+ * subcommand: ufo docker
67
+ * Thor::Group command: ufo init
68
+
69
+ Auto-completion accounts for each of these type of commands.
70
+ =end
71
+ module Codebuild
72
+ class Completer
73
+ autoload :Script, 'codebuild/completer/script'
74
+
75
+ def initialize(command_class, *params)
76
+ @params = params
77
+ @current_command = @params[0]
78
+ @command_class = command_class # CLI initiall
79
+ end
80
+
81
+ def run
82
+ if subcommand?(@current_command)
83
+ subcommand_class = @command_class.subcommand_classes[@current_command]
84
+ @params.shift # destructive
85
+ Completer.new(subcommand_class, *@params).run # recursively use subcommand
86
+ return
87
+ end
88
+
89
+ # full command has been found!
90
+ unless found?(@current_command)
91
+ puts all_commands
92
+ return
93
+ end
94
+
95
+ # will only get to here if command aws found (above)
96
+ arity = @command_class.instance_method(@current_command).arity.abs
97
+ if @params.size > arity or thor_group_command?
98
+ puts options_completion
99
+ else
100
+ puts params_completion
101
+ end
102
+ end
103
+
104
+ def subcommand?(command)
105
+ @command_class.subcommands.include?(command)
106
+ end
107
+
108
+ # hacky way to detect that command is a registered Thor::Group command
109
+ def thor_group_command?
110
+ command_params(raw=true) == [[:rest, :args]]
111
+ end
112
+
113
+ def found?(command)
114
+ public_methods = @command_class.public_instance_methods(false)
115
+ command && public_methods.include?(command.to_sym)
116
+ end
117
+
118
+ # all top-level commands
119
+ def all_commands
120
+ commands = @command_class.all_commands.reject do |k,v|
121
+ v.is_a?(Thor::HiddenCommand)
122
+ end
123
+ commands.keys
124
+ end
125
+
126
+ def command_params(raw=false)
127
+ params = @command_class.instance_method(@current_command).parameters
128
+ # Example:
129
+ # >> Sub.instance_method(:goodbye).parameters
130
+ # => [[:req, :name]]
131
+ # >>
132
+ raw ? params : params.map!(&:last)
133
+ end
134
+
135
+ def params_completion
136
+ offset = @params.size - 1
137
+ offset_params = command_params[offset..-1]
138
+ command_params[offset..-1].first
139
+ end
140
+
141
+ def options_completion
142
+ used = ARGV.select { |a| a.include?('--') } # so we can remove used options
143
+
144
+ method_options = @command_class.all_commands[@current_command].options.keys
145
+ class_options = @command_class.class_options.keys
146
+
147
+ all_options = method_options + class_options + ['help']
148
+
149
+ all_options.map! { |o| "--#{o.to_s.gsub('_','-')}" }
150
+ filtered_options = all_options - used
151
+ filtered_options.uniq
152
+ end
153
+
154
+ # Useful for debugging. Using puts messes up completion.
155
+ def log(msg)
156
+ File.open("/tmp/complete.log", "a") do |file|
157
+ file.puts(msg)
158
+ end
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,6 @@
1
+ class Codebuild::Completer::Script
2
+ def self.generate
3
+ bash_script = File.expand_path("script.sh", File.dirname(__FILE__))
4
+ puts "source #{bash_script}"
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ _codebuild() {
2
+ COMPREPLY=()
3
+ local word="${COMP_WORDS[COMP_CWORD]}"
4
+ local words=("${COMP_WORDS[@]}")
5
+ unset words[0]
6
+ local completion=$(codebuild completion ${words[@]})
7
+ COMPREPLY=( $(compgen -W "$completion" -- "$word") )
8
+ }
9
+
10
+ complete -F _codebuild codebuild
@@ -0,0 +1,9 @@
1
+ module Codebuild::Help
2
+ class << self
3
+ def text(namespaced_command)
4
+ path = namespaced_command.to_s.gsub(':','/')
5
+ path = File.expand_path("../help/#{path}.md", __FILE__)
6
+ IO.read(path) if File.exist?(path)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ Example:
2
+
3
+ codebuild completion
4
+
5
+ Prints words for TAB auto-completion.
6
+
7
+ Examples:
8
+
9
+ codebuild completion
10
+ codebuild completion hello
11
+ codebuild completion hello name
12
+
13
+ To enable, TAB auto-completion add the following to your profile:
14
+
15
+ eval $(codebuild completion_script)
16
+
17
+ Auto-completion example usage:
18
+
19
+ codebuild [TAB]
20
+ codebuild hello [TAB]
21
+ codebuild hello name [TAB]
22
+ codebuild hello name --[TAB]
@@ -0,0 +1,3 @@
1
+ To use, add the following to your `~/.bashrc` or `~/.profile`
2
+
3
+ eval $(codebuild completion_script)
@@ -0,0 +1,5 @@
1
+ Examples:
2
+
3
+ codebuild hello
4
+ codebuild hello NAME
5
+ codebuild hello NAME --from me
@@ -0,0 +1,3 @@
1
+ module Codebuild
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,37 @@
1
+ version: 0.2
2
+
3
+ #env:
4
+ #variables:
5
+ # key: "value"
6
+ # key: "value"
7
+ #parameter-store:
8
+ # key: "value"
9
+ # key: "value"
10
+
11
+ phases:
12
+ #install:
13
+ #commands:
14
+ # - command
15
+ # - command
16
+ #pre_build:
17
+ #commands:
18
+ # - command
19
+ # - command
20
+ build:
21
+ commands:
22
+ # - command
23
+ # - command
24
+ #post_build:
25
+ #commands:
26
+ # - command
27
+ # - command
28
+ #artifacts:
29
+ #files:
30
+ # - location
31
+ # - location
32
+ #name: $(date +%Y-%m-%d)
33
+ #discard-paths: yes
34
+ #base-directory: location
35
+ #cache:
36
+ #paths:
37
+ # - paths
@@ -0,0 +1,20 @@
1
+ version: 0.2
2
+
3
+ phases:
4
+ pre_build:
5
+ commands:
6
+ - uname -a
7
+ - pwd
8
+ - ls
9
+ - env
10
+ - ls /etc/*release*
11
+ - cat /etc/*release*
12
+ - whoami
13
+ build:
14
+ commands:
15
+ - echo Build started on `date`
16
+ - echo Building project...
17
+ - uptime
18
+ artifacts:
19
+ files:
20
+ - result.txt
@@ -0,0 +1,17 @@
1
+ # name
2
+ # description
3
+ # source
4
+ # artifacts
5
+ # cache
6
+ # environment
7
+ # service_role
8
+ # timeout_in_minutes
9
+
10
+ # badge_enabled
11
+ # encryption_key
12
+ # logs_config
13
+ # queued_timeout_in_minutes
14
+ # tags
15
+ # vpc_config
16
+ # secondary_artifacts
17
+ # secondary_sources
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ describe Codebuild::CLI do
4
+ before(:all) do
5
+ @args = "--from Tung"
6
+ end
7
+
8
+ describe "codebuild" do
9
+ it "hello" do
10
+ out = execute("exe/codebuild hello world #{@args}")
11
+ expect(out).to include("from: Tung\nHello world")
12
+ end
13
+
14
+ it "goodbye" do
15
+ out = execute("exe/codebuild sub goodbye world #{@args}")
16
+ expect(out).to include("from: Tung\nGoodbye world")
17
+ end
18
+
19
+ commands = {
20
+ "hell" => "hello",
21
+ "hello" => "name",
22
+ "hello -" => "--from",
23
+ "hello name" => "--from",
24
+ "hello name --" => "--from",
25
+ "sub goodb" => "goodbye",
26
+ "sub goodbye" => "name",
27
+ "sub goodbye name" => "--from",
28
+ "sub goodbye name --" => "--from",
29
+ "sub goodbye name --from" => "--help",
30
+ }
31
+ commands.each do |command, expected_word|
32
+ it "completion #{command}" do
33
+ out = execute("exe/codebuild completion #{command}")
34
+ expect(out).to include(expected_word) # only checking for one word for simplicity
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,29 @@
1
+ ENV["TEST"] = "1"
2
+
3
+ # CodeClimate test coverage: https://docs.codeclimate.com/docs/configuring-test-coverage
4
+ # require 'simplecov'
5
+ # SimpleCov.start
6
+
7
+ require "pp"
8
+ require "byebug"
9
+ root = File.expand_path("../", File.dirname(__FILE__))
10
+ require "#{root}/lib/codebuild"
11
+
12
+ module Helper
13
+ def execute(cmd)
14
+ puts "Running: #{cmd}" if show_command?
15
+ out = `#{cmd}`
16
+ puts out if show_command?
17
+ out
18
+ end
19
+
20
+ # Added SHOW_COMMAND because DEBUG is also used by other libraries like
21
+ # bundler and it shows its internal debugging logging also.
22
+ def show_command?
23
+ ENV['DEBUG'] || ENV['SHOW_COMMAND']
24
+ end
25
+ end
26
+
27
+ RSpec.configure do |c|
28
+ c.include Helper
29
+ end
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: codebuild
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tung Nguyen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rainbow
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aws-sdk-codebuild
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: cli_markdown
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description:
140
+ email:
141
+ - tongueroo@gmail.com
142
+ executables:
143
+ - codebuild
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - CHANGELOG.md
150
+ - Gemfile
151
+ - Gemfile.lock
152
+ - Guardfile
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - codebuild.gemspec
157
+ - exe/codebuild
158
+ - lib/codebuild.rb
159
+ - lib/codebuild/cli.rb
160
+ - lib/codebuild/command.rb
161
+ - lib/codebuild/completer.rb
162
+ - lib/codebuild/completer/script.rb
163
+ - lib/codebuild/completer/script.sh
164
+ - lib/codebuild/help.rb
165
+ - lib/codebuild/help/completion.md
166
+ - lib/codebuild/help/completion_script.md
167
+ - lib/codebuild/help/hello.md
168
+ - lib/codebuild/version.rb
169
+ - lib/template/.codebuild/buildspec-example.yml
170
+ - lib/template/.codebuild/buildspec.yml
171
+ - lib/template/.codebuild/project.rb
172
+ - spec/lib/cli_spec.rb
173
+ - spec/spec_helper.rb
174
+ homepage: https://github.com/tongueroo/codebuild
175
+ licenses:
176
+ - MIT
177
+ metadata: {}
178
+ post_install_message:
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ requirements: []
193
+ rubygems_version: 3.0.2
194
+ signing_key:
195
+ specification_version: 4
196
+ summary: Codebuild tool
197
+ test_files:
198
+ - spec/lib/cli_spec.rb
199
+ - spec/spec_helper.rb