generic_gem 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 75cf554db010518773c6fcc6526affc7bfd3dce5
4
+ data.tar.gz: bf2dd0eabfa2df632a0082338a87d94479b173a8
5
+ SHA512:
6
+ metadata.gz: 024cca148efc7e0afc2bb0ea358bb18cc861a4a8518911d88780cb8ca3551690a1aa90a4bd76140c25bba7f4a368d97da98c4ea393f6178e8b1de94598b426a5
7
+ data.tar.gz: ce82253278060bab6a118694da730a3c597c265d2348b23becf72bc9f7bcfb798e056185f251ef1cc9c36405c92322969301a997208699544f271fe85ad062f1
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ *.gem
12
+ /tmp*
13
+ .DS_Store
14
+
15
+ Gemfile.lock
16
+ /log/
17
+ gemsurance_report.html
18
+ *.svg
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,22 @@
1
+ Metrics/AbcSize:
2
+ Exclude:
3
+ - lib/generic_gem.rb
4
+
5
+ Metrics/LineLength:
6
+ Exclude:
7
+ - bin/generic_gem
8
+ - generic_gem.gemspec
9
+ - lib/generic_gem.rb
10
+ - spec/generic_gem_spec.rb
11
+
12
+ Metrics/MethodLength:
13
+ Exclude:
14
+ - lib/generic_gem.rb
15
+
16
+ Metrics/ModuleLength:
17
+ Exclude:
18
+ - lib/generic_gem.rb
19
+
20
+ AllCops:
21
+ Exclude:
22
+ - tmp/**/*
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in generic_gem.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,81 @@
1
+ [![Gem Version](https://badge.fury.io/rb/generic_gem.svg)](https://badge.fury.io/rb/generic_gem)
2
+ [![Dependency Status](https://gemnasium.com/jhsu802701/generic_gem.svg)](https://gemnasium.com/jhsu802701/generic_gem)
3
+ [![Build Status](https://travis-ci.org/jhsu802701/generic_gem.svg?branch=master)](https://travis-ci.org/jhsu802701/generic_gem)
4
+ [![Code Climate](https://codeclimate.com/github/jhsu802701/generic_gem/badges/gpa.svg)](https://codeclimate.com/github/jhsu802701/generic_gem)
5
+ [![Test Coverage](https://codeclimate.com/github/jhsu802701/generic_gem/badges/coverage.svg)](https://codeclimate.com/github/jhsu802701/generic_gem/coverage)
6
+
7
+ # GenericGem
8
+
9
+ Welcome to GenericGem! The purpose of this gem is to streamline the process of creating a gem with Bundler.
10
+
11
+ ## What's the point?
12
+ I HATE having to jump through hoops just to take care of the generic details that are necessary for all or most Ruby gems. Every time I have created a Ruby gem, there were numerous details that I had to remember to do. The generic aspects of a gem are fully automated to minimize the drudgery so that you have more time available to work on the capabilities that make your Ruby gem unique.
13
+
14
+ ## Prerequisites for Understanding GenericGem
15
+ You should be familiar with the process of building a Ruby gem. Some good resources are:
16
+
17
+ https://quickleft.com/blog/engineering-lunch-series-step-by-step-guide-to-building-your-first-ruby-gem/
18
+ http://rakeroutes.com/blog/lets-write-a-gem-part-one/
19
+ http://rakeroutes.com/blog/lets-write-a-gem-part-two/
20
+ http://guides.rubygems.org/make-your-own-gem/
21
+
22
+ ## How does GenericGem work?
23
+ GenericGem uses the bundle command to begin the process of creating a gem. Additionally, it adds a number of enhancements needed by all or most Ruby gems. These changes are:
24
+
25
+ * The Code of Conduct and MIT license are automatically included. (It's easier to remove them than to remember to add them.)
26
+ * Your name is automatically filled in the file LICENSE.txt and in the gemspec file.
27
+ * The gem description in the gemspec file is "GENERIC DESCRIPTION" to enable the "rake install" command.
28
+ * The gem summary in the gemspec file is "GENERIC SUMMARY" to enable the "rake install" command.
29
+ * Your email address is automatically provided in the gemspec file.
30
+ * RSpec testing is automatically included and installed. Your gem will pass the initial meaningless tests.
31
+ * The version number is set to 0.0.0.
32
+ * The bin/console and bin/setup script files are made executable.
33
+ * A working Rakefile is provided.
34
+ * The gem_test.sh script is added to the gem's root directory. This is the 1-step test procedure that executes the bin/setup script (which includes the "bundle install" command) AND the command "rake". Just enter the command "sh gem_test.sh" command to start the process. When you clone your gem's source code onto a machine with a fresh Ruby on Rails installation, running the gem_test.sh script should confirm that all of the details needed to make your gem work are complete.
35
+ * The .gitignore file includes .DS_Store and the directories tmp and tmp*.
36
+ * Instructions on using the gem_test.sh and gem_console.sh scripts are included in the README.md file.
37
+
38
+
39
+ ## Installation
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'generic_gem'
45
+ ```
46
+
47
+ And then execute:
48
+
49
+ $ bundle
50
+
51
+ Or install it yourself as:
52
+
53
+ $ gem install generic_gem
54
+
55
+ ## Usage
56
+
57
+ Just enter the command "generic_gem". When prompted, provide the name of your new gem, your name, and your email address. Your new gem will be automatically created AND tested. The initial meaningless tests will pass.
58
+
59
+ ## Development
60
+
61
+ ### Testing this gem
62
+
63
+ After cloning this source code, cd your way into this directory and enter the command `sh gem_test.sh`. Note that this script also runs the code_test.sh and gem_install.sh scripts.
64
+
65
+ ### Testing this gem's source code
66
+ Enter the command `sh code_test.sh` to test the quality of the source code.
67
+
68
+ ### Running this gem in irb
69
+ Enter the command `sh gem_console.sh`.
70
+
71
+ ### Installing this gem
72
+
73
+ Enter the command `sh gem_install.sh`.
74
+
75
+ ## Contributing
76
+
77
+ 1. Fork it ( https://github.com/[my-github-username]/generic_gem/fork )
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task default: :spec
7
+ task test: :spec
8
+
9
+ # TEST GEM: Enter "rake".
10
+ # INSTALL GEM: Enter "rake install".
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'generic_gem'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'generic_gem'
4
+
5
+ puts '***********************'
6
+ puts 'Welcome to Generic Gem!'
7
+ puts
8
+ puts 'DEFAULT VALUE: tmp1'
9
+ puts 'Enter the name of the gem you wish to create:'
10
+ subdir_name = gets.chomp
11
+ subdir_name = 'tmp1' if subdir_name == ''
12
+
13
+ puts
14
+ puts 'DEFAULT VALUE: Marie Curie'
15
+ puts 'Enter your name:'
16
+ your_name = gets.chomp
17
+ your_name = 'Marie Curie' if your_name == ''
18
+
19
+ puts
20
+ puts 'DEFAULT VALUE: mcurie@example.com'
21
+ puts 'Enter your email address:'
22
+ your_email = gets.chomp
23
+ your_email = 'mcurie@example.com' if your_email == ''
24
+
25
+ GenericGem.create(subdir_name, your_name, your_email)
26
+ system("cd #{subdir_name} && sh gem_test.sh")
27
+
28
+ puts
29
+ puts '******************************'
30
+ puts 'Your new gem is ready to roll.'
31
+ puts "GEM NAME: #{subdir_name}"
32
+ puts "YOUR NAME: #{your_name}"
33
+ puts "YOUR EMAIL: #{your_email}"
34
+ puts "Please remember to fill in the rest of your #{subdir_name}.gemspec file."
35
+ puts 'You still need to provide a gem summary, a gem description, and a homepage.'
36
+ puts 'You also need to remove the metadata section.'
37
+ puts
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+
3
+ DIR_GENERIC_GEM=$PWD
4
+ DIR_PARENT="${PWD%/*}"
5
+ mkdir -p log
6
+ rm -rf tmp
7
+
8
+ echo '--------------'
9
+ echo 'bundle install'
10
+ bin/setup >/dev/null
11
+
12
+ echo
13
+ echo '-------'
14
+ echo 'rubocop'
15
+ rubocop
16
+
17
+ echo
18
+ echo '-----------'
19
+ echo 'sandi_meter'
20
+ sandi_meter
21
+
22
+ echo
23
+ echo '------------'
24
+ echo 'bundle-audit'
25
+ bundle-audit
26
+
27
+ echo '----------------------------------------------'
28
+ echo 'gemsurance --output log/gemsurance_report.html'
29
+ gemsurance --output log/gemsurance_report.html
30
+ echo 'Gemsurance Report: log/gemsurance_report.html'
31
+
32
+ echo '------------------------------------------------------------------------'
33
+ echo 'bundle viz --file=log/diagram-gems --format=svg --requirements --version'
34
+ bundle viz --file=log/diagram-gems --format=svg --requirements --version
35
+ echo 'Gem dependency diagram: log/diagram-gems.svg'
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ bin/setup
4
+ bin/console
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ gem uninstall generic_gem
4
+
5
+ echo '--------------'
6
+ echo 'bundle install'
7
+ bin/setup >/dev/null
8
+
9
+ echo '------------'
10
+ echo 'rake install'
11
+ rake install
@@ -0,0 +1,77 @@
1
+ #!/bin/bash
2
+
3
+ gem uninstall generic_gem
4
+
5
+ DIR_GENERIC_GEM=$PWD
6
+ DIR_PARENT="${PWD%/*}"
7
+ DIR_TMP=$DIR_PARENT/tmp
8
+
9
+ FILE_LOG_MAIN=$DIR_GENERIC_GEM/log/1-test-gem-main.log
10
+ FILE_LOG_TMP=$DIR_GENERIC_GEM/log/2-test-gem-tmp.log
11
+
12
+ FILE_LOG_MAIN_CODE=$DIR_GENERIC_GEM/log/3-test-code-main.log
13
+ FILE_LOG_TMP_CODE=$DIR_GENERIC_GEM/log/4-test-code-tmp.log
14
+
15
+ FILE_LOG_MAIN_INSTALL=$DIR_GENERIC_GEM/log/5-install-main.log
16
+ FILE_LOG_TMP_INSTALL=$DIR_GENERIC_GEM/log/6-install-tmp.log
17
+
18
+ mkdir -p $DIR_GENERIC_GEM/log
19
+
20
+ echo '--------------'
21
+ echo 'bundle install'
22
+ bin/setup >/dev/null
23
+
24
+ echo '*************************'
25
+ echo 'BEGIN TESTING generic_gem'
26
+ rake 2>&1 | tee $FILE_LOG_MAIN
27
+ echo 'FINISHED TESTING generic_gem'
28
+ echo '****************************'
29
+
30
+ echo '******************************'
31
+ echo 'BEGIN TESTING THE tmp RUBY GEM'
32
+ DIR_PARENT="${PWD%/*}"
33
+ DIR_TMP="$DIR_PARENT/tmp"
34
+ cd $DIR_TMP && sh gem_test.sh 2>&1 | tee $FILE_LOG_TMP
35
+ echo 'FINISHED TESTING THE tmp RUBY GEM'
36
+ echo '*********************************'
37
+
38
+ echo '******************************'
39
+ echo 'BEGIN TESTING generic_gem CODE'
40
+ cd $DIR_GENERIC_GEM && sh code_test.sh 2>&1 | tee $FILE_LOG_MAIN_CODE
41
+ echo 'FINISHED TESTING generic_gem CODE'
42
+ echo '*********************************'
43
+
44
+ echo "******************************"
45
+ echo "BEGIN TESTING THE tmp CODE"
46
+ cd $DIR_TMP && sh code_test.sh | tee $FILE_LOG_TMP_CODE
47
+ echo 'FINISHED TESTING THE tmp CODE'
48
+ echo '*********************************'
49
+
50
+ echo '****************************'
51
+ echo 'BEGIN INSTALLING generic_gem'
52
+ cd $DIR_GENERIC_GEM && sh gem_install.sh 2>&1 | tee $FILE_LOG_MAIN_INSTALL
53
+ echo 'FINISHED INSTALLING generic_gem'
54
+ echo '*******************************'
55
+
56
+ echo '****************************'
57
+ echo 'BEGIN INSTALLING THE tmp GEM'
58
+ cd $DIR_TMP && sh gem_install.sh | tee $FILE_LOG_TMP_INSTALL
59
+ echo 'FINISHED INSTALLING THE tmp GEM'
60
+ echo '*******************************'
61
+
62
+ echo 'The results of gem_test.sh are logged at:'
63
+ echo $FILE_LOG_MAIN
64
+ echo $FILE_LOG_TMP
65
+ echo $FILE_LOG_MAIN_CODE
66
+ echo $FILE_LOG_TMP_CODE
67
+ echo $FILE_LOG_MAIN_INSTALL
68
+ echo $FILE_LOG_TMP_INSTALL
69
+ echo
70
+ echo "Gemsurance Report (main app): $DIR_GENERIC_GEM/log/gemsurance_report.html"
71
+ echo "Gem dependency diagram (main app): $DIR_GENERIC_GEM/log/diagram-gems.svg"
72
+ echo
73
+ echo "Gemsurance Report (tmp app): $DIR_TMP/log/gemsurance_report.html"
74
+ echo "Gem dependency diagram (tmp app): $DIR_TMP/log/diagram-gems.svg"
75
+ echo
76
+ echo 'If all went well, there are no error messages and no failed tests.'
77
+ echo
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'generic_gem/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'generic_gem'
8
+ spec.version = GenericGem::VERSION
9
+ spec.authors = ['Jason Hsu']
10
+ spec.email = ['rubyist@jasonhsu.com']
11
+
12
+ spec.summary = 'GenericGem streamlines the process of starting a new Ruby gem.'
13
+ spec.description = 'GenericGem executes the bundle command but fills in important but easily forgotten details.'
14
+ spec.homepage = 'https://github.com/jhsu802701/generic_gem'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'bin'
19
+ spec.executables = 'generic_gem'
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '>= 1.8'
23
+ spec.add_development_dependency 'rake', '>= 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'rubocop'
26
+ spec.add_development_dependency 'sandi_meter'
27
+ spec.add_development_dependency 'bundler-audit'
28
+ spec.add_development_dependency 'gemsurance'
29
+ spec.add_development_dependency 'ruby-graphviz'
30
+
31
+ spec.add_development_dependency 'codeclimate-test-reporter'
32
+ spec.add_development_dependency 'simplecov'
33
+
34
+ spec.add_runtime_dependency 'string_in_file'
35
+ spec.add_runtime_dependency 'replace_quotes'
36
+ end
@@ -0,0 +1,6 @@
1
+ BADGES for README.md
2
+ * Version Badge: http://badge.fury.io/
3
+ * Gemnasium: https://gemnasium.com/
4
+ * Travis CI: https://travis-ci.org/ (SPECIAL NOTE: There are incorrect procedures out there. You must go into your Travis CI settings and add the Code Climate repository token as an environment variable.)
5
+ * Code Climate: https://codeclimate.com/
6
+ * Hakiri: https://hakiri.io/
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task default: :spec
7
+ task test: :spec
8
+
9
+ # TEST GEM: Enter "rake".
10
+ # INSTALL GEM: Enter "rake install".
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ mkdir -p log
4
+ FILE_TEST_GEM='log/1-test-gem.log'
5
+ FILE_TEST_CODE='log/2-test-code.log'
6
+ FILE_INSTALL_GEM='log/3-install-gem.log'
7
+ sh gem_test.sh 2>&1 | tee $FILE_TEST_GEM
8
+ sh code_test.sh 2>&1 | tee $FILE_TEST_CODE
9
+ sh gem_install.sh 2>&1 | tee $FILE_INSTALL_GEM
10
+
11
+ echo 'Results are logged in:'
12
+ echo $FILE_TEST_GEM
13
+ echo $FILE_TEST_CODE
14
+ echo $FILE_INSTALL_GEM
15
+ echo
16
+ echo 'Gemsurance Report: log/gemsurance_report.html'
17
+ echo 'Gem dependency diagram: log/diagram-gems.svg'
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+
3
+ DIR_PARENT="${PWD%/*}"
4
+ DIR_TMP="$DIR_PARENT/tmp"
5
+ mkdir -p log
6
+ rm -rf tmp
7
+
8
+ echo '--------------'
9
+ echo 'bundle install'
10
+ bin/setup >/dev/null
11
+
12
+ echo
13
+ echo '-------'
14
+ echo 'rubocop'
15
+ rubocop
16
+
17
+ echo
18
+ echo '-----------'
19
+ echo 'sandi_meter'
20
+ sandi_meter
21
+
22
+ echo
23
+ echo '------------'
24
+ echo 'bundle-audit'
25
+ bundle-audit
26
+
27
+ echo '----------------------------------------------'
28
+ echo 'gemsurance --output log/gemsurance_report.html'
29
+ gemsurance --output log/gemsurance_report.html
30
+ echo 'Gemsurance Report: log/gemsurance_report.html'
31
+
32
+ echo '------------------------------------------------------------------------'
33
+ echo 'bundle viz --file=log/diagram-gems --format=svg --requirements --version'
34
+ bundle viz --file=log/diagram-gems --format=svg --requirements --version
35
+ echo 'Gem dependency diagram: log/diagram-gems.svg'
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env sh
2
+ ---
3
+ BUNDLE_GEM__COC: true
4
+ BUNDLE_GEM__MIT: true
5
+ BUNDLE_GEM__TEST: rspec
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ # uninstall
4
+ bin/setup
5
+ bin/console
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ # uninstall
4
+ bin/setup
5
+ rake install
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ # uninstall
4
+ bin/setup
5
+ echo '-----------------'
6
+ echo 'BEGIN TESTING gem'
7
+ rake
8
+ echo 'FINISHED TESTING gem'
9
+ echo '--------------------'
@@ -0,0 +1,3 @@
1
+ Metrics/LineLength:
2
+ Exclude:
3
+ - gemspec_file
@@ -0,0 +1,221 @@
1
+ require 'generic_gem/version'
2
+ require 'string_in_file'
3
+ require 'replace_quotes'
4
+
5
+ #
6
+ module GenericGem
7
+ def self.create(gem_name, your_name, your_email)
8
+ puts '**********************'
9
+ puts 'Welcome to Generic Gem'
10
+ puts "GEM NAME: #{gem_name}"
11
+ puts "YOUR NAME: #{your_name}"
12
+ puts "YOUR EMAIL: #{your_email}"
13
+ ENV['DIR_MAIN'] = File.expand_path('../../', __FILE__)
14
+
15
+ bundle_config
16
+ bundle_gem(gem_name)
17
+ update_version(gem_name)
18
+ add_name(gem_name, your_name)
19
+ update_gemspec(gem_name, your_email)
20
+ add_gem_dep(gem_name, 'rubocop')
21
+ add_gem_dep(gem_name, 'sandi_meter')
22
+ add_gem_dep(gem_name, 'bundler-audit')
23
+ add_gem_dep(gem_name, 'gemsurance')
24
+ add_gem_dep(gem_name, 'ruby-graphviz')
25
+ add_gem_dep(gem_name, 'simplecov')
26
+ update_spec_helper(gem_name)
27
+ update_tests(gem_name)
28
+ update_bin_scripts(gem_name)
29
+ add_rakefile(gem_name)
30
+ add_readme_todo(gem_name)
31
+ add_bash_scripts(gem_name)
32
+ update_gitignore(gem_name)
33
+ update_readme(gem_name)
34
+ update_main_module(gem_name)
35
+ add_rubocop_yml(gem_name)
36
+ reset_git(gem_name)
37
+ end
38
+
39
+ def self.bundle_config
40
+ puts '----------------------------------------'
41
+ puts "Setting up #{ENV['HOME']}/.bundle/config"
42
+ puts 'Includes the Code of Conduct (CODE_OF_CONDUCT.md file) and MIT license (LICENSE.txt file)'
43
+ puts 'Using rspec testing'
44
+ system("mkdir -p #{ENV['HOME']}/.bundle")
45
+ system("cp #{ENV['DIR_MAIN']}/lib/files_to_add/config #{ENV['HOME']}/.bundle/config")
46
+ end
47
+
48
+ def self.bundle_gem(gem_name)
49
+ t1 = Thread.new do
50
+ puts '--------------------'
51
+ puts 'Creating the new gem'
52
+ puts "bundle gem #{gem_name}"
53
+ system("bundle gem #{gem_name}")
54
+ end
55
+ t1.join
56
+ end
57
+
58
+ def self.update_version(gem_name)
59
+ puts '----------------------'
60
+ puts 'Initial version: 0.0.0'
61
+ StringInFile.replace('0.1.0', '0.0.0', "#{gem_name}/lib/#{gem_name}/version.rb")
62
+ ReplaceQuotes.update("#{gem_name}/lib/#{gem_name}/version.rb")
63
+ StringInFile.replace('module', "#\nmodule", "#{gem_name}/lib/#{gem_name}/version.rb")
64
+ end
65
+
66
+ def self.add_name(gem_name, your_name)
67
+ puts '-----------------------------------------------------------'
68
+ puts "Filling in your name in LICENSE.txt and #{gem_name}.gemspec"
69
+ puts "Your name: #{your_name}"
70
+ StringInFile.replace('TODO: Write your name', your_name, "#{gem_name}/LICENSE.txt")
71
+ StringInFile.replace('TODO: Write your name', your_name, "#{gem_name}/#{gem_name}.gemspec")
72
+ end
73
+
74
+ def self.update_gemspec(gem_name, your_email)
75
+ puts '----------------------------------------------------'
76
+ puts "Filling in your email address in #{gem_name}.gemspec"
77
+ StringInFile.replace('TODO: Write your email address', your_email, "#{gem_name}/#{gem_name}.gemspec")
78
+
79
+ puts '-----------------------------------------------------'
80
+ puts "Filling in the gem description in #{gem_name}.gemspec"
81
+ StringInFile.replace('TODO: Write a longer description or delete this line.', 'GENERIC DESCRIPTION', "#{gem_name}/#{gem_name}.gemspec")
82
+ StringInFile.replace('%q{GENERIC DESCRIPTION}', "'GENERIC DESCRIPTION'", "#{gem_name}/#{gem_name}.gemspec")
83
+
84
+ puts '-------------------------------------------------'
85
+ puts "Filling in the gem summary in #{gem_name}.gemspec"
86
+ StringInFile.replace('TODO: Write a short summary, because Rubygems requires one.', 'GENERIC SUMMARY', "#{gem_name}/#{gem_name}.gemspec")
87
+ StringInFile.replace('%q{GENERIC SUMMARY}', "'GENERIC SUMMARY'", "#{gem_name}/#{gem_name}.gemspec")
88
+
89
+ puts '---------------------------------------------------'
90
+ puts "Updating #{gem_name}.gemspec for RuboCop compliance"
91
+ ReplaceQuotes.update("#{gem_name}/#{gem_name}.gemspec")
92
+ StringInFile.replace("'\\x0'", '"\\x0"', "#{gem_name}/#{gem_name}.gemspec")
93
+
94
+ puts '--------------------------------------------------------------'
95
+ puts "Replace 'raise' in #{gem_name}/#{gem_name}.gemspec with 'fail'"
96
+ StringInFile.replace("raise 'RubyGems", "fail 'RubyGems", "#{gem_name}/#{gem_name}.gemspec")
97
+ end
98
+
99
+ def self.add_gem_dep(gem_name, gem_dep)
100
+ puts '----------------------------------------'
101
+ puts "Adding #{gem_dep} development dependency"
102
+ str1 = "spec.add_development_dependency 'rspec'"
103
+ str2 = "\n spec.add_development_dependency '#{gem_dep}'"
104
+ str3 = "#{str1}#{str2}"
105
+ StringInFile.replace(str1, str3, "#{gem_name}/#{gem_name}.gemspec")
106
+ end
107
+
108
+ def self.update_spec_helper(gem_name)
109
+ puts '----------------------------'
110
+ puts 'Updating spec/spec_helper.rb'
111
+ file_new = "#{gem_name}/spec/spec_helper_new.rb"
112
+ file_old = "#{gem_name}/spec/spec_helper.rb"
113
+ open(file_new, 'a') do |f|
114
+ f << "require 'simplecov'\n"
115
+ f << "SimpleCov.start\n\n"
116
+ f << File.read(file_old)
117
+ end
118
+ system("mv #{file_new} #{file_old}")
119
+ end
120
+
121
+ def self.update_tests(gem_name)
122
+ puts '--------------------------------'
123
+ puts 'Revising the initial rspec tests'
124
+ StringInFile.replace('expect(false).to eq(true)', 'expect(true).to eq(true)', "#{gem_name}/spec/#{gem_name}_spec.rb")
125
+ end
126
+
127
+ def self.update_bin_scripts(gem_name)
128
+ puts '----------------------------------'
129
+ puts 'Updating bin/console and bin/setup'
130
+ ReplaceQuotes.update("#{gem_name}/bin/console")
131
+ system("chmod +x #{gem_name}/bin/*")
132
+ end
133
+
134
+ def self.add_rakefile(gem_name)
135
+ puts '-------------------'
136
+ puts 'Adding the Rakefile'
137
+ system("cp #{ENV['DIR_MAIN']}/lib/files_to_add/Rakefile #{gem_name}")
138
+ end
139
+
140
+ def self.add_readme_todo(gem_name)
141
+ puts '--------------------------------'
142
+ puts 'Adding the README-to_do.txt file'
143
+ system("cp #{ENV['DIR_MAIN']}/lib/files_to_add/README-to_do.txt #{gem_name}")
144
+ end
145
+
146
+ def self.add_bash_scripts(gem_name)
147
+ puts '-------------------'
148
+ puts 'Adding Bash scripts'
149
+ system("cp #{ENV['DIR_MAIN']}/lib/files_to_add/*.sh #{gem_name}")
150
+
151
+ puts '----------------------------------------------'
152
+ puts "Adding 'gem uninstall' command to Bash scripts"
153
+ str_old = '# uninstall'
154
+ str_new = "gem uninstall #{gem_name}"
155
+ StringInFile.replace(str_old, str_new, "#{gem_name}/code_test.sh")
156
+ StringInFile.replace(str_old, str_new, "#{gem_name}/gem_test.sh")
157
+ StringInFile.replace(str_old, str_new, "#{gem_name}/gem_install.sh")
158
+ StringInFile.replace(str_old, str_new, "#{gem_name}/gem_console.sh")
159
+ end
160
+
161
+ def self.update_gitignore(gem_name)
162
+ puts '----------------------------'
163
+ puts 'Updating the .gitignore file'
164
+ puts 'Adding tmp* and .DS_Store'
165
+ open("#{gem_name}/.gitignore", 'a') do |f|
166
+ f << "\nlog/"
167
+ f << "\ntmp*"
168
+ f << "\n.DS_Store"
169
+ f << "\n*.gem"
170
+ end
171
+ end
172
+
173
+ def self.update_readme(gem_name)
174
+ puts '---------------------------'
175
+ puts 'Updating the README.md file'
176
+ t1 = Thread.new do
177
+ file_w = open("#{gem_name}/README.md", 'a')
178
+ file_w.write("## Bash Scripts\n")
179
+ file_w.write("### Testing this gem\n")
180
+ file_w.write("After you download this source code, enter `sh gem_test.sh` to set up and test this gem.\n\n")
181
+ file_w.write("### Testing this gem's source code\n")
182
+ file_w.write("Enter `sh code_test.sh` to test the quality of this gem's source code.\n")
183
+ file_w.write("### Running this gem in irb\n")
184
+ file_w.write("Enter `sh gem_console.sh`.\n\n")
185
+ file_w.write("### Installing this gem\n")
186
+ file_w.write("Enter `sh gem_install.sh`.\n")
187
+ file_w.write("### Testing the gem, source code, and installation process\n")
188
+ file_w.write("Enter `sh all.sh` to run the gem_test.sh, code_test.sh, and gem_install.sh scripts.\n")
189
+ file_w.close
190
+ end
191
+ t1.join
192
+ end
193
+
194
+ def self.update_main_module(gem_name)
195
+ puts '--------------------------------------------------------------'
196
+ puts "Updating #{gem_name}/lib/#{gem_name}.rb to comply with RuboCop"
197
+ ReplaceQuotes.update("#{gem_name}/lib/#{gem_name}.rb")
198
+ StringInFile.replace('module', "#\nmodule", "#{gem_name}/lib/#{gem_name}.rb")
199
+
200
+ puts '-------------------------------------------------------------------------------'
201
+ puts "Adding the suggestion of using a class or module to the lib/#{gem_name}.rb file"
202
+ open("#{gem_name}/lib/#{gem_name}.rb", 'a') do |f|
203
+ f << "# Your new gem is a module by default. You may wish to use a class instead.\n"
204
+ end
205
+ end
206
+
207
+ def self.add_rubocop_yml(gem_name)
208
+ puts '-------------------'
209
+ puts 'Adding .rubocop.yml'
210
+ system("cp #{ENV['DIR_MAIN']}/lib/files_to_add/rubocop.yml #{gem_name}/.rubocop.yml")
211
+ StringInFile.replace('gemspec_file', "#{gem_name}.gemspec", "#{gem_name}/.rubocop.yml")
212
+ end
213
+
214
+ def self.reset_git(gem_name)
215
+ puts '---------'
216
+ puts 'Reset Git'
217
+ system("cd #{gem_name} && git init")
218
+ system("cd #{gem_name} && git add .")
219
+ system("cd #{gem_name} && git commit -m 'Initial commit'")
220
+ end
221
+ end
@@ -0,0 +1,4 @@
1
+ #
2
+ module GenericGem
3
+ VERSION = '0.1.0'
4
+ end
@@ -0,0 +1,52 @@
1
+ AT START:
2
+ 1. Set configuration
3
+ #!/usr/bin/env sh
4
+ echo "---" > $HOME/.bundle/config
5
+ echo "BUNDLE_GEM__COC: true" >> $HOME/.bundle/config
6
+ echo "BUNDLE_GEM__MIT: true" >> $HOME/.bundle/config
7
+ echo "BUNDLE_GEM__TEST: rspec" >> $HOME/.bundle/config
8
+ /usr/bin/env ruby <<-EORUBY
9
+
10
+ StringInFile.replace("0.1.0", "0.0.0", (lib/gem name/version.txt))
11
+
12
+ EORUBY
13
+
14
+ 2. bundle gem (name of gem)
15
+
16
+ 3. Make bin/setup and bin/console executable
17
+ chmod +x bin/setup
18
+ chmod +x bin/console
19
+
20
+ 4. Add gem_test file
21
+ echo "#!/bin/bash" > gem_test.sh
22
+ echo "" >> gem_test.sh
23
+ echo "# Run this script to test this gem." >> gem_test.sh
24
+ echo "bin/setup" >> gem_test.sh
25
+ echo "rake" >> gem_test.sh
26
+ chmod +x gem_test.sh
27
+
28
+ 5. Add gem_console file
29
+
30
+ echo "#!/bin/bash" > gem_console.sh
31
+ echo "" >> gem_console.sh
32
+ echo "# Run this script to test this gem in an irb shell." >> gem_console.sh
33
+ echo "bin/console" >> gem_console.sh
34
+ chmod +x gem_console.sh
35
+
36
+ 6. gemspec: Add rspec to development dependency list, replace "\nend" with
37
+ ' spec.add_development_dependency "rspec"\nend'
38
+
39
+ 7. Rakefile:
40
+ require "bundler/gem_tasks"
41
+ require "rspec/core/rake_task"
42
+
43
+ RSpec::Core::RakeTask.new
44
+
45
+ task :default => :spec
46
+ task :test => :spec
47
+
48
+ 8. *_spec.rb:
49
+ expect(false).to eq(true) -> expect(true).to eq(true)
50
+
51
+ 9. .gitignore
52
+ include tmp, tmp*, and .DS_Store
metadata ADDED
@@ -0,0 +1,243 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: generic_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Hsu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-24 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.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
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: '0'
48
+ type: :development
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: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
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: sandi_meter
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: bundler-audit
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: gemsurance
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: ruby-graphviz
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: codeclimate-test-reporter
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
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: string_in_file
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: replace_quotes
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description: GenericGem executes the bundle command but fills in important but easily
182
+ forgotten details.
183
+ email:
184
+ - rubyist@jasonhsu.com
185
+ executables:
186
+ - generic_gem
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - ".gitignore"
191
+ - ".rspec"
192
+ - ".rubocop.yml"
193
+ - ".travis.yml"
194
+ - CODE_OF_CONDUCT.md
195
+ - Gemfile
196
+ - LICENSE.txt
197
+ - README.md
198
+ - Rakefile
199
+ - bin/console
200
+ - bin/generic_gem
201
+ - bin/setup
202
+ - code_test.sh
203
+ - gem_console.sh
204
+ - gem_install.sh
205
+ - gem_test.sh
206
+ - generic_gem.gemspec
207
+ - lib/files_to_add/README-to_do.txt
208
+ - lib/files_to_add/Rakefile
209
+ - lib/files_to_add/all.sh
210
+ - lib/files_to_add/code_test.sh
211
+ - lib/files_to_add/config
212
+ - lib/files_to_add/gem_console.sh
213
+ - lib/files_to_add/gem_install.sh
214
+ - lib/files_to_add/gem_test.sh
215
+ - lib/files_to_add/rubocop.yml
216
+ - lib/generic_gem.rb
217
+ - lib/generic_gem/version.rb
218
+ - plans.txt
219
+ homepage: https://github.com/jhsu802701/generic_gem
220
+ licenses:
221
+ - MIT
222
+ metadata: {}
223
+ post_install_message:
224
+ rdoc_options: []
225
+ require_paths:
226
+ - lib
227
+ required_ruby_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ version: '0'
232
+ required_rubygems_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ requirements: []
238
+ rubyforge_project:
239
+ rubygems_version: 2.4.5.1
240
+ signing_key:
241
+ specification_version: 4
242
+ summary: GenericGem streamlines the process of starting a new Ruby gem.
243
+ test_files: []