├── .editorconfig ├── .gitignore ├── .gitmodules ├── .rspec ├── .travis.yml ├── LICENSE ├── README.md ├── app └── index.js ├── package.json └── test └── test-generator.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/*.log 12 | /tmp 13 | /.idea/* 14 | /log/*.log 15 | /doc/* 16 | .DS_Store 17 | /public/assets 18 | /out 19 | /spec/out 20 | node_modules 21 | deps-auto-update.sh 22 | 23 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ruby-starter-kit"] 2 | path = ruby-starter-kit 3 | url = https://github.com/artemv/ruby-starter-kit 4 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format doc 2 | --color 3 | --require support/spec_helper 4 | --order random 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | cache: 4 | directories: 5 | - node_modules 6 | node_js: 7 | - '4' 8 | - '7' 9 | - stable 10 | before_install: 11 | - npm i -g npm@^2.0.0 12 | before_script: 13 | - npm prune 14 | after_success: 15 | - 'curl -Lo travis_after_all.py https://git.io/travis_after_all' 16 | - python travis_after_all.py 17 | - 'export $(cat .to_export_back) &> /dev/null' 18 | - npm run semantic-release 19 | branches: 20 | except: 21 | - "/^v\\d+\\.\\d+\\.\\d+$/" 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Artem Vasiliev 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-ruby-starter-kit 2 | 3 | [![NPM info][nodei.co]][npm-url] 4 | 5 | [![Code Climate](https://codeclimate.com/github/artemv/generator-ruby-starter-kit/badges/gpa.svg)](https://codeclimate.com/github/artemv/generator-ruby-starter-kit) 6 | [![Travis build status](https://travis-ci.org/artemv/generator-ruby-starter-kit.svg?branch=master)](https://travis-ci.org/artemv/generator-ruby-starter-kit) 7 | [![Dependency Status](https://david-dm.org/artemv/generator-ruby-starter-kit.svg)](https://david-dm.org/artemv/generator-ruby-starter-kit) 8 | [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) 9 | 10 | A [Yeoman](http://yeoman.io/) generator for Ruby app boilerplate based on [Ruby Starter Kit](https://github.com/artemv/ruby-starter-kit) (Bundler, Guard, ActiveSupport Logger, Rubocop, RSpec, WebMock, Travis, CodeClimate) 11 | 12 | ### Installation 13 | 14 | * Install Ruby 2.3.1 from https://www.ruby-lang.org/en/downloads/ or via RVM (https://rvm.io/). 15 | * Install `yo` and this generator globally: 16 | ``` 17 | npm install -g yo generator-ruby-starter-kit 18 | ``` 19 | * Navigate to the directory you'd like to use for your project and run the generator: 20 | ``` 21 | cd my-app 22 | yo ruby-starter-kit 23 | ``` 24 | 25 | ### Basic Guide 26 | 27 | Run the app entry point script: 28 | ``` 29 | repo=octokit.py bin/app.rb 30 | ``` 31 | 32 | Run the guard dev env tool: 33 | ``` 34 | guard 35 | ``` 36 | It will run rubocop on start, will run rubocop inspections on changed files and will re-run all RSpecs and rubocop 37 | inspections if you hit Enter in guard window. 38 | 39 | [nodei.co]: https://nodei.co/npm/generator-ruby-starter-kit.png?downloads=true 40 | [npm-url]: https://npmjs.org/package/generator-ruby-starter-kit 41 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | var yeoman = require('yeoman-generator'); 5 | var chalk = require('chalk'); 6 | var yosay = require('yosay'); 7 | var glob = require('glob'); 8 | 9 | module.exports = yeoman.Base.extend({ 10 | 11 | initializing: function () { 12 | this.sourceRoot(path.join(this.sourceRoot(), '../../ruby-starter-kit')); 13 | }, 14 | 15 | prompting: function () { 16 | this.log(yosay( 17 | 'Welcome to the ' + chalk.green('Ruby Starter Kit') + ' generator!' 18 | )); 19 | }, 20 | 21 | writing: function () { 22 | var done = this.async(); 23 | glob('**/*', { cwd: this.sourceRoot(), dot: true }, function (err, files) { 24 | if (err) { 25 | this.log('Error:', err.message); 26 | return done(); 27 | } 28 | files.forEach(function (file) { 29 | var dest = file; 30 | if (file === '.npmignore') { 31 | dest = '.gitignore'; 32 | } 33 | this.fs.copy( 34 | this.templatePath(file), 35 | this.destinationPath(dest) 36 | ); 37 | }, this); 38 | done(); 39 | }.bind(this)); 40 | }, 41 | 42 | detectFeature: function (testCommand) { 43 | if (!testCommand) return; 44 | var result = this.spawnCommandSync(testCommand, ['--version'], {stdio: 'ignore'}); 45 | return !result.error; 46 | }, 47 | 48 | _promptUserWithGitInit: function() { 49 | var done = this.async(); 50 | this.prompt({ 51 | type: 'confirm', 52 | name: 'initGit', 53 | message: 'Initialize Git repo?', 54 | default: true 55 | }, function (answers) { 56 | if (answers.initGit) { 57 | this.log("Initializing Git repo.."); 58 | this.spawnCommandSync('git', ['init']); 59 | } 60 | // this._sayGoodbye(); 61 | done(); 62 | }.bind(this)); 63 | }, 64 | 65 | _showRvmInstructions: function () { 66 | this.log("You are using RVM. Please run these commands manually after this installation is complete:"); 67 | this.log(); 68 | this.log("rvm use `cat .ruby-version`"); 69 | this.log("gem install bundler"); 70 | this.log("bundle install"); 71 | this.log(); 72 | }, 73 | 74 | _installGems: function () { 75 | this.log('Installing bundler gem..'); 76 | this.spawnCommandSync('gem', ['install', 'bundler']); 77 | this.log("Installing dependent gems with 'bundle install'.."); 78 | this.spawnCommandSync('bundle', ['install']); 79 | }, 80 | 81 | install: { 82 | 83 | bundle: function() { 84 | if (this.detectFeature('rvm')) { 85 | this._showRvmInstructions(); 86 | } else { 87 | this._installGems(); 88 | } 89 | }, 90 | 91 | gitInit: function() { 92 | if (this.detectFeature('git')) { 93 | var fs = require('fs'); 94 | fs.exists('.git', function (exists) { 95 | if (!exists) { 96 | this._promptUserWithGitInit() 97 | } else { 98 | this._sayGoodbye(); 99 | } 100 | }.bind(this)); 101 | } else { 102 | this._sayGoodbye(); 103 | } 104 | } 105 | }, 106 | 107 | _sayGoodbye: function() { 108 | this.log(yosay("That's it. " + chalk.green("Happy hacking!"))); 109 | } 110 | }); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-ruby-starter-kit", 3 | "description": "Yeoman generator for Ruby app boilerplate based on Ruby Starter Kit (Bundler, Guard, ActiveSupport Logger, Rubocop, RSpec, WebMock, Travis, CodeClimate).", 4 | "homepage": "https://github.com/artemv/generator-ruby-starter-kit", 5 | "author": { 6 | "name": "Artem Vasiliev", 7 | "email": "artem.job@gmail.com", 8 | "url": "https://github.com/artemv" 9 | }, 10 | "files": [ 11 | "app", 12 | "ruby-starter-kit" 13 | ], 14 | "main": "app/index.js", 15 | "keywords": [ 16 | "ruby", 17 | "bundler", 18 | "rspec", 19 | "yeoman-generator" 20 | ], 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/artemv/generator-ruby-starter-kit.git" 24 | }, 25 | "dependencies": { 26 | "chalk": "1.1.3", 27 | "glob": "7.1.1", 28 | "yeoman-generator": "0.23.3", 29 | "yeoman-assert": "2.2.1", 30 | "yeoman-test": "1.5.1", 31 | "yosay": "1.2.1", 32 | "@artemv/ruby-starter-kit": "1.0.18" 33 | }, 34 | "devDependencies": { 35 | "freeform-semantic-commit-analyzer": "^1.1.0", 36 | "mocha": "3.1.1", 37 | "semantic-release": "4.3.5" 38 | }, 39 | "release": { 40 | "analyzeCommits": "./node_modules/freeform-semantic-commit-analyzer/dist/index.js" 41 | }, 42 | "scripts": { 43 | "test": "mocha --timeout 10000", 44 | "semantic-release": "semantic-release pre && npm publish && semantic-release post" 45 | }, 46 | "license": "MIT" 47 | } 48 | -------------------------------------------------------------------------------- /test/test-generator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | var assert = require('yeoman-assert'); 5 | var helpers = require('yeoman-test'); 6 | var fs = require('fs'); 7 | 8 | describe('javascript:app', function () { 9 | 10 | function moveSourceFiles(from, to) { 11 | var sourceDir = '../ruby-starter-kit'; 12 | var sourcePath = path.join(__dirname, path.join(sourceDir, from)); 13 | fs.exists(sourcePath, function (exists) { 14 | if (exists) fs.rename(sourcePath, path.join(__dirname, path.join(sourceDir, to))); 15 | }); 16 | } 17 | 18 | before(function (done) { 19 | var renameFile = ['.gitignore', '.npmignore']; 20 | helpers.run(path.join(__dirname, '../app')) 21 | .on('ready', function () { 22 | moveSourceFiles(renameFile[0], renameFile[1]); 23 | }) 24 | .withOptions({ skipInstall: true }) 25 | .on('end', function () { 26 | moveSourceFiles(renameFile[1], renameFile[0]); 27 | done(); 28 | }); 29 | }); 30 | 31 | it('creates files', function () { 32 | assert.file([ 33 | '.editorconfig', 34 | '.gitignore', 35 | 'Gemfile' 36 | ]); 37 | }); 38 | 39 | }); 40 | --------------------------------------------------------------------------------