mickey_goldmill 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7730f253ff80156a46022c02747692b4d9ee4da9
4
+ data.tar.gz: 4dd70f57d75a0ca81d475540ffda50c3fdf34a76
5
+ SHA512:
6
+ metadata.gz: 4f7013bc24313e8178058f582fb3ffc9a6fd6a3bd0ec65a953c1da1719c100914ed04bece1202da70fb8e7da234ac24d229729415e1e35b4ed40496fee74b589
7
+ data.tar.gz: 1108123f6de9392189ab1dd9efe9624f414e4c58ebb9a88dcd5a03b4f318d00fbb2d921fd60ef6b65386b80866c393c797bd8706a4104b22a8064c8342699915
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Cody Tanner
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # MickeyGoldmill
2
+ This is a gem that includes generators to add a jenkins setup to a rails project.
3
+
4
+ ## Usage
5
+ There are 2 ways to use this gem. If you run the generator without any arguments it will
6
+ install gergich, brakeman, eslint, rubocop, and simplecov.
7
+
8
+ If you do not desire to install everything, pass all the options that you want installed.
9
+ You can pass the following option: brakeman, eslint, rubocop, simplecov
10
+
11
+ Examples:
12
+ $ rails generate mickey
13
+
14
+ This will create:
15
+ build.sh
16
+ bin/jekins
17
+ Dockerfile
18
+ docker-compost.test.yml
19
+
20
+ This will inject:
21
+ gergich
22
+ brakeman
23
+ eslint
24
+ rubocop
25
+ simplecov
26
+
27
+ $ rails generate mickey eslint rubocop
28
+
29
+ This will create:
30
+ build.sh
31
+ bin/jekins
32
+ Dockerfile
33
+ docker-compost.test.yml
34
+
35
+ This will inject:
36
+ gergich
37
+ eslint
38
+ rubocop
39
+
40
+ ## Installation
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'mickey_goldmill'
45
+ ```
46
+
47
+ And then execute:
48
+ ```bash
49
+ $ bundle
50
+ ```
51
+
52
+ Or install it yourself as:
53
+ ```bash
54
+ $ gem install mickey_goldmill
55
+ ```
56
+
57
+ ## License
58
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'MickeyGoldmill'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+
33
+ task default: :test
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Adds brakeman to your gemfile
3
+
4
+ Example:
5
+ rails generate brakeman
6
+
7
+ This will add to your gemfile:
8
+ gem "brakeman", group: [:development, :test]
@@ -0,0 +1,7 @@
1
+ class BrakemanGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def add_to_gemfile
5
+ gem "brakeman", group: [:development, :test]
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ This creates a build.sh script that relies on a docker-compose.test.yml
3
+
4
+ Example:
5
+ rails generate build
6
+
7
+ This will create:
8
+ build.sh
@@ -0,0 +1,19 @@
1
+ class BuildGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ argument :features, :type => :array, :default => []
4
+
5
+ def create_build_file
6
+ create_file "build.sh",
7
+ <<-FILE
8
+ #!/bin/bash
9
+ export COMPOSE_FILE=docker-compose.test.yml
10
+
11
+ set -e
12
+
13
+ docker-compose build
14
+ docker-compose up -d
15
+ docker-compose run -T web bin/jenkins
16
+ FILE
17
+ end
18
+
19
+ end
@@ -0,0 +1,10 @@
1
+ Description:
2
+ Creates a default Dockerfile and a docker-compose.test.yml file
3
+ uses the passed in name for docker compose values
4
+
5
+ Example:
6
+ rails generate docker NAME
7
+
8
+ This will create:
9
+ Dockerfile
10
+ docker-compose.test.yml
@@ -0,0 +1,62 @@
1
+ class DockerGenerator < Rails::Generators::NamedBase
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def create_docker_compose_files
5
+ create_file "docker-compose.test.yml",
6
+ <<-FILE
7
+ version: '2'
8
+
9
+ services:
10
+ web:
11
+ build:
12
+ context: .
13
+ dockerfile: ./Dockerfile
14
+ environment:
15
+ APP_DOMAIN: web
16
+ GERGICH_KEY: "${GERGICH_KEY}"
17
+ GERRIT_PROJECT: "${GERRIT_PROJECT}"
18
+ GERRIT_HOST: "${GERRIT_HOST}"
19
+ GERRIT_BRANCH: "${GERRIT_BRANCH}"
20
+ DB_USERNAME: postgres
21
+ DB_PASSWORD: #{file_name.underscore}_postgres_password
22
+ links:
23
+ - postgres
24
+ volumes:
25
+ - '.git:/usr/src/app/.git'
26
+ - "coverage:/usr/src/app/coverage"
27
+
28
+ postgres:
29
+ image: postgres:10.1
30
+ environment:
31
+ POSTGRES_USER: postgres
32
+ POSTGRES_PASSWORD: #{file_name.underscore}_postgres_password
33
+
34
+ volumes:
35
+ coverage: {}
36
+ FILE
37
+ end
38
+
39
+ def create_docker_file
40
+ create_file "Dockerfile",
41
+ <<-FILE
42
+ FROM ruby:2.4.3
43
+
44
+ RUN apt-get update
45
+ RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && \
46
+ apt-get install -y nodejs
47
+
48
+ RUN mkdir -p /usr/src/app
49
+ ADD Gemfile /usr/src/app/
50
+ ADD Gemfile.lock /usr/src/app/
51
+ ADD package.json /usr/src/app/
52
+
53
+ WORKDIR /usr/src/app
54
+ ENV RAILS_ENV test
55
+ RUN bundle install --system
56
+ RUN npm install
57
+
58
+ ADD . /usr/src/app/
59
+ FILE
60
+
61
+ end
62
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Adds eslint-rails to your gemfile
3
+
4
+ Example:
5
+ rails generate eslint-rails
6
+
7
+ This will add to your gemfile:
8
+ gem "eslint-rails", group: [:development, :test]
@@ -0,0 +1,7 @@
1
+ class EslintGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def add_to_gemfile
5
+ gem "eslint-rails", group: [:development, :test]
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Creates a script that will run on jenkins to determine if a build is valid
3
+
4
+ Example:
5
+ rails generate jenkins
6
+
7
+ This will create:
8
+ bin/jenkins
@@ -0,0 +1,54 @@
1
+ class JenkinsGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ argument :features, :type => :array, :default => []
4
+
5
+ def create_jenkins_file
6
+ brakeman = 'echo "Checking securtiy issues with brakeman"
7
+ bundle exec gergich capture brakeman "bundle exec brakeman"
8
+ EXIT_CODES=$(($EXIT_CODES + $?))
9
+ ' if features.include?('brakeman')
10
+ puts features.include?('brakeman')
11
+
12
+ rubocop = 'echo "Analyzing ruby code with rubocop"
13
+ bundle exec gergich capture rubocop "bundle exec rubocop --fail-level autocorrect"
14
+ EXIT_CODES=$(($EXIT_CODES + $?))
15
+ ' if features.include?('rubocop')
16
+
17
+ eslint = 'echo "Analyzing js with eslint"
18
+ bundle exec gergich capture eslint "bundle exec rake eslint:run[app]"
19
+ EXIT_CODES=$(($EXIT_CODES + $?))
20
+ ' if features.include?('eslint')
21
+
22
+ create_file "bin/jenkins",
23
+ """#!/usr/bin/env bash
24
+
25
+ set +e
26
+ EXIT_CODES=0
27
+
28
+ # Allow time for postgres to start
29
+ for i in {1..6}; do
30
+ bundle exec rake db:create && break
31
+ test $i -eq 6 && echo 'Failed to db:create' && exit 1
32
+ sleep 1
33
+ done
34
+
35
+ bundle exec rake db:migrate
36
+
37
+ echo 'Checking last migration is reversible'
38
+ bundle exec rake db:migrate:redo
39
+ EXIT_CODES=$(($EXIT_CODES + $?))
40
+
41
+ #{[brakeman, rubocop, eslint].compact.join("\n")}
42
+ echo 'Running ruby specs'
43
+ bundle exec rspec
44
+ EXIT_CODES=$(($EXIT_CODES + $?))
45
+
46
+ echo 'Running JS specs...'
47
+ npm run test
48
+ EXIT_CODES=$(($EXIT_CODES + $?))
49
+
50
+ bundle exec gergich publish
51
+ exit $EXIT_CODES"""
52
+ end
53
+
54
+ end
@@ -0,0 +1,36 @@
1
+ Description:
2
+ Adds gergich to gemfile
3
+ Creates a docker compose and docker setup for jenkins.
4
+ Includes code analysis and code coverage.
5
+ Can pass the following option: brakeman, eslint, rubocop, simplecov
6
+ If no options are passed it will install all of them
7
+
8
+ Example:
9
+ 1) rails generate mickey
10
+
11
+ This will create:
12
+ build.sh
13
+ bin/jekins
14
+ Dockerfile
15
+ docker-compost.test.yml
16
+
17
+ This will inject:
18
+ gergich
19
+ brakeman
20
+ eslint
21
+ rubocop
22
+ simplecov
23
+
24
+ 2) rails generate mickey eslint rubocop
25
+
26
+ This will create:
27
+ build.sh
28
+ bin/jekins
29
+ Dockerfile
30
+ docker-compost.test.yml
31
+
32
+ This will inject:
33
+ gergich
34
+ eslint
35
+ rubocop
36
+
@@ -0,0 +1,19 @@
1
+ class MickeyGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ argument :install, :type => :array, :default => ['brakeman', 'eslint', 'rubocop', 'simplecov']
4
+
5
+ def add_to_gemfile
6
+ gem 'gergich'
7
+ end
8
+
9
+ def generate_files
10
+ app_name = Rails.application.class.parent_name
11
+ generate "docker", app_name
12
+ generate "simplecov" if install.include?('simplecov')
13
+ generate "rubocop" if install.include?('rubocop')
14
+ generate "brakeman" if install.include?('brakeman')
15
+ generate "eslint" if install.include?('eslint')
16
+ generate "jenkins", "features #{install.join(' ')}"
17
+ generate "build"
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ Description:
2
+ Adds rubocop to your gemfile.
3
+ Also add a default .rubocop.yml file
4
+
5
+ Example:
6
+ rails generate rubocop
7
+
8
+ This will add to your gemfile:
9
+ gem "rubocop", group: [:development, :test]
10
+
11
+ This will create:
12
+ .rubocop.yml
@@ -0,0 +1,28 @@
1
+ class RubocopGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def add_to_gemfile
5
+ gem "rubocop", group: [:development, :test]
6
+ end
7
+
8
+ def create_yaml_file
9
+ create_file ".rubocop.yml",
10
+ <<-FILE
11
+ AllCops:
12
+ Exclude:
13
+ - 'db/schema.rb'
14
+ - 'config/development-local.rb'
15
+ - 'bin/**/*'
16
+ Metrics/LineLength:
17
+ Max: 120
18
+ Style/Documentation:
19
+ Enabled: false
20
+ Metrics/BlockLength:
21
+ Exclude:
22
+ - 'spec/**/*'
23
+ Style/FrozenStringLiteralComment:
24
+ Enabled: false
25
+ FILE
26
+ end
27
+
28
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate docker Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,21 @@
1
+ class SimplecovGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def add_to_gemfile
5
+ gem "simplecov", group: [:development, :test]
6
+ end
7
+
8
+ def add_to_rails_helper
9
+ inject_into_file 'spec/rails_helper.rb', after: "ActiveRecord::Migration.maintain_test_schema!\n" do <<-'RUBY'
10
+
11
+ require 'simplecov'
12
+ SimpleCov.minimum_coverage 90
13
+ SimpleCov.minimum_coverage_by_file 80
14
+ SimpleCov.start do
15
+ add_filter 'config/routes.rb'
16
+ end
17
+ RUBY
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,3 @@
1
+ module MickeyGoldmill
2
+ # Your code goes here...
3
+ end
@@ -0,0 +1,3 @@
1
+ module MickeyGoldmill
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :mickey_goldmill do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mickey_goldmill
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Cody Tanner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
27
+ description: This is a gem that includes generators to add a jenkins setup to a rails
28
+ project
29
+ email:
30
+ - ctanner@instructure.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - MIT-LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - lib/generators/brakeman/USAGE
39
+ - lib/generators/brakeman/brakeman_generator.rb
40
+ - lib/generators/build/USAGE
41
+ - lib/generators/build/build_generator.rb
42
+ - lib/generators/docker/USAGE
43
+ - lib/generators/docker/docker_generator.rb
44
+ - lib/generators/eslint/USAGE
45
+ - lib/generators/eslint/eslint_generator.rb
46
+ - lib/generators/jenkins/USAGE
47
+ - lib/generators/jenkins/jenkins_generator.rb
48
+ - lib/generators/mickey/USAGE
49
+ - lib/generators/mickey/mickey_generator.rb
50
+ - lib/generators/rubocop/USAGE
51
+ - lib/generators/rubocop/rubocop_generator.rb
52
+ - lib/generators/simplecov/USAGE
53
+ - lib/generators/simplecov/simplecov_generator.rb
54
+ - lib/mickey_goldmill.rb
55
+ - lib/mickey_goldmill/version.rb
56
+ - lib/tasks/mickey_goldmill_tasks.rake
57
+ homepage: https://gerrit.instructure.com/#/admin/projects/mickey_goldmill
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.6.14
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: This is a gem that includes generators to add a jenkins setup to a rails
81
+ project
82
+ test_files: []