raygun 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +7 -1
- data/app_prototype/Gemfile +3 -0
- data/app_prototype/app/controllers/registrations_controller.rb +1 -1
- data/app_prototype/app/mailers/user_mailer.rb +1 -1
- data/app_prototype/lib/tasks/cane.rake +30 -0
- data/app_prototype/lib/tasks/spec.rake +4 -0
- data/bin/raygun +135 -56
- data/lib/raygun/version.rb +1 -1
- metadata +3 -2
data/CHANGES.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.18 [2013-01-24]
|
4
|
+
|
5
|
+
* Support generating an app in the current directory.
|
6
|
+
* Better handling of command line arguments.
|
7
|
+
* Include support for cane quality checks via ```rake spec:cane```.
|
8
|
+
|
3
9
|
## 0.0.17 [2013-01-17]
|
4
10
|
|
5
|
-
* Configure .
|
11
|
+
* Configure .ruby-version, .rvmrc, and Gemfile with the version of ruby used to execute raygun.
|
6
12
|
* Improve the detfault email content.
|
7
13
|
* Improve the raygun and app_prototype READMEs.
|
8
14
|
* Use $PORT to set the server port for Heroku compatibility, with default set in .env.
|
data/app_prototype/Gemfile
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
begin
|
2
|
+
require 'cane/rake_task'
|
3
|
+
require 'morecane'
|
4
|
+
|
5
|
+
desc "Run cane to check quality metrics"
|
6
|
+
Cane::RakeTask.new(:quality) do |cane|
|
7
|
+
cane.add_threshold 'coverage/covered_percent', :>=, 95
|
8
|
+
|
9
|
+
cane.no_style = false # Change to true to skip style checks
|
10
|
+
cane.style_measure = 120 # Maximum line length
|
11
|
+
cane.style_exclude = %w{
|
12
|
+
lib/templates/rspec/scaffold/controller_spec.rb
|
13
|
+
}
|
14
|
+
|
15
|
+
cane.no_doc = true # Change to false to enable documentation checks
|
16
|
+
|
17
|
+
cane.abc_max = 15 # Fail the build if complexity is too high.
|
18
|
+
# cane.abc_exclude = %w(
|
19
|
+
# User#bad_code_rising
|
20
|
+
# )
|
21
|
+
|
22
|
+
# Fail the build if the code includes debugging statements
|
23
|
+
cane.use Morecane::MustNotMatchCheck,
|
24
|
+
must_not_match_glob: "{app,lib,config,spec}/**/*.rb",
|
25
|
+
must_not_match_regexp: /binding\.pry|debugger/
|
26
|
+
end
|
27
|
+
|
28
|
+
rescue LoadError
|
29
|
+
warn "cane not available, quality task not provided."
|
30
|
+
end
|
@@ -16,12 +16,16 @@ begin
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
desc 'Runs specs with coverage and cane checks'
|
21
|
+
task cane: ['spec:enable_coverage', 'spec:coverage', 'quality']
|
19
22
|
end
|
20
23
|
|
21
24
|
Rake::Task['spec'].enhance do
|
22
25
|
Rake::Task['spec:javascripts'].invoke
|
23
26
|
end
|
24
27
|
|
28
|
+
|
25
29
|
rescue LoadError
|
26
30
|
namespace :spec do
|
27
31
|
task :javascripts do
|
data/bin/raygun
CHANGED
@@ -1,65 +1,144 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'optparse'
|
3
4
|
require 'fileutils'
|
4
5
|
require 'securerandom'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
module Raygun
|
8
|
+
class Runner
|
9
|
+
attr_accessor :app_name, :app_dir, :title_name, :snake_name, :camel_name, :dash_name
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def initialize(app_name_arg)
|
12
|
+
@app_dir = File.expand_path(app_name_arg.strip.to_s)
|
13
|
+
@app_name = File.basename(app_dir).gsub(/\s+/, '-')
|
14
|
+
@dash_name = app_name.gsub('_', '-')
|
15
|
+
@snake_name = app_name.gsub('-', '_')
|
16
|
+
@camel_name = camelize(snake_name)
|
17
|
+
@title_name = titleize(snake_name)
|
18
|
+
end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
def copy_prototype
|
21
|
+
FileUtils.mkdir_p(app_dir)
|
22
|
+
|
23
|
+
Dir.glob(File.expand_path('../../app_prototype/*', __FILE__), File::FNM_DOTMATCH) do |f|
|
24
|
+
next if %w{. ..}.include?(File.basename(f))
|
25
|
+
FileUtils.cp_r(f, app_dir)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def rename_new_app
|
30
|
+
Dir.chdir(app_dir) do
|
31
|
+
{
|
32
|
+
'AppPrototype' => camel_name,
|
33
|
+
'app-prototype' => dash_name,
|
34
|
+
'app_prototype' => snake_name,
|
35
|
+
'App Prototype' => title_name
|
36
|
+
}.each do |proto_name, new_name|
|
37
|
+
`find . -type f -print | xargs sed -i '' 's/#{proto_name}/#{new_name}/g'`
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def configure_new_app
|
43
|
+
generate_tokens
|
44
|
+
update_ruby_version
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_tokens
|
48
|
+
Dir.chdir(app_dir) do
|
49
|
+
`sed -i '' 's/SUPER_SECRET_TOKEN_REPLACE_ME_TODO/#{SecureRandom.hex(128)}/' #{app_dir}/config/initializers/secret_token.rb`
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def update_ruby_version
|
54
|
+
prototype_ruby_patch_level = File.read(File.expand_path('../../.rbenv-version', __FILE__)).strip
|
55
|
+
prototype_ruby_version = prototype_ruby_patch_level.match(/(\d\.\d\.\d).*/)[1]
|
56
|
+
current_ruby_version = RUBY_VERSION
|
57
|
+
current_ruby_patch_level = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
58
|
+
|
59
|
+
Dir.chdir(app_dir) do
|
60
|
+
`sed -i '' 's/#{prototype_ruby_patch_level}/#{current_ruby_patch_level}/g' .rvmrc .ruby-version`
|
61
|
+
`sed -i '' 's/#{prototype_ruby_version}/#{current_ruby_version}/g' Gemfile`
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def print_plan
|
66
|
+
puts
|
67
|
+
puts "Creating new app #{camel_name} in directory #{app_dir}..."
|
68
|
+
puts
|
69
|
+
end
|
70
|
+
|
71
|
+
def print_next_steps
|
72
|
+
puts "Done! Next steps..."
|
73
|
+
puts ""
|
74
|
+
puts "# Install updated dependencies"
|
75
|
+
puts "$ cd #{app_dir}"
|
76
|
+
puts "$ gem install bundler"
|
77
|
+
puts "$ bundle update"
|
78
|
+
puts ""
|
79
|
+
puts "# Prepare the database: schema and reference / sample data"
|
80
|
+
puts "$ rake db:setup db:sample_data"
|
81
|
+
puts ""
|
82
|
+
puts "# Run the specs (they should all pass)"
|
83
|
+
puts "$ rake"
|
84
|
+
puts ""
|
85
|
+
puts "# Load reference and sample data, then run the app and check things out"
|
86
|
+
puts "$ foreman start"
|
87
|
+
puts "$ open http://0.0.0.0:3000"
|
88
|
+
puts ""
|
89
|
+
puts "Enjoy your Carbon Five flavored Rails application!"
|
90
|
+
end
|
21
91
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
92
|
+
protected
|
93
|
+
|
94
|
+
def camelize(string)
|
95
|
+
result = string.sub(/^[a-z\d]*/) { $&.capitalize }
|
96
|
+
result.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }
|
97
|
+
end
|
98
|
+
|
99
|
+
def titleize(underscored_string)
|
100
|
+
result = underscored_string.gsub(/_/, ' ')
|
101
|
+
result.gsub(/\b('?[a-z])/) { $1.capitalize }
|
102
|
+
end
|
103
|
+
|
104
|
+
class << self
|
105
|
+
def parse(args)
|
106
|
+
raygun = nil
|
107
|
+
|
108
|
+
parser = OptionParser.new do |opts|
|
109
|
+
opts.banner = "Usage: raygun [options] NEW_APP_DIRECTORY"
|
110
|
+
|
111
|
+
opts.on("-h", "--help", "Show raygun usage") do |variable|
|
112
|
+
usage_and_exit(opts)
|
113
|
+
end
|
114
|
+
|
115
|
+
if ARGV.size == 0
|
116
|
+
usage_and_exit(opts)
|
117
|
+
else
|
118
|
+
raygun = Raygun::Runner.new(ARGV.first)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
begin
|
123
|
+
parser.parse!
|
124
|
+
rescue OptionParser::InvalidOption
|
125
|
+
usage_and_exit(parser)
|
126
|
+
end
|
127
|
+
|
128
|
+
raygun
|
129
|
+
end
|
130
|
+
|
131
|
+
def usage_and_exit(parser)
|
132
|
+
puts parser
|
133
|
+
exit 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
65
137
|
end
|
138
|
+
|
139
|
+
raygun = Raygun::Runner.parse(ARGV)
|
140
|
+
raygun.print_plan
|
141
|
+
raygun.copy_prototype
|
142
|
+
raygun.rename_new_app
|
143
|
+
raygun.configure_new_app
|
144
|
+
raygun.print_next_steps
|
data/lib/raygun/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raygun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-01-
|
14
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: Carbon Five Rails application generator
|
17
17
|
email:
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- app_prototype/db/seeds.rb
|
110
110
|
- app_prototype/lib/assets/.gitkeep
|
111
111
|
- app_prototype/lib/tasks/.gitkeep
|
112
|
+
- app_prototype/lib/tasks/cane.rake
|
112
113
|
- app_prototype/lib/tasks/coverage.rake
|
113
114
|
- app_prototype/lib/tasks/db.rake
|
114
115
|
- app_prototype/lib/tasks/spec.rake
|