awskit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +674 -0
  7. data/README.md +4 -0
  8. data/Rakefile +6 -0
  9. data/awskit.gemspec +35 -0
  10. data/bin/awskit +6 -0
  11. data/lib/awskit/cli.rb +40 -0
  12. data/lib/awskit/gen/cli.rb +35 -0
  13. data/lib/awskit/gen/cookbook/kitchen_template_binding.rb +41 -0
  14. data/lib/awskit/gen/cookbook/service.rb +123 -0
  15. data/lib/awskit/gen/cookbook/templates/.gitignore +18 -0
  16. data/lib/awskit/gen/cookbook/templates/.kitchen.yml.erb +43 -0
  17. data/lib/awskit/gen/cookbook/templates/Berksfile +6 -0
  18. data/lib/awskit/gen/cookbook/templates/Gemfile +22 -0
  19. data/lib/awskit/gen/cookbook/templates/README.md.erb +3 -0
  20. data/lib/awskit/gen/cookbook/templates/Thorfile +5 -0
  21. data/lib/awskit/gen/cookbook/templates/Vagrantfile.erb +90 -0
  22. data/lib/awskit/gen/cookbook/templates/attributes/default.rb +2 -0
  23. data/lib/awskit/gen/cookbook/templates/chefignore +94 -0
  24. data/lib/awskit/gen/cookbook/templates/metadata.rb.erb +9 -0
  25. data/lib/awskit/gen/cookbook/templates/recipes/configure.rb +0 -0
  26. data/lib/awskit/gen/cookbook/templates/recipes/deploy.rb +0 -0
  27. data/lib/awskit/gen/cookbook/templates/recipes/setup.rb +1 -0
  28. data/lib/awskit/gen/cookbook/templates/recipes/shutdown.rb +0 -0
  29. data/lib/awskit/gen/cookbook/templates/recipes/undeploy.rb +0 -0
  30. data/lib/awskit/gen/cookbook/templates/test/integration/default/serverspec/localhost/common_spec.rb +6 -0
  31. data/lib/awskit/gen/cookbook/templates/test/integration/default/serverspec/spec_helper.rb +11 -0
  32. data/lib/awskit/gen/cookbook/vagrantfile_template_binding.rb +17 -0
  33. data/lib/awskit/gen/template_writer.rb +28 -0
  34. data/lib/awskit/gen/toolkit/files/.gitignore +9 -0
  35. data/lib/awskit/gen/toolkit/files/.rspec +2 -0
  36. data/lib/awskit/gen/toolkit/files/Gemfile +4 -0
  37. data/lib/awskit/gen/toolkit/files/LICENSE.txt +674 -0
  38. data/lib/awskit/gen/toolkit/files/README.md +3 -0
  39. data/lib/awskit/gen/toolkit/files/Rakefile +6 -0
  40. data/lib/awskit/gen/toolkit/service.rb +136 -0
  41. data/lib/awskit/gen/toolkit/templates/bin.erb +6 -0
  42. data/lib/awskit/gen/toolkit/templates/cli.erb +31 -0
  43. data/lib/awskit/gen/toolkit/templates/spec_helper.erb +2 -0
  44. data/lib/awskit/gen/toolkit/templates/toolkit.erb +24 -0
  45. data/lib/awskit/gen/toolkit/templates/toolkit.gemspec.erb +35 -0
  46. data/lib/awskit/gen/toolkit/templates/toolkit_spec.erb +11 -0
  47. data/lib/awskit/gen/toolkit/templates/version.erb +3 -0
  48. data/lib/awskit/gen/toolkit/toolkit_template_binding.rb +19 -0
  49. data/lib/awskit/version.rb +3 -0
  50. data/lib/awskit.rb +28 -0
  51. metadata +150 -0
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,136 @@
1
+ require 'awskit/gen/toolkit/toolkit_template_binding'
2
+
3
+ module Awskit::Gen::Toolkit
4
+
5
+ class Service
6
+
7
+ attr_accessor :options
8
+ attr_accessor :output_path
9
+
10
+ def initialize(options)
11
+ self.options = options
12
+ self.output_path = options[:path] || "./#{toolkit_name}"
13
+ end
14
+
15
+ def gen
16
+ gen_gem_dirs
17
+ copy_static_files
18
+ gen_toolkit_spec
19
+ gen_bin
20
+ gen_toolkit_main
21
+ gen_cli
22
+ gen_version
23
+ gen_spec
24
+ end
25
+
26
+ private
27
+
28
+ def toolkit_name
29
+ options[:name].downcase
30
+ end
31
+
32
+ def module_name
33
+ toolkit_name.capitalize
34
+ end
35
+
36
+ def gen_gem_dirs
37
+ bin = "#{output_path}/bin"
38
+ lib = "#{output_path}/lib"
39
+ spec = "#{output_path}/spec"
40
+ lib_toolkit = "#{output_path}/lib/#{toolkit_name}"
41
+ FileUtils.mkdir_p output_path
42
+ Dir.mkdir bin unless File.exist?(bin)
43
+ Dir.mkdir lib unless File.exist?(lib)
44
+ Dir.mkdir spec unless File.exist?(spec)
45
+ Dir.mkdir lib_toolkit unless File.exist?(lib_toolkit)
46
+ FileUtils.mkdir_p "#{output_path}/test/integration/default/serverspec/localhost"
47
+ end
48
+
49
+ def copy_static_files
50
+ FileUtils.cp(static_file('Gemfile'), "#{output_path}/Gemfile")
51
+ FileUtils.cp(static_file('LICENSE.txt'), "#{output_path}/LICENSE.txt")
52
+ FileUtils.cp(static_file('Rakefile'), "#{output_path}/Rakefile")
53
+ FileUtils.cp(static_file('README.md'), "#{output_path}/README.md")
54
+ FileUtils.cp(static_file('.gitignore'), "#{output_path}/.gitignore")
55
+ FileUtils.cp(static_file('.rspec'), "#{output_path}/.rspec")
56
+ end
57
+
58
+ def gen_toolkit_spec
59
+ Awskit::Gen::TemplateWriter.new(
60
+ :output_path => output_path,
61
+ :template => template_path('toolkit.gemspec'),
62
+ :binding => template_binding,
63
+ :filename => "#{toolkit_name}.gemspec"
64
+ ).write!
65
+ end
66
+
67
+ def gen_bin
68
+ Awskit::Gen::TemplateWriter.new(
69
+ :output_path => "#{output_path}/bin",
70
+ :template => template_path('bin'),
71
+ :binding => template_binding,
72
+ :filename => toolkit_name
73
+ ).write!
74
+ FileUtils.chmod 0775, "#{output_path}/bin/#{toolkit_name}"
75
+ end
76
+
77
+ def gen_toolkit_main
78
+ Awskit::Gen::TemplateWriter.new(
79
+ :output_path => "#{output_path}/lib",
80
+ :template => template_path('toolkit'),
81
+ :binding => template_binding,
82
+ :filename => "#{toolkit_name}.rb"
83
+ ).write!
84
+ end
85
+
86
+ def gen_cli
87
+ Awskit::Gen::TemplateWriter.new(
88
+ :output_path => "#{output_path}/lib/#{toolkit_name}",
89
+ :template => template_path('cli'),
90
+ :binding => template_binding,
91
+ :filename => 'cli.rb'
92
+ ).write!
93
+ end
94
+
95
+ def gen_version
96
+ Awskit::Gen::TemplateWriter.new(
97
+ :output_path => "#{output_path}/lib/#{toolkit_name}",
98
+ :template => template_path('version'),
99
+ :binding => template_binding,
100
+ :filename => 'version.rb'
101
+ ).write!
102
+ end
103
+
104
+ def gen_spec
105
+ Awskit::Gen::TemplateWriter.new(
106
+ :output_path => "#{output_path}/spec",
107
+ :template => template_path('spec_helper'),
108
+ :binding => template_binding,
109
+ :filename => 'spec_helper.rb'
110
+ ).write!
111
+ Awskit::Gen::TemplateWriter.new(
112
+ :output_path => "#{output_path}/spec",
113
+ :template => template_path('toolkit_spec'),
114
+ :binding => template_binding,
115
+ :filename => "#{toolkit_name}_spec.rb"
116
+ ).write!
117
+ end
118
+
119
+ def static_file(file)
120
+ "#{Awskit.home}/awskit/gen/toolkit/files/#{file}"
121
+ end
122
+
123
+ def template_path(template)
124
+ "#{Awskit.home}/awskit/gen/toolkit/templates/#{template}.erb"
125
+ end
126
+
127
+ def template_binding
128
+ ToolkitTemplateBinding.new(
129
+ :toolkit_name => toolkit_name,
130
+ :toolkit_module_name => module_name
131
+ ).get_binding
132
+ end
133
+
134
+ end
135
+
136
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.expand_path('../../lib', __FILE__)
3
+ require '<%= toolkit_name %>/cli'
4
+ <%= toolkit_module_name %>::Cli.require_clis
5
+ <%= toolkit_module_name %>::Cli.start
6
+
@@ -0,0 +1,31 @@
1
+ require '<%= toolkit_name %>'
2
+ require 'stackit/cli/stack_cli'
3
+
4
+ module <%= toolkit_module_name %>
5
+ class Cli < Thor
6
+
7
+ def initialize(*args)
8
+ super(*args)
9
+ end
10
+
11
+ def self.require_clis
12
+ Dir.glob("#{<%= toolkit_module_name %>.home}/<%= toolkit_name %>/*") do |pkg|
13
+ next if File.file?(pkg)
14
+ pkg_name = pkg.split('/').last
15
+ full_pkg_name = "<%= toolkit_module_name %>::#{pkg_name.capitalize}::Cli"
16
+ cli = "#{pkg}/cli.rb"
17
+ if File.exist?(cli)
18
+ require cli
19
+ clazz = full_pkg_name.constantize
20
+ clazz.initialize_cli if clazz.respond_to?('initialize_cli')
21
+ end
22
+ end
23
+ end
24
+
25
+ desc 'version', 'Displays <%= toolkit_name %> version'
26
+ def version
27
+ puts "Amazon Web Services Toolkit v#{<%= toolkit_module_name %>::VERSION}"
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require '<%= toolkit_name %>'
@@ -0,0 +1,24 @@
1
+ require 'stackit'
2
+ require '<%= toolkit_name %>/version'
3
+
4
+ module <%= toolkit_module_name %>
5
+ class << self
6
+
7
+ attr_accessor :home
8
+ attr_accessor :logger
9
+ attr_accessor :aws
10
+
11
+ def aws
12
+ @aws ||= Stackit.aws
13
+ end
14
+
15
+ def home
16
+ Pathname.new(File.expand_path('<%= toolkit_name %>.gemspec', __dir__)).dirname
17
+ end
18
+
19
+ def logger
20
+ @logger ||= Logger.new(STDOUT)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require '<%= toolkit_name %>/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "<%= toolkit_name %>"
8
+ spec.version = <%= toolkit_module_name %>::VERSION
9
+ spec.authors = ["root"]
10
+ spec.email = ["root@localhost"]
11
+
12
+ spec.summary = %q{DevOps automation toolkit for AWS.}
13
+ spec.description = %q{AWS DevOps toolkit.}
14
+ spec.homepage = "https://github.com/jeremyhahn/awskit"
15
+ spec.license = "GPLv3"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+
34
+ spec.add_runtime_dependency 'stackit', "~> 0"
35
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe <%= toolkit_module_name %> do
4
+ it 'has a version number' do
5
+ expect(<%= toolkit_module_name %>::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module <%= toolkit_module_name %>
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,19 @@
1
+ module Awskit::Gen::Toolkit
2
+
3
+ class ToolkitTemplateBinding
4
+
5
+ attr_accessor :toolkit_name
6
+ attr_accessor :toolkit_module_name
7
+
8
+ def initialize(options)
9
+ self.toolkit_name = options[:toolkit_name]
10
+ self.toolkit_module_name = options[:toolkit_module_name]
11
+ end
12
+
13
+ def get_binding
14
+ binding()
15
+ end
16
+
17
+ end
18
+ end
19
+
@@ -0,0 +1,3 @@
1
+ module Awskit
2
+ VERSION = "0.1.0"
3
+ end
data/lib/awskit.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'stackit'
2
+ require 'awskit/version'
3
+
4
+ module Awskit
5
+ class << self
6
+
7
+ attr_accessor :home
8
+ attr_accessor :logger
9
+ attr_accessor :aws
10
+
11
+ def aws
12
+ @aws ||= Stackit.aws
13
+ end
14
+
15
+ def home
16
+ Pathname.new(File.expand_path('awskit.gemspec', __dir__)).dirname
17
+ end
18
+
19
+ def logger
20
+ @logger ||= Logger.new(STDOUT)
21
+ end
22
+
23
+ def environment
24
+ @environment ||= Stackit.environment
25
+ end
26
+
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: awskit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Hahn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: stackit
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
+ description: Generates an AWS DevOps toolkit.
70
+ email:
71
+ - mail@jeremyhahn.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - awskit.gemspec
84
+ - bin/awskit
85
+ - lib/awskit.rb
86
+ - lib/awskit/cli.rb
87
+ - lib/awskit/gen/cli.rb
88
+ - lib/awskit/gen/cookbook/kitchen_template_binding.rb
89
+ - lib/awskit/gen/cookbook/service.rb
90
+ - lib/awskit/gen/cookbook/templates/.gitignore
91
+ - lib/awskit/gen/cookbook/templates/.kitchen.yml.erb
92
+ - lib/awskit/gen/cookbook/templates/Berksfile
93
+ - lib/awskit/gen/cookbook/templates/Gemfile
94
+ - lib/awskit/gen/cookbook/templates/README.md.erb
95
+ - lib/awskit/gen/cookbook/templates/Thorfile
96
+ - lib/awskit/gen/cookbook/templates/Vagrantfile.erb
97
+ - lib/awskit/gen/cookbook/templates/attributes/default.rb
98
+ - lib/awskit/gen/cookbook/templates/chefignore
99
+ - lib/awskit/gen/cookbook/templates/metadata.rb.erb
100
+ - lib/awskit/gen/cookbook/templates/recipes/configure.rb
101
+ - lib/awskit/gen/cookbook/templates/recipes/deploy.rb
102
+ - lib/awskit/gen/cookbook/templates/recipes/setup.rb
103
+ - lib/awskit/gen/cookbook/templates/recipes/shutdown.rb
104
+ - lib/awskit/gen/cookbook/templates/recipes/undeploy.rb
105
+ - lib/awskit/gen/cookbook/templates/test/integration/default/serverspec/localhost/common_spec.rb
106
+ - lib/awskit/gen/cookbook/templates/test/integration/default/serverspec/spec_helper.rb
107
+ - lib/awskit/gen/cookbook/vagrantfile_template_binding.rb
108
+ - lib/awskit/gen/template_writer.rb
109
+ - lib/awskit/gen/toolkit/files/.gitignore
110
+ - lib/awskit/gen/toolkit/files/.rspec
111
+ - lib/awskit/gen/toolkit/files/Gemfile
112
+ - lib/awskit/gen/toolkit/files/LICENSE.txt
113
+ - lib/awskit/gen/toolkit/files/README.md
114
+ - lib/awskit/gen/toolkit/files/Rakefile
115
+ - lib/awskit/gen/toolkit/service.rb
116
+ - lib/awskit/gen/toolkit/templates/bin.erb
117
+ - lib/awskit/gen/toolkit/templates/cli.erb
118
+ - lib/awskit/gen/toolkit/templates/spec_helper.erb
119
+ - lib/awskit/gen/toolkit/templates/toolkit.erb
120
+ - lib/awskit/gen/toolkit/templates/toolkit.gemspec.erb
121
+ - lib/awskit/gen/toolkit/templates/toolkit_spec.erb
122
+ - lib/awskit/gen/toolkit/templates/version.erb
123
+ - lib/awskit/gen/toolkit/toolkit_template_binding.rb
124
+ - lib/awskit/version.rb
125
+ homepage: https://github.com/jeremyhahn/awskit
126
+ licenses:
127
+ - GPLv3
128
+ metadata:
129
+ allowed_push_host: https://rubygems.org
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.4.8
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: DevOps automation toolkit generator for AWS.
150
+ test_files: []