hello_rails 0.0.1
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 +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/hello_rails +9 -0
- data/hello_rails.gemspec +26 -0
- data/lib/hello_rails.rb +31 -0
- data/lib/hello_rails/app.rb +70 -0
- data/lib/hello_rails/app_data.rb +19 -0
- data/lib/hello_rails/app_installer.rb +42 -0
- data/lib/hello_rails/cli_handler.rb +39 -0
- data/lib/hello_rails/messenger.rb +67 -0
- data/lib/hello_rails/runner.rb +20 -0
- data/lib/hello_rails/starter_repo.rb +3 -0
- data/lib/hello_rails/string_utils.rb +21 -0
- data/lib/hello_rails/tag_manager.rb +80 -0
- data/lib/hello_rails/unix_utils.rb +16 -0
- data/lib/hello_rails/version.rb +3 -0
- data/spec/lib/hello_rails/runner_spec.rb +18 -0
- data/spec/spec_helper.rb +83 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cf9115f48da3a974a3e3d4e7547b43e989a65ced
|
4
|
+
data.tar.gz: 2406ffe4f251a134e56ff154457d973f56f3464f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a755dbceef4330b5e49231beb76611330f789c2b79872fd6ac5d2c7efbc09e3286d9cf8591c743e42fe8032398a7d3c47ad27380a7e6f21a1d7a9cec3acca5c
|
7
|
+
data.tar.gz: 69ddca129ab1ceba12583cc1614f65cff153349e4368276cbb828f2eb40dfe770cbd59da07e5f4528a7bb0eb1a48bc04d22f38b4bda8789aef80d2fffd279475
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Freddy Rangel
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# HelloRails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'hello_rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install hello_rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/hello_rails/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/hello_rails
ADDED
data/hello_rails.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
File.expand_path('../lib', __FILE__).tap do |lib|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'hello_rails/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "hello_rails"
|
10
|
+
spec.version = HelloRails::VERSION
|
11
|
+
spec.authors = ["Freddy Rangel"]
|
12
|
+
spec.email = ["freddy.rangel@hellosign.com"]
|
13
|
+
spec.summary = %q{A simple Rails application generator that builds applications with the common customization stuff already done.}
|
14
|
+
spec.homepage = "https://github.com/freddyrangel/hello_rails"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.3', '>= 3.3.0'
|
25
|
+
spec.add_development_dependency 'webmock', '~> 1.21', '>= 1.21.0'
|
26
|
+
end
|
data/lib/hello_rails.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'optparse'
|
4
|
+
require 'colorize'
|
5
|
+
require 'net/http'
|
6
|
+
require 'json'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
require 'hello_rails/version'
|
10
|
+
require 'hello_rails/runner'
|
11
|
+
require 'hello_rails/starter_repo'
|
12
|
+
require 'hello_rails/cli_handler'
|
13
|
+
require 'hello_rails/string_utils'
|
14
|
+
require 'hello_rails/unix_utils'
|
15
|
+
require 'hello_rails/app'
|
16
|
+
require 'hello_rails/messenger'
|
17
|
+
require 'hello_rails/app_data'
|
18
|
+
require 'hello_rails/app_installer'
|
19
|
+
require 'hello_rails/tag_manager'
|
20
|
+
|
21
|
+
module HelloRails
|
22
|
+
def self.run
|
23
|
+
runner.run
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def self.runner
|
29
|
+
Runner.new
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module HelloRails
|
2
|
+
class App
|
3
|
+
extend Forwardable
|
4
|
+
include UnixUtils
|
5
|
+
|
6
|
+
attr_reader :current_ruby_version, :messenger, :app_data, :app_installer
|
7
|
+
|
8
|
+
def_delegators :app_data, :name, :repo, :directory, :formatted_name,
|
9
|
+
:dash_name, :snake_name, :camel_name, :title_name
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@current_ruby_version = RUBY_VERSION
|
13
|
+
@app_installer = AppInstaller.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def create!(opts = {})
|
17
|
+
@app_data = AppData.new(opts)
|
18
|
+
@messenger = Messenger.new(app_data: app_data, ruby_version: current_ruby_version)
|
19
|
+
welcome_message if app_directory_empty?
|
20
|
+
app_installer.run(app_data)
|
21
|
+
configure_app
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def app_directory_empty?
|
27
|
+
if Dir["#{directory}/*"].empty?
|
28
|
+
true
|
29
|
+
else
|
30
|
+
messenger.directory_not_empty
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def welcome_message
|
36
|
+
messenger.welcome
|
37
|
+
end
|
38
|
+
|
39
|
+
def rename_app
|
40
|
+
Dir.chdir(directory) do
|
41
|
+
{
|
42
|
+
'HellosignRailsStarterApp' => camel_name,
|
43
|
+
'hellosign-rails-starter-app' => dash_name,
|
44
|
+
'hellosign_rails_starter_app' => snake_name,
|
45
|
+
'Hellosign Rails Starter App' => title_name
|
46
|
+
}.each do |proto_name, new_name|
|
47
|
+
shell "find . -type f -print | xargs #{sed_i} 's/#{proto_name}/#{new_name}/g'"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def configure_app
|
53
|
+
rename_app
|
54
|
+
initialize_git
|
55
|
+
print_success_message
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize_git
|
59
|
+
Dir.chdir(directory) do
|
60
|
+
shell "git init"
|
61
|
+
shell "git add -A ."
|
62
|
+
shell "git commit -m 'Initial commit.'"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def print_success_message
|
67
|
+
messenger.success_message
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module HelloRails
|
2
|
+
class AppData
|
3
|
+
include StringUtils
|
4
|
+
|
5
|
+
attr_reader :name, :repo, :directory, :formatted_name, :dash_name,
|
6
|
+
:snake_name, :camel_name, :title_name
|
7
|
+
|
8
|
+
def initialize(opts = {})
|
9
|
+
@name = opts[:app_name]
|
10
|
+
@repo = opts[:repo] || STARTER_REPO
|
11
|
+
@directory = File.expand_path(name.strip.to_s)
|
12
|
+
@formatted_name = File.basename(directory).gsub(/\s+/, '-')
|
13
|
+
@dash_name = dashize(formatted_name)
|
14
|
+
@snake_name = snake_case(formatted_name)
|
15
|
+
@camel_name = camelize(snake_name)
|
16
|
+
@title_name = titleize(snake_name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module HelloRails
|
2
|
+
class AppInstaller
|
3
|
+
include UnixUtils
|
4
|
+
|
5
|
+
attr_accessor :tag_manager, :app_data, :prototype, :latest_tag, :tarball_url
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@tag_manager = TagManager.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def run(app_data)
|
12
|
+
@app_data = app_data
|
13
|
+
tag_manager.fetch_latest(app_data)
|
14
|
+
@prototype = tag_manager.prototype
|
15
|
+
unwrap_tarball
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def repo
|
21
|
+
app_data.repo
|
22
|
+
end
|
23
|
+
|
24
|
+
def app_directory
|
25
|
+
app_data.directory
|
26
|
+
end
|
27
|
+
|
28
|
+
def unwrap_tarball
|
29
|
+
FileUtils.mkdir_p(app_directory)
|
30
|
+
shell "tar xfz #{prototype} -C #{app_directory}"
|
31
|
+
remove_github_added_extra_directory
|
32
|
+
end
|
33
|
+
|
34
|
+
def remove_github_added_extra_directory
|
35
|
+
extraneous_dir = Dir.glob("#{app_directory}/*").first
|
36
|
+
dirs_to_move = Dir.glob("#{extraneous_dir}/*", File::FNM_DOTMATCH)
|
37
|
+
.reject { |d| %w{. ..}.include?(File.basename(d)) }
|
38
|
+
FileUtils.mv dirs_to_move, app_directory
|
39
|
+
FileUtils.remove_dir extraneous_dir
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module HelloRails
|
2
|
+
class CliHandler
|
3
|
+
attr_accessor :app_args
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@app_args = OpenStruct.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def parse!
|
10
|
+
begin
|
11
|
+
parser.parse!
|
12
|
+
app_args.app_name = ARGV.first
|
13
|
+
raise OptionParser::InvalidOption if app_args.app_name.nil?
|
14
|
+
true
|
15
|
+
rescue OptionParser::InvalidOption
|
16
|
+
usage_and_exit(parser)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def parser
|
23
|
+
@parser ||= OptionParser.new do |opts|
|
24
|
+
opts.banner = "Usage: hello_rails [options] NEW_APP_DIRECTORY"
|
25
|
+
opts.on('-h', '--help', "Show hello_rails usage") do
|
26
|
+
usage_and_exit(opts)
|
27
|
+
end
|
28
|
+
opts.on('-r', '--repository [github_repo]', "Github repo (e.g. hello_sign/hello_sign).") do |repo_name_from_cli|
|
29
|
+
app_args.repo = repo_name_from_cli
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def usage_and_exit(parser)
|
35
|
+
puts parser
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module HelloRails
|
2
|
+
class Messenger
|
3
|
+
attr_reader :app_data, :ruby_version
|
4
|
+
|
5
|
+
def initialize(opts = {})
|
6
|
+
@app_data = opts[:app_data]
|
7
|
+
@ruby_version = opts[:ruby_version]
|
8
|
+
end
|
9
|
+
|
10
|
+
def welcome
|
11
|
+
puts ' __ __ ____ ____ _ __'.colorize(:red)
|
12
|
+
puts ' / / / /__ / / /___ / __ \____ _(_) /____'.colorize(:red)
|
13
|
+
puts ' / /_/ / _ \/ / / __ \/ /_/ / __ `/ / / ___/'.colorize(:red)
|
14
|
+
puts ' / __ / __/ / / /_/ / _, _/ /_/ / / (__ ) '.colorize(:red)
|
15
|
+
puts '/_/ /_/\___/_/_/\____/_/ |_|\__,_/_/_/____/ '.colorize(:red)
|
16
|
+
puts
|
17
|
+
puts "HelloRails will create new app in directory:".colorize(:yellow) + " #{app_data.name}".colorize(:yellow) + "...".colorize(:yellow)
|
18
|
+
puts
|
19
|
+
puts "-".colorize(:blue) + " Application Name:".colorize(:light_blue) + " #{app_data.title_name}".colorize(:light_reen)
|
20
|
+
puts "-".colorize(:blue) + " Project Template:".colorize(:light_blue) + " #{app_data.repo}".colorize(:light_reen)
|
21
|
+
puts "-".colorize(:blue) + " Ruby Version: ".colorize(:light_blue) + " #{ruby_version}".colorize(:light_reen)
|
22
|
+
puts
|
23
|
+
end
|
24
|
+
|
25
|
+
def directory_not_empty
|
26
|
+
puts ""
|
27
|
+
puts "Whoops - need to try again!".colorize(:red)
|
28
|
+
puts "The target directory isn't empty."
|
29
|
+
puts ""
|
30
|
+
end
|
31
|
+
|
32
|
+
def repo_has_no_tags
|
33
|
+
puts ""
|
34
|
+
print "Whoops - need to try again!".colorize(:red)
|
35
|
+
puts ""
|
36
|
+
print "We could not find any tags in the repo (".colorize(:light_red)
|
37
|
+
print "#{app_data.repo}".colorize(:white)
|
38
|
+
print ") on github.".colorize(:light_red)
|
39
|
+
puts ""
|
40
|
+
print "HelloRails uses the 'largest' tag in a repository, where tags are sorted alphanumerically.".colorize(:light_red)
|
41
|
+
puts ""
|
42
|
+
print "E.g., tag 'v.0.10.0' > 'v.0.9.9' and 'x' > 'a'.".colorize(:light_red)
|
43
|
+
print ""
|
44
|
+
puts ""
|
45
|
+
end
|
46
|
+
|
47
|
+
def failed_github_request(opts = {})
|
48
|
+
puts ""
|
49
|
+
print "Whoops - need to try again!".colorize(:red)
|
50
|
+
puts ""
|
51
|
+
print "We could not find (".colorize(:light_red)
|
52
|
+
print "#{app_data.repo}".colorize(:white)
|
53
|
+
print ") on github.".colorize(:light_red)
|
54
|
+
puts ""
|
55
|
+
print "The response from github was a (".colorize(:light_red)
|
56
|
+
print "#{opts[:status_code]}".colorize(:white)
|
57
|
+
puts ") which I'm sure you can fix right up!".colorize(:light_red)
|
58
|
+
puts ""
|
59
|
+
end
|
60
|
+
|
61
|
+
def success_message
|
62
|
+
puts ""
|
63
|
+
puts "Your application is ready.".colorize(:yellow)
|
64
|
+
puts ""
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module HelloRails
|
2
|
+
class Runner
|
3
|
+
attr_accessor :cli_handler, :app
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@cli_handler = CliHandler.new
|
7
|
+
@app = App.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
app.create!(app_args) if cli_handler.parse!
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def app_args
|
17
|
+
cli_handler.app_args
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HelloRails
|
2
|
+
module StringUtils
|
3
|
+
def camelize(string)
|
4
|
+
result = string.sub(/^[a-z\d]*/) { $&.capitalize }
|
5
|
+
result.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }
|
6
|
+
end
|
7
|
+
|
8
|
+
def titleize(underscored_string)
|
9
|
+
result = underscored_string.gsub(/_/, ' ')
|
10
|
+
result.gsub(/\b('?[a-z])/) { $1.capitalize }
|
11
|
+
end
|
12
|
+
|
13
|
+
def dashize(string)
|
14
|
+
string.gsub('_', '-')
|
15
|
+
end
|
16
|
+
|
17
|
+
def snake_case(string)
|
18
|
+
string.gsub('-', '_')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module HelloRails
|
2
|
+
class TagManager
|
3
|
+
include UnixUtils
|
4
|
+
|
5
|
+
attr_accessor :app_data, :prototype, :latest_tag, :tarball_url,
|
6
|
+
:cached_prototypes_dir
|
7
|
+
|
8
|
+
def fetch_latest(app_data)
|
9
|
+
@app_data = app_data
|
10
|
+
check_latest_version_on_github
|
11
|
+
cache_latest_version
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def repo
|
17
|
+
app_data.repo
|
18
|
+
end
|
19
|
+
|
20
|
+
def app_directory
|
21
|
+
app_data.directory
|
22
|
+
end
|
23
|
+
|
24
|
+
def check_latest_version_on_github
|
25
|
+
print "Checking for the latest version of the app...".colorize(:yellow)
|
26
|
+
$stdout.flush
|
27
|
+
set_tag_variables
|
28
|
+
print " #{latest_tag}.".colorize(:white)
|
29
|
+
$stdout.flush
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_tag_variables
|
33
|
+
latest_tag_obj = fetch_latest_tag_obj
|
34
|
+
@latest_tag = latest_tag_obj['name']
|
35
|
+
@tarball_url = latest_tag_obj['tarball_url']
|
36
|
+
end
|
37
|
+
|
38
|
+
def fetch_latest_tag_obj
|
39
|
+
url = "https://api.github.com/repos/#{repo}/tags"
|
40
|
+
uri = URI.parse(url)
|
41
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
42
|
+
http.use_ssl = true
|
43
|
+
request = Net::HTTP::Get.new(URI.encode(url))
|
44
|
+
response = http.request(request)
|
45
|
+
parse_response(response)
|
46
|
+
end
|
47
|
+
|
48
|
+
def parse_response(response)
|
49
|
+
if response.code == '200'
|
50
|
+
result = JSON.parse(response.body).first
|
51
|
+
unless result
|
52
|
+
messenger.repo_has_no_tags
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
result
|
56
|
+
else
|
57
|
+
messenger.failed_github_request(status_code: response.code)
|
58
|
+
exit 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def cache_latest_version
|
63
|
+
@cached_prototypes_dir = File.join(Dir.home, ".hello_rails")
|
64
|
+
@prototype = "#{cached_prototypes_dir}/#{repo.sub('/', '--')}-#{latest_tag}.tar.gz"
|
65
|
+
if File.exists?(prototype)
|
66
|
+
puts " Using cached version.".colorize(:yellow)
|
67
|
+
else
|
68
|
+
download_latest_version
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def download_latest_version
|
73
|
+
print " Downloading...".colorize(:yellow)
|
74
|
+
$stdout.flush
|
75
|
+
Dir.mkdir(cached_prototypes_dir, 0755) unless Dir.exists?(cached_prototypes_dir)
|
76
|
+
shell "curl -s -L #{tarball_url} -o #{prototype}"
|
77
|
+
puts " done!".colorize(:yellow)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module HelloRails
|
2
|
+
module UnixUtils
|
3
|
+
def shell(command)
|
4
|
+
%x{#{command}}
|
5
|
+
raise "#{command} failed with status #{$?.exitstatus}." unless $?.success?
|
6
|
+
end
|
7
|
+
|
8
|
+
# Distinguish BSD vs GNU sed with the --version flag (only present in GNU sed).
|
9
|
+
def sed_i
|
10
|
+
@sed_format ||= begin
|
11
|
+
%x{sed --version &> /dev/null}
|
12
|
+
$?.success? ? "sed -i" : "sed -i ''"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe HelloRails::Runner do
|
4
|
+
let(:args) { ['-p', 'This is sparta!'] }
|
5
|
+
let(:runner) { HelloRails::Runner.new(cli_arguments: args) }
|
6
|
+
|
7
|
+
describe "#initialize" do
|
8
|
+
it 'should not blow up' do
|
9
|
+
expect { runner }.to_not raise_error
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#run' do
|
14
|
+
it 'should not blow up' do
|
15
|
+
expect { runner.run }.to_not raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require 'hello_rails'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# rspec-expectations config goes here. You can use an alternate
|
8
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
9
|
+
# assertions if you prefer.
|
10
|
+
config.expect_with :rspec do |expectations|
|
11
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
12
|
+
# and `failure_message` of custom matchers include text for helper methods
|
13
|
+
# defined using `chain`, e.g.:
|
14
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
15
|
+
# # => "be bigger than 2 and smaller than 4"
|
16
|
+
# ...rather than:
|
17
|
+
# # => "be bigger than 2"
|
18
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
19
|
+
end
|
20
|
+
|
21
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
22
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
23
|
+
config.mock_with :rspec do |mocks|
|
24
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
25
|
+
# a real object. This is generally recommended, and will default to
|
26
|
+
# `true` in RSpec 4.
|
27
|
+
mocks.verify_partial_doubles = true
|
28
|
+
end
|
29
|
+
|
30
|
+
# The settings below are suggested to provide a good initial experience
|
31
|
+
# with RSpec, but feel free to customize to your heart's content.
|
32
|
+
=begin
|
33
|
+
# These two settings work together to allow you to limit a spec run
|
34
|
+
# to individual examples or groups you care about by tagging them with
|
35
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
36
|
+
# get run.
|
37
|
+
config.filter_run :focus
|
38
|
+
config.run_all_when_everything_filtered = true
|
39
|
+
|
40
|
+
# Allows RSpec to persist some state between runs in order to support
|
41
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
42
|
+
# you configure your source control system to ignore this file.
|
43
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
44
|
+
|
45
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
46
|
+
# recommended. For more details, see:
|
47
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
48
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
49
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
50
|
+
config.disable_monkey_patching!
|
51
|
+
|
52
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
53
|
+
# be too noisy due to issues in dependencies.
|
54
|
+
config.warnings = true
|
55
|
+
|
56
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
57
|
+
# file, and it's useful to allow more verbose output when running an
|
58
|
+
# individual spec file.
|
59
|
+
if config.files_to_run.one?
|
60
|
+
# Use the documentation formatter for detailed output,
|
61
|
+
# unless a formatter has already been configured
|
62
|
+
# (e.g. via a command-line flag).
|
63
|
+
config.default_formatter = 'doc'
|
64
|
+
end
|
65
|
+
|
66
|
+
# Print the 10 slowest examples and example groups at the
|
67
|
+
# end of the spec run, to help surface which specs are running
|
68
|
+
# particularly slow.
|
69
|
+
config.profile_examples = 10
|
70
|
+
|
71
|
+
# Run specs in random order to surface order dependencies. If you find an
|
72
|
+
# order dependency and want to debug it, you can fix the order by providing
|
73
|
+
# the seed, which is printed after each run.
|
74
|
+
# --seed 1234
|
75
|
+
config.order = :random
|
76
|
+
|
77
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
78
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
79
|
+
# test failures related to randomization by passing the same `--seed` value
|
80
|
+
# as the one that triggered the failure.
|
81
|
+
Kernel.srand config.seed
|
82
|
+
=end
|
83
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hello_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Freddy Rangel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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.3'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.3.0
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.3'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.3.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: webmock
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.21'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.21.0
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.21'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.21.0
|
81
|
+
description:
|
82
|
+
email:
|
83
|
+
- freddy.rangel@hellosign.com
|
84
|
+
executables:
|
85
|
+
- hello_rails
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- ".gitignore"
|
90
|
+
- ".rspec"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/hello_rails
|
96
|
+
- hello_rails.gemspec
|
97
|
+
- lib/hello_rails.rb
|
98
|
+
- lib/hello_rails/app.rb
|
99
|
+
- lib/hello_rails/app_data.rb
|
100
|
+
- lib/hello_rails/app_installer.rb
|
101
|
+
- lib/hello_rails/cli_handler.rb
|
102
|
+
- lib/hello_rails/messenger.rb
|
103
|
+
- lib/hello_rails/runner.rb
|
104
|
+
- lib/hello_rails/starter_repo.rb
|
105
|
+
- lib/hello_rails/string_utils.rb
|
106
|
+
- lib/hello_rails/tag_manager.rb
|
107
|
+
- lib/hello_rails/unix_utils.rb
|
108
|
+
- lib/hello_rails/version.rb
|
109
|
+
- spec/lib/hello_rails/runner_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
homepage: https://github.com/freddyrangel/hello_rails
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.4.5
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: A simple Rails application generator that builds applications with the common
|
135
|
+
customization stuff already done.
|
136
|
+
test_files:
|
137
|
+
- spec/lib/hello_rails/runner_spec.rb
|
138
|
+
- spec/spec_helper.rb
|