raygun-gl 0.10.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 +19 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGES.md +149 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/NEXTSTEPS.taskpaper +5 -0
- data/README.md +86 -0
- data/Rakefile +1 -0
- data/bin/raygun +18 -0
- data/lib/colorize.rb +194 -0
- data/lib/raygun/gitlab_client.rb +24 -0
- data/lib/raygun/raygun.rb +413 -0
- data/lib/raygun/version.rb +3 -0
- data/marvin.jpg +0 -0
- data/raygun.gemspec +27 -0
- metadata +121 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8befec715f877059eebe18fe8c774b2726219dce
|
|
4
|
+
data.tar.gz: dbd5c72f9c8dadffc9eaac6d770ff62f27d1bbb3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e294778971ecc3792f8fd54f76980bd22855241d803c5cfb7a3e480d6bd0fe729676514893a0b2050936899b800c63906cf73891d6fab074eab5658171b4be37
|
|
7
|
+
data.tar.gz: 0dfd5f7b8d359109fab0bb21e137e7fa40a8de3ba392a3db6100b2a9895116eb31eeadb694f6f69d53a15cbd4ff05531439770dcec973c091f6dfb9be485a072
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
raygun
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.1.2
|
data/CHANGES.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## 0.9.4 [2014-02-11]
|
|
4
|
+
|
|
5
|
+
* Don't use patchlevels with ruby v2.1.0+, now that ruby has adopted semantic versioning.
|
|
6
|
+
* Fixed a typo (#124 , thanks redpoptarts!).
|
|
7
|
+
|
|
8
|
+
## 0.9.3 [2014-01-21]
|
|
9
|
+
|
|
10
|
+
* Use curl instead of wget, it's available by default on mavericks (wget is not).
|
|
11
|
+
|
|
12
|
+
## 0.9.2 [2013-12-03]
|
|
13
|
+
|
|
14
|
+
* Support custom project templates with the -p command line arg (#122, thanks @drogar!).
|
|
15
|
+
* Remove the stranded and useless .raygun-version from the generated app.
|
|
16
|
+
* Rename the rails prototype repo to raygun-rails (#123).
|
|
17
|
+
|
|
18
|
+
## 0.9.1 [2013-11-12]
|
|
19
|
+
|
|
20
|
+
* Fixed a bug that fouled up fetching tags from github (#118).
|
|
21
|
+
* Specify the license in the gemspec (#117).
|
|
22
|
+
|
|
23
|
+
## 0.9.0 [2013-11-11]
|
|
24
|
+
|
|
25
|
+
Note: All future changes to the application prototype (sample app) will be made in the [raygun-rails](https://github.com/carbonfive/raygun-rails) repo.
|
|
26
|
+
|
|
27
|
+
* Raygun no longer bundles the application prototype, it's fetched from github (https://github.com/carbonfive/raygun-rails) instead (#112).
|
|
28
|
+
* Drop support for Rails 3 (#116).
|
|
29
|
+
* Better bootstrap 3 support (#115, thanks @felafelwaffle!).
|
|
30
|
+
|
|
31
|
+
## 0.0.34 [2013-10-15]
|
|
32
|
+
|
|
33
|
+
* Nudge bundler to use guard v2.x (defaults to 1.x otherwise).
|
|
34
|
+
* Upgrade to bootstrap 3.0 (#114, thanks @drtoast!).
|
|
35
|
+
* RSpec's rake task patterns use globs, and don't work with regular expressions as one might expect (#107, thanks @wless1!).
|
|
36
|
+
* Include a deployment script for heroku and configuration for circleci for easy continuous deployment (#109, thanks @jonah-carbonfive!).
|
|
37
|
+
|
|
38
|
+
## 0.0.33 [2013-07-08]
|
|
39
|
+
|
|
40
|
+
* Raygun defaults to generating Rails 4 apps now (use -r 32 for Rails 3.2).
|
|
41
|
+
* Incluide a recipe for rack-canonical-host (#105). Set ENV['HOSTNAME'] to enable.
|
|
42
|
+
|
|
43
|
+
## 0.0.32 [2013-06-18]
|
|
44
|
+
|
|
45
|
+
* Rails 4: enable guard-livereload with a tweak to support .less files.
|
|
46
|
+
* Rails 4: enable guard-jasmine (with a sample spec).
|
|
47
|
+
|
|
48
|
+
## 0.0.31 [2013-06-16]
|
|
49
|
+
|
|
50
|
+
* For Heroku, default to serving static assets and the logger is synchronous by default (we don't have to set it) (#103).
|
|
51
|
+
* Less duplication in acceptance.rb, since it's basicially the same as production.rb.
|
|
52
|
+
* Fixed a regression where new apps might be configured with a non-existent ruby (#104).
|
|
53
|
+
|
|
54
|
+
## 0.0.30 [2013-06-14]
|
|
55
|
+
|
|
56
|
+
* Bug fix.
|
|
57
|
+
|
|
58
|
+
## 0.0.29 [2013-06-14]
|
|
59
|
+
|
|
60
|
+
* Migrate from ```.rvmrc``` to ```.ruby-version``` and ```.ruby-gemset``` (#93).
|
|
61
|
+
* Use database_cleaner instead of the shared connection (#101).
|
|
62
|
+
* Support generating rails 4.0 apps (beta!) using the ```-r 40``` command line flag.
|
|
63
|
+
* Improve and colorize output (#86).
|
|
64
|
+
|
|
65
|
+
## 0.0.28 [2013-03-26]
|
|
66
|
+
|
|
67
|
+
* Use unicorn by default instead of thin, as per heroku's recommendation.
|
|
68
|
+
* Suppress schema dumping unless run in development mode to eliminate pg_dump errors on heroku during db:migrate.
|
|
69
|
+
* Tweak mailcatcher configuration so that it only sets smtp_settings when mailcatcher is running.
|
|
70
|
+
ray
|
|
71
|
+
## 0.0.27 [2013-02-27]
|
|
72
|
+
|
|
73
|
+
* Make sure the target directory is empty, otherwise misfire.
|
|
74
|
+
* Use ruby-1.9.3-p392 for the project (new apps still use the version that invoked raygun) (thanks @rpak).
|
|
75
|
+
* Better detection of BSD vs GNU sed (thanks @orangejulius).
|
|
76
|
+
|
|
77
|
+
## 0.0.26 [2013-02-24]
|
|
78
|
+
|
|
79
|
+
* Validate presense of name on User.
|
|
80
|
+
* Drop rspec and capybara version constraints from the Gemfile.
|
|
81
|
+
|
|
82
|
+
## 0.0.25 [2013-02-20]
|
|
83
|
+
|
|
84
|
+
* Generated controller specs now pass without intervention.
|
|
85
|
+
* Generated view specs use factory_girl's build_stubbed instead of rspec's stub_model, expect() syntax, and 1.9 hash syntax.
|
|
86
|
+
* Initialize git and create an initial commit (thanks @blakeeb).
|
|
87
|
+
|
|
88
|
+
## 0.0.24 [2013-02-14]
|
|
89
|
+
|
|
90
|
+
* Upgrade to ruby-1.9.3-p385 (thanks @mechfish).
|
|
91
|
+
* Upgrade to rails ~> 3.2.12 (thanks @mechfish).
|
|
92
|
+
* Pay attention to shelled command's exit status and bail with a message if a command fails.
|
|
93
|
+
|
|
94
|
+
## 0.0.23 [2013-02-07]
|
|
95
|
+
|
|
96
|
+
* Fixed a bug with detecting whether we're on darwin or not.
|
|
97
|
+
* Remove some dead code (thanks @bemurphy).
|
|
98
|
+
|
|
99
|
+
## 0.0.22 [2013-02-07]
|
|
100
|
+
|
|
101
|
+
* Support ubuntu and darwin (sed has slightly different syntax for in-place substitution).
|
|
102
|
+
* Take lib off the load path by default.
|
|
103
|
+
|
|
104
|
+
## 0.0.21 [2013-02-01]
|
|
105
|
+
|
|
106
|
+
* Turn off threadsafe when running rake tasks (thanks @subakva).
|
|
107
|
+
|
|
108
|
+
## 0.0.20 [unreleased]
|
|
109
|
+
|
|
110
|
+
* Bug fix and minor output tweak.
|
|
111
|
+
|
|
112
|
+
## 0.0.19 [2013-01-29]
|
|
113
|
+
|
|
114
|
+
* Pull the rails secret token from the environment so it can be easily set in server environments.
|
|
115
|
+
* Dump the static index.html for a dynamic version.
|
|
116
|
+
|
|
117
|
+
## 0.0.18 [2013-01-24]
|
|
118
|
+
|
|
119
|
+
* Support generating an app in the current directory (thanks @subakva).
|
|
120
|
+
* Better handling of command line arguments (thanks @subakva).
|
|
121
|
+
* Include support for cane quality checks via ```rake spec:cane``` (thanks @subakva).
|
|
122
|
+
|
|
123
|
+
## 0.0.17 [2013-01-17]
|
|
124
|
+
|
|
125
|
+
* Configure .ruby-version, .rvmrc, and Gemfile with the version of ruby used to execute raygun.
|
|
126
|
+
* Improve the default email content.
|
|
127
|
+
* Improve the raygun and app_prototype READMEs.
|
|
128
|
+
* Use $PORT to set the server port for Heroku compatibility, with default set in .env.
|
|
129
|
+
* .ruby-version instead of .rbenv-version (as recommended by rbenv).
|
|
130
|
+
* Add a unique database constraint on users.email.
|
|
131
|
+
|
|
132
|
+
## 0.0.16 [2013-01-04]
|
|
133
|
+
|
|
134
|
+
* Improved authorization rules so that users can't delete themselves and non-admin can't access users controller :new.
|
|
135
|
+
|
|
136
|
+
## 0.0.15 [2012-12-26]
|
|
137
|
+
|
|
138
|
+
* Handle cases where raygun is given a name with dashes (e.g wonder-pets).
|
|
139
|
+
* Replace all instances of app_prototype with the real app name.
|
|
140
|
+
|
|
141
|
+
## 0.0.14 [2012-12-26]
|
|
142
|
+
|
|
143
|
+
* Basic usage information.
|
|
144
|
+
* Added guard-livereload to Guardfile.
|
|
145
|
+
* Better specs for auth flows (register, password reset, sign in) (~98% coverage).
|
|
146
|
+
* Use the new rspec expect(...).to syntax ([more info](http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax)).
|
|
147
|
+
* Hardcode 1.9.3-p327 so that app_prototype is executable without futzing.
|
|
148
|
+
* Consistent hostnames across environments.
|
|
149
|
+
* Use mailcatcher when it's running locally ([more info](http://www.mikeperham.com/2012/12/09/12-gems-of-christmas-4-mailcatcher-and-mail_view/)).
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Carbon Five
|
|
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/NEXTSTEPS.taskpaper
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
[](http://badge.fury.io/rb/raygun-gl)
|
|
2
|
+
<img src="https://raw.github.com/lastobelus/raygun-gl/master/marvin.jpg" align="right"/>
|
|
3
|
+
|
|
4
|
+
# Raygun GL
|
|
5
|
+
|
|
6
|
+
Rails application generator that builds a new project skeleton from prototype app repos which can live either on github or a private gitlab instance.
|
|
7
|
+
|
|
8
|
+
Raygun-gl generates Rails 4 projects by copying a sample app and massaging it gently into shape. It is a fork of https://github.com/carbonfive/raygun but does not supply an app prototype. Instead it allows you to use (your own) app prototype repos that are hosted either on github or a private gitlab instance. If you want to us Carbon Five's app prototype, raygun-gl does not provide any extra functionality over Carbon Five's original version (except for the `--embed_as` option)
|
|
9
|
+
|
|
10
|
+
## Projects Goals
|
|
11
|
+
|
|
12
|
+
Raygun GL...
|
|
13
|
+
|
|
14
|
+
* Generates a new rails application that's ready for immediate feature development.
|
|
15
|
+
* Generates an application that has YOUR best practices that apply to most projects baked in.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
$ gem install raygun-gl
|
|
20
|
+
|
|
21
|
+
## Prerequisites
|
|
22
|
+
|
|
23
|
+
To generate an application, you only need the raygun-gl gem and network connectivity.
|
|
24
|
+
|
|
25
|
+
The generated app will be configured to use the ruby version that was used to invoke raygun. If you're using
|
|
26
|
+
another ruby, just change the ```Gemfile``` and ```.ruby-version``` as necessary.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
$ raygun-gl your-project
|
|
31
|
+
|
|
32
|
+
## Using Project Template
|
|
33
|
+
|
|
34
|
+
The default is to use the project at [carbonfive/raygun-rails](https://github.com/carbonfive/raygun-rails) as a
|
|
35
|
+
starting point. You can use another repo as the project template with the ```-p``` and/or ```-g``` command line options.
|
|
36
|
+
|
|
37
|
+
If you invoke raygun-gl with the ```-p``` option, you can specify your own github repository.
|
|
38
|
+
|
|
39
|
+
$ raygun -p githubid/repo your-project
|
|
40
|
+
|
|
41
|
+
The repository must:
|
|
42
|
+
|
|
43
|
+
* Not have any binary files. Raygun runs a 'sed' command on all files, which will fail on binaries, such as jar files.
|
|
44
|
+
|
|
45
|
+
For github repos, the repository must have been tagged. Raygun chooses the "greatest" tag and downloads the repository as of that tag -- this is the original way the Carbon Five version. For gitlab repos you can (must) supply a ref (branch or tag) with `-r`
|
|
46
|
+
|
|
47
|
+
If your project template requires a minimum version of raygun, include the version in a file called
|
|
48
|
+
```.raygun-version``` at the root. Raygun will make sure it's new enough for your repo.
|
|
49
|
+
|
|
50
|
+
If you want to use a project template that lives on a gitlab instance, invoke raygun-gl with the ```-g``` option or set the `GITLAB_API_ENDPOINT` environment variable to your gitlab instance url. Currently, you must also use the `-r` option to specify a ref (branch or tag). You must either set your private token in env `GITLAB_API_PRIVATE_TOKEN`, or, if using OS X you can store it in your keychain in a generic password named `[gitlab endpoint host]-private-token`
|
|
51
|
+
|
|
52
|
+
$ raygun -g https://gitlab.mydomain.com -p gitlabid/repo -r v1.0.0 your-project
|
|
53
|
+
|
|
54
|
+
## Embed As
|
|
55
|
+
|
|
56
|
+
If the rails app you are generating is a part of another project (example: the backend in an Ember app), you can use the `--embed_as` option to specify what its directory should be called:
|
|
57
|
+
|
|
58
|
+
$ raygun -g https://gitlab.mydomain.com -p gitlabid/repo -r v1.0.0 -e rails /path/to/ember-project
|
|
59
|
+
|
|
60
|
+
This example will generate a rails app in `/path/to/ember-project/rails`, creating `/path/to/ember-project` if it doesn't exist, and doing `git init` in `/path/to/ember-project` **IF** `/path/to/ember-projec/.git` doesn't already exist before committing the generated app.
|
|
61
|
+
|
|
62
|
+
## Internal Mechanics
|
|
63
|
+
|
|
64
|
+
Raygun fetches the greatest tag from the [carbonfive/raygun-rails](https://github.com/carbonfive/raygun-rails)
|
|
65
|
+
repo, or the specified branch/tag from the specified repo, unless it already has it cached in ~/.raygun, extracts the contents of the tarball, and runs a series of search-and-replaces on the code to customize it accordingly.
|
|
66
|
+
|
|
67
|
+
This approach is fast, simple, and makes raygun development very easy. Make changes to the application
|
|
68
|
+
prototype (which is a valid rails app) and tag them when they should be used for new applications.
|
|
69
|
+
|
|
70
|
+
## Contributing
|
|
71
|
+
|
|
72
|
+
1. Fork it
|
|
73
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
74
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
75
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
76
|
+
5. Create new Pull Request
|
|
77
|
+
|
|
78
|
+
### Development
|
|
79
|
+
|
|
80
|
+
Generate an example app using your local development version of raygun-gl:
|
|
81
|
+
|
|
82
|
+
$ ./bin/raygun-gl tmp/example_app
|
|
83
|
+
|
|
84
|
+
## Changes
|
|
85
|
+
|
|
86
|
+
[View the Change Log](https://github.com/lastobelus/raygun-gl/tree/master/CHANGES.md)
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/raygun
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
File.expand_path('../../lib', __FILE__).tap do |lib|
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'raygun/raygun'
|
|
8
|
+
|
|
9
|
+
raygun = Raygun::Runner.parse(ARGV)
|
|
10
|
+
|
|
11
|
+
raygun.check_target
|
|
12
|
+
raygun.print_plan
|
|
13
|
+
raygun.fetch_prototype
|
|
14
|
+
raygun.check_raygun_version
|
|
15
|
+
raygun.copy_prototype
|
|
16
|
+
raygun.rename_new_app
|
|
17
|
+
raygun.configure_new_app
|
|
18
|
+
raygun.print_next_steps
|
data/lib/colorize.rb
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Colorize String class extension.
|
|
3
|
+
#
|
|
4
|
+
# Borrowed directly from the colorize gem. It hasn't changed in 4 years and I didn't
|
|
5
|
+
# want to add a gem dependency.
|
|
6
|
+
|
|
7
|
+
class String
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# Colors Hash
|
|
11
|
+
#
|
|
12
|
+
COLORS = {
|
|
13
|
+
:black => 0,
|
|
14
|
+
:red => 1,
|
|
15
|
+
:green => 2,
|
|
16
|
+
:yellow => 3,
|
|
17
|
+
:blue => 4,
|
|
18
|
+
:magenta => 5,
|
|
19
|
+
:cyan => 6,
|
|
20
|
+
:white => 7,
|
|
21
|
+
:default => 9,
|
|
22
|
+
|
|
23
|
+
:light_black => 10,
|
|
24
|
+
:light_red => 11,
|
|
25
|
+
:light_green => 12,
|
|
26
|
+
:light_yellow => 13,
|
|
27
|
+
:light_blue => 14,
|
|
28
|
+
:light_magenta => 15,
|
|
29
|
+
:light_cyan => 16,
|
|
30
|
+
:light_white => 17
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# Modes Hash
|
|
35
|
+
#
|
|
36
|
+
MODES = {
|
|
37
|
+
:default => 0, # Turn off all attributes
|
|
38
|
+
#:bright => 1, # Set bright mode
|
|
39
|
+
:underline => 4, # Set underline mode
|
|
40
|
+
:blink => 5, # Set blink mode
|
|
41
|
+
:swap => 7, # Exchange foreground and background colors
|
|
42
|
+
:hide => 8 # Hide text (foreground color would be the same as background)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Set color values in new string intance
|
|
49
|
+
#
|
|
50
|
+
def set_color_parameters( params )
|
|
51
|
+
if (params.instance_of?(Hash))
|
|
52
|
+
@color = params[:color]
|
|
53
|
+
@background = params[:background]
|
|
54
|
+
@mode = params[:mode]
|
|
55
|
+
@uncolorized = params[:uncolorized]
|
|
56
|
+
self
|
|
57
|
+
else
|
|
58
|
+
nil
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
public
|
|
63
|
+
|
|
64
|
+
#
|
|
65
|
+
# Change color of string
|
|
66
|
+
#
|
|
67
|
+
# Examples:
|
|
68
|
+
#
|
|
69
|
+
# puts "This is blue".colorize( :blue )
|
|
70
|
+
# puts "This is light blue".colorize( :light_blue )
|
|
71
|
+
# puts "This is also blue".colorize( :color => :blue )
|
|
72
|
+
# puts "This is light blue with red background".colorize( :color => :light_blue, :background => :red )
|
|
73
|
+
# puts "This is light blue with red background".colorize( :light_blue ).colorize( :background => :red )
|
|
74
|
+
# puts "This is blue text on red".blue.on_red
|
|
75
|
+
# puts "This is red on blue".colorize( :red ).on_blue
|
|
76
|
+
# puts "This is red on blue and underline".colorize( :red ).on_blue.underline
|
|
77
|
+
# puts "This is blue text on red".blue.on_red.blink
|
|
78
|
+
# puts "This is uncolorized".blue.on_red.uncolorize
|
|
79
|
+
#
|
|
80
|
+
def colorize( params )
|
|
81
|
+
return self unless STDOUT.isatty
|
|
82
|
+
|
|
83
|
+
begin
|
|
84
|
+
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
|
|
85
|
+
rescue LoadError
|
|
86
|
+
raise 'You must gem install win32console to use colorize on Windows'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
color_parameters = {}
|
|
90
|
+
|
|
91
|
+
if (params.instance_of?(Hash))
|
|
92
|
+
color_parameters[:color] = COLORS[params[:color]]
|
|
93
|
+
color_parameters[:background] = COLORS[params[:background]]
|
|
94
|
+
color_parameters[:mode] = MODES[params[:mode]]
|
|
95
|
+
elsif (params.instance_of?(Symbol))
|
|
96
|
+
color_parameters[:color] = COLORS[params]
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
color_parameters[:color] ||= @color ||= COLORS[:default]
|
|
100
|
+
color_parameters[:background] ||= @background ||= COLORS[:default]
|
|
101
|
+
color_parameters[:mode] ||= @mode ||= MODES[:default]
|
|
102
|
+
|
|
103
|
+
color_parameters[:uncolorized] ||= @uncolorized ||= self.dup
|
|
104
|
+
|
|
105
|
+
# calculate bright mode
|
|
106
|
+
color_parameters[:color] += 50 if color_parameters[:color] > 10
|
|
107
|
+
|
|
108
|
+
color_parameters[:background] += 50 if color_parameters[:background] > 10
|
|
109
|
+
|
|
110
|
+
"\033[#{color_parameters[:mode]};#{color_parameters[:color]+30};#{color_parameters[:background]+40}m#{color_parameters[:uncolorized]}\033[0m".set_color_parameters( color_parameters )
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
#
|
|
114
|
+
# Return uncolorized string
|
|
115
|
+
#
|
|
116
|
+
def uncolorize
|
|
117
|
+
@uncolorized || self
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
#
|
|
121
|
+
# Return true if sting is colorized
|
|
122
|
+
#
|
|
123
|
+
def colorized?
|
|
124
|
+
!defined?(@uncolorized).nil?
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
#
|
|
128
|
+
# Make some color and on_color methods
|
|
129
|
+
#
|
|
130
|
+
COLORS.each_key do | key |
|
|
131
|
+
next if key == :default
|
|
132
|
+
|
|
133
|
+
define_method key do
|
|
134
|
+
self.colorize( :color => key )
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
define_method "on_#{key}" do
|
|
138
|
+
self.colorize( :background => key )
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
#
|
|
143
|
+
# Methods for modes
|
|
144
|
+
#
|
|
145
|
+
MODES.each_key do | key |
|
|
146
|
+
next if key == :default
|
|
147
|
+
|
|
148
|
+
define_method key do
|
|
149
|
+
self.colorize( :mode => key )
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
class << self
|
|
154
|
+
|
|
155
|
+
#
|
|
156
|
+
# Return array of available modes used by colorize method
|
|
157
|
+
#
|
|
158
|
+
def modes
|
|
159
|
+
keys = []
|
|
160
|
+
MODES.each_key do | key |
|
|
161
|
+
keys << key
|
|
162
|
+
end
|
|
163
|
+
keys
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
#
|
|
167
|
+
# Return array of available colors used by colorize method
|
|
168
|
+
#
|
|
169
|
+
def colors
|
|
170
|
+
keys = []
|
|
171
|
+
COLORS.each_key do | key |
|
|
172
|
+
keys << key
|
|
173
|
+
end
|
|
174
|
+
keys
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
#
|
|
178
|
+
# Display color matrix with color names.
|
|
179
|
+
#
|
|
180
|
+
def color_matrix( txt = "[X]" )
|
|
181
|
+
size = String.colors.length
|
|
182
|
+
String.colors.each do | color |
|
|
183
|
+
String.colors.each do | back |
|
|
184
|
+
print txt.colorize( :color => color, :background => back )
|
|
185
|
+
end
|
|
186
|
+
puts " < #{color}"
|
|
187
|
+
end
|
|
188
|
+
String.colors.reverse.each_with_index do | back, index |
|
|
189
|
+
puts "#{"|".rjust(txt.length)*(size-index)} < #{back}"
|
|
190
|
+
end
|
|
191
|
+
""
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'gitlab'
|
|
2
|
+
|
|
3
|
+
module Raygun
|
|
4
|
+
class GitlabClient
|
|
5
|
+
|
|
6
|
+
attr_accessor :uri, :endpoint, :token
|
|
7
|
+
def initialize(endpoint)
|
|
8
|
+
@endpoint = URI.parse(endpoint)
|
|
9
|
+
@token = ENV['GITLAB_API_PRIVATE_TOKEN']
|
|
10
|
+
unless `which security`.empty?
|
|
11
|
+
cmd = "security 2>&1 >/dev/null find-generic-password -g -l#{@endpoint.host}-private-token"
|
|
12
|
+
@token ||= `#{cmd}`.gsub(/password: *"([^"]+)"\n/, '\1')
|
|
13
|
+
end
|
|
14
|
+
Gitlab.configure do |config|
|
|
15
|
+
config.endpoint = endpoint
|
|
16
|
+
config.private_token = @token
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def domain
|
|
21
|
+
endpoint.host
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
require 'optparse'
|
|
2
|
+
require 'ostruct'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'securerandom'
|
|
5
|
+
require 'net/http'
|
|
6
|
+
require 'json'
|
|
7
|
+
require 'colorize'
|
|
8
|
+
|
|
9
|
+
require_relative 'version'
|
|
10
|
+
require_relative 'gitlab_client'
|
|
11
|
+
|
|
12
|
+
module Raygun
|
|
13
|
+
class Runner
|
|
14
|
+
CARBONFIVE_REPO = 'carbonfive/raygun-rails'
|
|
15
|
+
|
|
16
|
+
attr_accessor :target_dir, :app_dir, :app_name, :dash_name, :snake_name, :camel_name, :title_name, :prototype_repo,
|
|
17
|
+
:gitlab_endpoint, :ref, :embed_as, :current_ruby_version, :current_ruby_patch_level
|
|
18
|
+
|
|
19
|
+
def initialize(target_dir, prototype_repo, gitlab_endpoint, ref, embed_as)
|
|
20
|
+
@target_dir = target_dir
|
|
21
|
+
@app_dir = File.expand_path(target_dir.strip.to_s)
|
|
22
|
+
@app_name = File.basename(app_dir).gsub(/\s+/, '-')
|
|
23
|
+
@dash_name = app_name.gsub('_', '-')
|
|
24
|
+
@snake_name = app_name.gsub('-', '_')
|
|
25
|
+
@camel_name = camelize(snake_name)
|
|
26
|
+
@title_name = titleize(snake_name)
|
|
27
|
+
@prototype_repo = prototype_repo
|
|
28
|
+
@gitlab_endpoint = gitlab_endpoint
|
|
29
|
+
@ref = ref
|
|
30
|
+
@embed_as = embed_as
|
|
31
|
+
if embed_as
|
|
32
|
+
FileUtils.mkdir_p(app_dir) unless File.exist?(app_dir)
|
|
33
|
+
@app_dir = File.join(app_dir, embed_as)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
@current_ruby_version = RUBY_VERSION
|
|
37
|
+
@current_ruby_patch_level = if RUBY_VERSION < '2.1.0' # Ruby adopted semver starting with 2.1.0.
|
|
38
|
+
"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
|
39
|
+
else
|
|
40
|
+
"#{RUBY_VERSION}"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def check_target
|
|
45
|
+
unless Dir["#{@app_dir}/*"].empty?
|
|
46
|
+
puts "Misfire! The target directory isn't empty... aim elsewhere."
|
|
47
|
+
exit 1
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def gitlab?
|
|
53
|
+
!!@gitlab_endpoint
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def gitlab_client
|
|
57
|
+
@gitlab_client ||= GitlabClient.new(gitlab_endpoint)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def gitlab_project_id
|
|
61
|
+
@gitlab_project_id ||= parse_gitlab_project_id
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def parse_gitlab_project_id
|
|
65
|
+
if prototype_repo.to_i == prototype_repo
|
|
66
|
+
prototype_repo
|
|
67
|
+
else
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def fetch_prototype
|
|
73
|
+
if gitlab?
|
|
74
|
+
fetch_prototype_from_gitlab
|
|
75
|
+
else
|
|
76
|
+
fetch_prototype_from_github
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def cached_prototypes_dir; File.join(Dir.home, ".raygun"); end
|
|
81
|
+
|
|
82
|
+
def fetch_prototype_from_gitlab
|
|
83
|
+
print "Checking for the latest application prototype on gitlab...".colorize(:yellow)
|
|
84
|
+
$stdout.flush
|
|
85
|
+
|
|
86
|
+
latest_tag = ref || fetch_latest_tag_gitlab(prototype_repo)
|
|
87
|
+
|
|
88
|
+
gitlab_cached_prototypes_dir = File.join(cached_prototypes_dir, gitlab_client.domain)
|
|
89
|
+
@prototype = File.join(gitlab_cached_prototypes_dir, "#{prototype_repo.sub('/', '--')}-#{latest_tag}.tar.gz")
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if File.exists?(@prototype)
|
|
94
|
+
puts " Using cached version.".colorize(:yellow)
|
|
95
|
+
else
|
|
96
|
+
print " Downloading...".colorize(:yellow)
|
|
97
|
+
$stdout.flush
|
|
98
|
+
|
|
99
|
+
# Download the tarball and install in the cache.
|
|
100
|
+
Dir.mkdir(gitlab_cached_prototypes_dir, 0755) unless Dir.exists?(gitlab_cached_prototypes_dir)
|
|
101
|
+
tarball_url = URI([gitlab_endpoint, prototype_repo, "repository", "archive.tar.gz"].join('/'))
|
|
102
|
+
tarball_url.query = URI.encode_www_form(private_token: gitlab_client.token, ref: latest_tag)
|
|
103
|
+
|
|
104
|
+
shell "curl -s -L '#{tarball_url.to_s}' -o #{@prototype}"
|
|
105
|
+
puts " done!".colorize(:yellow)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
$stdout.flush
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def fetch_prototype_from_github
|
|
113
|
+
print "Checking for the latest application prototype...".colorize(:yellow)
|
|
114
|
+
$stdout.flush
|
|
115
|
+
|
|
116
|
+
# Check if we can connect, or fail gracefully and use the latest cached version.
|
|
117
|
+
latest_tag_obj = fetch_latest_tag(prototype_repo)
|
|
118
|
+
latest_tag = latest_tag_obj['name']
|
|
119
|
+
tarball_url = latest_tag_obj['tarball_url']
|
|
120
|
+
|
|
121
|
+
print " #{latest_tag}.".colorize(:white)
|
|
122
|
+
$stdout.flush
|
|
123
|
+
|
|
124
|
+
@prototype = "#{cached_prototypes_dir}/#{prototype_repo.sub('/', '--')}-#{latest_tag}.tar.gz"
|
|
125
|
+
|
|
126
|
+
# Do we already have the tarball cached under ~/.raygun?
|
|
127
|
+
if File.exists?(@prototype)
|
|
128
|
+
puts " Using cached version.".colorize(:yellow)
|
|
129
|
+
else
|
|
130
|
+
print " Downloading...".colorize(:yellow)
|
|
131
|
+
$stdout.flush
|
|
132
|
+
|
|
133
|
+
# Download the tarball and install in the cache.
|
|
134
|
+
Dir.mkdir(cached_prototypes_dir, 0755) unless Dir.exists?(cached_prototypes_dir)
|
|
135
|
+
|
|
136
|
+
shell "curl -s -L #{tarball_url} -o #{@prototype}"
|
|
137
|
+
puts " done!".colorize(:yellow)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def check_raygun_version
|
|
142
|
+
required_raygun_version =
|
|
143
|
+
%x{tar xfz #{@prototype} --include "*.raygun-version" -O 2> /dev/null}.chomp ||
|
|
144
|
+
::Raygun::VERSION
|
|
145
|
+
|
|
146
|
+
if Gem::Version.new(required_raygun_version) > Gem::Version.new(::Raygun::VERSION)
|
|
147
|
+
puts ""
|
|
148
|
+
print "Hold up!".colorize(:red)
|
|
149
|
+
print " This version of the raygun gem (".colorize(:light_red)
|
|
150
|
+
print "#{::Raygun::VERSION})".colorize(:white)
|
|
151
|
+
print " is too old to generate this application (needs ".colorize(:light_red)
|
|
152
|
+
print "#{required_raygun_version}".colorize(:white)
|
|
153
|
+
puts " or newer).".colorize(:light_red)
|
|
154
|
+
puts ""
|
|
155
|
+
print "Please update the gem by running ".colorize(:light_red)
|
|
156
|
+
print "gem update raygun".colorize(:white)
|
|
157
|
+
puts ", and try again. Thanks!".colorize(:light_red)
|
|
158
|
+
puts ""
|
|
159
|
+
exit 1
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def copy_prototype
|
|
164
|
+
FileUtils.mkdir_p(app_dir)
|
|
165
|
+
|
|
166
|
+
shell "tar xfz #{@prototype} -C #{app_dir}"
|
|
167
|
+
|
|
168
|
+
# Github includes an extra directory layer in the tag tarball.
|
|
169
|
+
extraneous_dir = Dir.glob("#{app_dir}/*").first
|
|
170
|
+
dirs_to_move = Dir.glob("#{extraneous_dir}/*", File::FNM_DOTMATCH)
|
|
171
|
+
.reject { |d| %w{. ..}.include?(File.basename(d)) }
|
|
172
|
+
|
|
173
|
+
FileUtils.mv dirs_to_move, app_dir
|
|
174
|
+
FileUtils.remove_dir extraneous_dir
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def rename_new_app
|
|
178
|
+
Dir.chdir(app_dir) do
|
|
179
|
+
{
|
|
180
|
+
'AppPrototype' => camel_name,
|
|
181
|
+
'app-prototype' => dash_name,
|
|
182
|
+
'app_prototype' => snake_name,
|
|
183
|
+
'App Prototype' => title_name
|
|
184
|
+
}.each do |proto_name, new_name|
|
|
185
|
+
shell "find . -type f -print | xargs #{sed_i} 's/#{proto_name}/#{new_name}/g'"
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def configure_new_app
|
|
191
|
+
clean_up_unwanted_files
|
|
192
|
+
|
|
193
|
+
update_ruby_version
|
|
194
|
+
|
|
195
|
+
initialize_git
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def clean_up_unwanted_files
|
|
199
|
+
FileUtils.rm "#{app_dir}/.raygun-version", force: true
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def update_ruby_version
|
|
203
|
+
prototype_ruby_patch_level = File.read(File.expand_path("#{app_dir}/.ruby-version", __FILE__)).strip
|
|
204
|
+
prototype_ruby_version = prototype_ruby_patch_level.match(/(\d\.\d\.\d).*/)[1]
|
|
205
|
+
|
|
206
|
+
Dir.chdir(app_dir) do
|
|
207
|
+
shell "#{sed_i} 's/#{prototype_ruby_patch_level}/#{@current_ruby_patch_level}/g' .ruby-version README.md"
|
|
208
|
+
shell "#{sed_i} 's/#{prototype_ruby_version}/#{@current_ruby_version}/g' Gemfile"
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def initialize_git
|
|
213
|
+
dir = app_dir
|
|
214
|
+
dir = File.join(dir, '..') if embed_as
|
|
215
|
+
Dir.chdir(dir) do
|
|
216
|
+
shell "git init" unless (embed_as && File.exist?('.git'))
|
|
217
|
+
shell "git add -A ."
|
|
218
|
+
shell "git commit -m 'Raygun-zapped skeleton.'"
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def print_plan
|
|
223
|
+
puts ' ____ '.colorize(:light_yellow)
|
|
224
|
+
puts ' / __ \____ ___ ______ ___ ______ '.colorize(:light_yellow)
|
|
225
|
+
puts ' / /_/ / __ `/ / / / __ `/ / / / __ \ '.colorize(:light_yellow)
|
|
226
|
+
puts ' / _, _/ /_/ / /_/ / /_/ / /_/ / / / / '.colorize(:light_yellow)
|
|
227
|
+
puts ' /_/ |_|\__,_/\__, /\__, /\__,_/_/ /_/ '.colorize(:light_yellow)
|
|
228
|
+
puts ' /____//____/ '.colorize(:light_yellow)
|
|
229
|
+
puts
|
|
230
|
+
puts "Raygun will create new app in directory:".colorize(:yellow) + " #{target_dir}".colorize(:yellow) + "...".colorize(:yellow)
|
|
231
|
+
puts
|
|
232
|
+
puts "-".colorize(:blue) + " Application Name:".colorize(:light_blue) + " #{title_name}".colorize(:light_green)
|
|
233
|
+
if gitlab?
|
|
234
|
+
puts "-".colorize(:blue) + " Gitlab Endpoint: ".colorize(:light_blue) + " #{gitlab_endpoint}".colorize(:light_green)
|
|
235
|
+
end
|
|
236
|
+
puts "-".colorize(:blue) + " Project Template:".colorize(:light_blue) + " #{prototype_repo}".colorize(:light_green)
|
|
237
|
+
if ref
|
|
238
|
+
puts "-".colorize(:blue) + " Branch/Tag: ".colorize(:light_blue) + " #{ref}".colorize(:light_green)
|
|
239
|
+
end
|
|
240
|
+
if embed_as
|
|
241
|
+
puts "-".colorize(:blue) + " Embed as: ".colorize(:light_blue) + " #{embed_as}".colorize(:light_green)
|
|
242
|
+
end
|
|
243
|
+
puts "-".colorize(:blue) + " Ruby Version: ".colorize(:light_blue) + " #{@current_ruby_patch_level}".colorize(:light_green)
|
|
244
|
+
puts
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def print_next_steps
|
|
248
|
+
if @prototype_repo == CARBONFIVE_REPO
|
|
249
|
+
print_next_steps_carbon_five
|
|
250
|
+
else
|
|
251
|
+
print_next_steps_for_custom_repo
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def print_next_steps_carbon_five
|
|
256
|
+
puts ""
|
|
257
|
+
puts "Zap! Your application is ready. Next steps...".colorize(:yellow)
|
|
258
|
+
puts ""
|
|
259
|
+
puts "# Install updated dependencies".colorize(:light_green)
|
|
260
|
+
puts "$".colorize(:blue) + " cd #{target_dir}".colorize(:light_blue)
|
|
261
|
+
puts "$".colorize(:blue) + " gem install bundler".colorize(:light_blue)
|
|
262
|
+
puts "$".colorize(:blue) + " bundle".colorize(:light_blue)
|
|
263
|
+
puts ""
|
|
264
|
+
puts "# Prepare the database: schema and reference / sample data".colorize(:light_green)
|
|
265
|
+
puts "$".colorize(:blue) + " rake db:setup db:sample_data".colorize(:light_blue)
|
|
266
|
+
puts ""
|
|
267
|
+
puts "# Run the specs (they should all pass)".colorize(:light_green)
|
|
268
|
+
puts "$".colorize(:blue) + " rake".colorize(:light_blue)
|
|
269
|
+
puts ""
|
|
270
|
+
puts "# Run the app and check things out".colorize(:light_green)
|
|
271
|
+
puts "$".colorize(:blue) + " foreman start".colorize(:light_blue)
|
|
272
|
+
puts "$".colorize(:blue) + " open http://localhost:3000".colorize(:light_blue)
|
|
273
|
+
puts ""
|
|
274
|
+
puts "Enjoy your Carbon Five flavored Rails application!".colorize(:yellow)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def print_next_steps_for_custom_repo
|
|
278
|
+
puts ""
|
|
279
|
+
puts "Zap! Your application is ready.".colorize(:yellow)
|
|
280
|
+
puts ""
|
|
281
|
+
puts "Enjoy your raygun generated application!".colorize(:yellow)
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
protected
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
# Fetch the tags for the repo (e.g. 'carbonfive/raygun-rails') and return the latest as JSON.
|
|
288
|
+
def fetch_latest_tag(repo)
|
|
289
|
+
url = "https://api.github.com/repos/#{repo}/tags"
|
|
290
|
+
uri = URI.parse(url)
|
|
291
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
292
|
+
http.use_ssl = true
|
|
293
|
+
request = Net::HTTP::Get.new(URI.encode(url))
|
|
294
|
+
|
|
295
|
+
response = http.request(request)
|
|
296
|
+
|
|
297
|
+
unless response.code == "200"
|
|
298
|
+
puts ""
|
|
299
|
+
print "Whoops - need to try again!".colorize(:red)
|
|
300
|
+
puts ""
|
|
301
|
+
print "We could not find (".colorize(:light_red)
|
|
302
|
+
print "#{repo}".colorize(:white)
|
|
303
|
+
print ") on github.".colorize(:light_red)
|
|
304
|
+
puts ""
|
|
305
|
+
print "The response from github was a (".colorize(:light_red)
|
|
306
|
+
print "#{response.code}".colorize(:white)
|
|
307
|
+
puts ") which I'm sure you can fix right up!".colorize(:light_red)
|
|
308
|
+
puts ""
|
|
309
|
+
exit 1
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
result = JSON.parse(response.body).first
|
|
313
|
+
unless result
|
|
314
|
+
puts ""
|
|
315
|
+
print "Whoops - need to try again!".colorize(:red)
|
|
316
|
+
puts ""
|
|
317
|
+
print "We could not find any tags in the repo (".colorize(:light_red)
|
|
318
|
+
print "#{repo}".colorize(:white)
|
|
319
|
+
print ") on github.".colorize(:light_red)
|
|
320
|
+
puts ""
|
|
321
|
+
print "Raygun uses the 'largest' tag in a repository, where tags are sorted alphanumerically.".colorize(:light_red)
|
|
322
|
+
puts ""
|
|
323
|
+
print "E.g., tag 'v.0.10.0' > 'v.0.9.9' and 'x' > 'a'.".colorize(:light_red)
|
|
324
|
+
print ""
|
|
325
|
+
puts ""
|
|
326
|
+
exit 1
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
result
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def fetch_latest_tag_gitlab(repo)
|
|
333
|
+
puts "latest tag not implemented. Please supply a ref with -r".colorize(:red)
|
|
334
|
+
exit 1
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def camelize(string)
|
|
338
|
+
result = string.sub(/^[a-z\d]*/) { $&.capitalize }
|
|
339
|
+
result.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def titleize(underscored_string)
|
|
343
|
+
result = underscored_string.gsub(/_/, ' ')
|
|
344
|
+
result.gsub(/\b('?[a-z])/) { $1.capitalize }
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
# Distinguish BSD vs GNU sed with the --version flag (only present in GNU sed).
|
|
348
|
+
def sed_i
|
|
349
|
+
@sed_format ||= begin
|
|
350
|
+
%x{sed --version &> /dev/null}
|
|
351
|
+
$?.success? ? "sed -i" : "sed -i ''"
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
# Run a shell command and raise an exception if it fails.
|
|
356
|
+
def shell(command)
|
|
357
|
+
%x{#{command}}
|
|
358
|
+
raise "#{command} failed with status #{$?.exitstatus}." unless $?.success?
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def self.parse(args)
|
|
362
|
+
raygun = nil
|
|
363
|
+
|
|
364
|
+
options = OpenStruct.new
|
|
365
|
+
options.target_dir = nil
|
|
366
|
+
options.prototype_repo = CARBONFIVE_REPO
|
|
367
|
+
options.gitlab_endpoint = nil
|
|
368
|
+
|
|
369
|
+
parser = OptionParser.new do |opts|
|
|
370
|
+
opts.banner = "Usage: raygun [options] NEW_APP_DIRECTORY"
|
|
371
|
+
|
|
372
|
+
opts.on('-h', '--help', "Show raygun usage") do
|
|
373
|
+
usage_and_exit(opts)
|
|
374
|
+
end
|
|
375
|
+
opts.on('-p', '--prototype [github_repo]', "Prototype github repo (e.g. carbonfive/raygun-rails).") do |prototype|
|
|
376
|
+
options.prototype_repo = prototype
|
|
377
|
+
end
|
|
378
|
+
opts.on('-g', '--gitlab [gitlab_endpoint]', "Gitlab instance where the prototype repo can be found.") do |gitlab|
|
|
379
|
+
gitlab ||= ENV['GITLAB_API_ENDPOINT']
|
|
380
|
+
if gitlab.nil? || gitlab.empty?
|
|
381
|
+
raise "--gitlab specified with no endpoint and $GITLAB_API_ENDPOINT was empty"
|
|
382
|
+
end
|
|
383
|
+
options.gitlab_endpoint = gitlab
|
|
384
|
+
end
|
|
385
|
+
opts.on('-r', '--ref [branch-or-tag]', "Git ref on prototype-repo (defaults to 'greatest' tag).") do |ref|
|
|
386
|
+
options.ref = ref
|
|
387
|
+
end
|
|
388
|
+
opts.on('-e', '--embed [sub-dir-name]', "App is sub-dir in existing project.") do |embed_as|
|
|
389
|
+
options.embed_as = embed_as
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
begin
|
|
394
|
+
parser.parse!
|
|
395
|
+
options.target_dir = ARGV.first
|
|
396
|
+
|
|
397
|
+
raise OptionParser::InvalidOption if options.target_dir.nil?
|
|
398
|
+
|
|
399
|
+
raygun = Raygun::Runner.new(options.target_dir, options.prototype_repo, options.gitlab_endpoint, options.ref, options.embed_as)
|
|
400
|
+
|
|
401
|
+
rescue OptionParser::InvalidOption
|
|
402
|
+
usage_and_exit(parser)
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
raygun
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
def self.usage_and_exit(parser)
|
|
409
|
+
puts parser
|
|
410
|
+
exit 1
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
end
|
data/marvin.jpg
ADDED
|
Binary file
|
data/raygun.gemspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
File.expand_path('../lib', __FILE__).tap do |lib|
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'raygun/version'
|
|
8
|
+
|
|
9
|
+
Gem::Specification.new do |gem|
|
|
10
|
+
gem.name = "raygun-gl"
|
|
11
|
+
gem.version = Raygun::VERSION
|
|
12
|
+
gem.authors = ["Christian Nelson", "Jonah Williams", "Jason Wadsworth", "Michael Johnston"]
|
|
13
|
+
gem.email = ["lastobelus@gmail.com"]
|
|
14
|
+
gem.description = %q{Rails application generator}
|
|
15
|
+
gem.summary = %q{Generates and customizes Rails applications from prototype repos which can live either on github or on private gitlab instances.}
|
|
16
|
+
gem.homepage = "https://github.com/lastobelus/raygun-gl"
|
|
17
|
+
gem.license = 'MIT'
|
|
18
|
+
|
|
19
|
+
gem.files = `git ls-files`.split($/)
|
|
20
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
21
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
22
|
+
gem.require_paths = ["lib"]
|
|
23
|
+
gem.add_dependency "gitlab", "~> 3"
|
|
24
|
+
gem.add_development_dependency "pry"
|
|
25
|
+
gem.add_development_dependency "awesome_print"
|
|
26
|
+
gem.add_development_dependency "rake"
|
|
27
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: raygun-gl
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.10.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Christian Nelson
|
|
8
|
+
- Jonah Williams
|
|
9
|
+
- Jason Wadsworth
|
|
10
|
+
- Michael Johnston
|
|
11
|
+
autorequire:
|
|
12
|
+
bindir: bin
|
|
13
|
+
cert_chain: []
|
|
14
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: gitlab
|
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
|
19
|
+
requirements:
|
|
20
|
+
- - "~>"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '3'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '3'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: pry
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '0'
|
|
37
|
+
type: :development
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
- !ruby/object:Gem::Dependency
|
|
45
|
+
name: awesome_print
|
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
type: :development
|
|
52
|
+
prerelease: false
|
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
54
|
+
requirements:
|
|
55
|
+
- - ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: '0'
|
|
58
|
+
- !ruby/object:Gem::Dependency
|
|
59
|
+
name: rake
|
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: '0'
|
|
65
|
+
type: :development
|
|
66
|
+
prerelease: false
|
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '0'
|
|
72
|
+
description: Rails application generator
|
|
73
|
+
email:
|
|
74
|
+
- lastobelus@gmail.com
|
|
75
|
+
executables:
|
|
76
|
+
- raygun
|
|
77
|
+
extensions: []
|
|
78
|
+
extra_rdoc_files: []
|
|
79
|
+
files:
|
|
80
|
+
- ".gitignore"
|
|
81
|
+
- ".ruby-gemset"
|
|
82
|
+
- ".ruby-version"
|
|
83
|
+
- CHANGES.md
|
|
84
|
+
- Gemfile
|
|
85
|
+
- LICENSE.txt
|
|
86
|
+
- NEXTSTEPS.taskpaper
|
|
87
|
+
- README.md
|
|
88
|
+
- Rakefile
|
|
89
|
+
- bin/raygun
|
|
90
|
+
- lib/colorize.rb
|
|
91
|
+
- lib/raygun/gitlab_client.rb
|
|
92
|
+
- lib/raygun/raygun.rb
|
|
93
|
+
- lib/raygun/version.rb
|
|
94
|
+
- marvin.jpg
|
|
95
|
+
- raygun.gemspec
|
|
96
|
+
homepage: https://github.com/lastobelus/raygun-gl
|
|
97
|
+
licenses:
|
|
98
|
+
- MIT
|
|
99
|
+
metadata: {}
|
|
100
|
+
post_install_message:
|
|
101
|
+
rdoc_options: []
|
|
102
|
+
require_paths:
|
|
103
|
+
- lib
|
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - ">="
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0'
|
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '0'
|
|
114
|
+
requirements: []
|
|
115
|
+
rubyforge_project:
|
|
116
|
+
rubygems_version: 2.2.2
|
|
117
|
+
signing_key:
|
|
118
|
+
specification_version: 4
|
|
119
|
+
summary: Generates and customizes Rails applications from prototype repos which can
|
|
120
|
+
live either on github or on private gitlab instances.
|
|
121
|
+
test_files: []
|