raygun 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53fef6c89e692472bd5d1bdca79c821116c57bcc
4
- data.tar.gz: 7f94124fd48ae4286dc162f25705c7f5a3dbeb26
3
+ metadata.gz: 065ecc2e84bd97c90297b39a7619a0a6ca2aeb3e
4
+ data.tar.gz: cb6eb42d11c58ffff33c9a46b4e786a77b16875b
5
5
  SHA512:
6
- metadata.gz: 1ebcc79eef641dfb5449169f6cbc04a0eccf13586b1907c79dc537fbeb922140331134a6b35702bf25f9f632c85d057394c3796e156cbbe1bdfd55d2649d8ae4
7
- data.tar.gz: 2ee3e7c2fc6944293daa3d6b3a24feebd31cdb1f58ff0ea3125acac6a6e44723913de5288ca7921c1f7ccc5d8997415b01dd08611e4fbdad16efdbb58f2b5576
6
+ metadata.gz: 37cf514bd395889660bb53a7c60e6f9c706e13609a762be7b1382228f09680021ef52423986e3d30e518116c7334c2a34327fa14743cc6147dc2995babf544ce
7
+ data.tar.gz: 6edf23596a25b0b12aa6cab27557dae283b03ca67a2038e61370b2a2b25c2c4cd71b73698b14dda5b1cda7e26a82d44571787e7d7c1c079868eb7cabfe345b70
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.4
1
+ 2.4.2
data/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ **Note:** Don't let the apparent lack of activity here scare you away. Almost all changes are captured in the
4
+ prototype repo (see [raygun-rails](https://github.com/carbonfive/raygun-rails)), and it's kept pretty well up to date.
5
+
6
+ ## 1.0.3 [2017-10-25]
7
+
8
+ * Add ability to pull template repository by branch name (#137, thanks @bunnymatic!).
9
+ * Updates to the README (mostly tweaks).
10
+ * Use Ruby 2.4.2 for development.
11
+
3
12
  ## 1.0.1 [2015-01-30]
4
13
 
5
14
  * Simplify instructions: use ./bin/setup instead of explicit commands.
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  Rails application generator that builds a new project skeleton configured with Carbon Five preferences and
7
7
  best practices baked right in. Spend less time configuring and more building cool features.
8
8
 
9
- Raygun generates Rails 4 projects by copying this [sample app](https://github.com/carbonfive/raygun-rails)
9
+ Raygun generates Rails projects by copying this [sample app](https://github.com/carbonfive/raygun-rails)
10
10
  and massaging it gently into shape.
11
11
 
12
12
  Alternatively, Raygun allows you to specify your own prototype instead of the default sample app. See below
@@ -20,10 +20,9 @@ Major tools/libraries:
20
20
  * Sass
21
21
  * Bootstrap
22
22
  * RSpec
23
- * Factory Girl
24
- * Jasmine
23
+ * Factory Bot
25
24
  * SimpleCov
26
- * Guard (rspec, jasmine, livereload)
25
+ * Guard (rspec, livereload)
27
26
  * And many tweaks, patterns and common recipes (see [raygun-rails](https://github.com/carbonfive/raygun-rails) for all the details).
28
27
 
29
28
  Raygun includes generator templates for controllers, views, and specs so that generated code follows best
@@ -47,21 +46,21 @@ Raygun...
47
46
 
48
47
  ## Prerequisites
49
48
 
50
- To generate an application, you only need the raygun gem and network connectivity.
49
+ To generate an application, you only need the Raygun gem and network connectivity.
51
50
 
52
51
  To run your new application's specs or fire up its server, you'll need to meet these requirements.
53
52
 
54
- * PostgreSQL 9.x with superuser 'postgres' with no password (```createuser -s postgres```)
55
- * PhantomJS for JavaScript testing (```brew install phantomjs```)
53
+ * PostgreSQL 9.x with superuser 'postgres' with no password (`createuser -s postgres`)
54
+ * PhantomJS for JavaScript testing (`brew install phantomjs`)
56
55
 
57
- The generated app will be configured to use the ruby version that was used to invoke raygun. If you're using
58
- another ruby, just change the ```Gemfile``` and ```.ruby-version``` as necessary.
56
+ The generated app will be configured to use the ruby version that was used to invoke Raygun. If you're using
57
+ another ruby, just change the `Gemfile` and `.ruby-version` as necessary.
59
58
 
60
59
  ## Usage
61
60
 
62
61
  $ raygun your-project
63
62
 
64
- Once your project is baked out, you can easily kick the wheels. Be sure that you have the prerequities
63
+ Once your project is baked out, you can easily kick the wheels. Be sure that you have the prerequisites
65
64
  covered (see above).
66
65
 
67
66
  $ cd your-project
@@ -77,27 +76,33 @@ covered (see above).
77
76
  ## Using a Custom Project Template
78
77
 
79
78
  The default is to use the project at [carbonfive/raygun-rails](https://github.com/carbonfive/raygun-rails) as a
80
- starting point. You can use another repo as the project template with the ```-p``` command line option.
79
+ starting point. You can use another repo as the project template with the `-p` command line option.
81
80
 
82
- If you invoke raygun with the ```-p``` option, you can specify your own github repository.
81
+ If you invoke raygun with the `-p` option, you can specify your own github repository.
83
82
 
84
83
  $ raygun -p githubid/repo your-project
85
84
 
85
+ Or
86
+
87
+ $ raygun -p githubid/repo your-project#new-branch-name
88
+
86
89
  The repository must:
87
90
 
88
- * Have been tagged. Raygun chooses the "greatest" tag and downloads the repository as of that tag.
89
- * Not have any binary files. Raygun runs a 'sed' command on all files, which will fail on binaries, such as jar files.
91
+ Not have any binary files. Raygun runs a 'sed' command on all files, which will fail on binaries, such as jar files.
92
+
93
+ If you are not planning to pull the prototype repository by branch, it must also have a tag. Raygun will choose the
94
+ "greatest" tag and downloads the repository as of that tag.
90
95
 
91
- If your project template requires a minimum version of raygun, include the version in a file called
92
- ```.raygun-version``` at the root. Raygun will make sure it's new enough for your repo.
96
+ If your project template requires a minimum version of Raygun, include the version in a file called
97
+ `.raygun-version` at the root. Raygun will make sure it's new enough for your repo.
93
98
 
94
99
  ## Internal Mechanics
95
100
 
96
101
  Raygun fetches the greatest tag from the [carbonfive/raygun-rails](https://github.com/carbonfive/raygun-rails)
97
- repo, unless it already has it cached in ~/.raygun, extracts the contents of the tarball, and runs a series of
102
+ repo, unless it already has it cached in `~/.raygun`, extracts the contents of the tarball, and runs a series of
98
103
  search-and-replaces on the code to customize it accordingly.
99
104
 
100
- This approach is fast, simple, and makes raygun developement very easy. Make changes to the application
105
+ This approach is fast, simple, and makes developmentn on Raygun very easy: make changes to the application
101
106
  prototype (which is a valid rails app) and tag them when they should be used for new applications.
102
107
 
103
108
  ## Contributing
@@ -110,7 +115,7 @@ prototype (which is a valid rails app) and tag them when they should be used for
110
115
 
111
116
  ### Development
112
117
 
113
- Generate an example app using your local development version of raygun:
118
+ Generate an example app using your local development version of Raygun:
114
119
 
115
120
  $ ./bin/raygun tmp/example_app
116
121
 
data/lib/raygun/raygun.rb CHANGED
@@ -7,6 +7,7 @@ require 'json'
7
7
  require 'colorize'
8
8
 
9
9
  require_relative 'version'
10
+ require_relative 'template_repo'
10
11
 
11
12
  module Raygun
12
13
  class Runner
@@ -45,15 +46,16 @@ module Raygun
45
46
  $stdout.flush
46
47
 
47
48
  # Check if we can connect, or fail gracefully and use the latest cached version.
48
- latest_tag_obj = fetch_latest_tag(prototype_repo)
49
- latest_tag = latest_tag_obj['name']
50
- tarball_url = latest_tag_obj['tarball_url']
49
+ repo = TemplateRepo.new(prototype_repo)
50
+ name = repo.name
51
+ tarball_url = repo.tarball
52
+ sha = repo.sha
51
53
 
52
- print " #{latest_tag}.".colorize(:white)
54
+ print " #{name}.".colorize(:white)
53
55
  $stdout.flush
54
56
 
55
57
  cached_prototypes_dir = File.join(Dir.home, ".raygun")
56
- @prototype = "#{cached_prototypes_dir}/#{prototype_repo.sub('/', '--')}-#{latest_tag}.tar.gz"
58
+ @prototype = "#{cached_prototypes_dir}/#{name.gsub('/','--')}-#{sha}.tar.gz"
57
59
 
58
60
  # Do we already have the tarball cached under ~/.raygun?
59
61
  if File.exists?(@prototype)
@@ -64,7 +66,6 @@ module Raygun
64
66
 
65
67
  # Download the tarball and install in the cache.
66
68
  Dir.mkdir(cached_prototypes_dir, 0755) unless Dir.exists?(cached_prototypes_dir)
67
-
68
69
  shell "curl -s -L #{tarball_url} -o #{@prototype}"
69
70
  puts " done!".colorize(:yellow)
70
71
  end
@@ -176,7 +177,7 @@ module Raygun
176
177
  print_next_steps_for_custom_repo
177
178
  end
178
179
  end
179
-
180
+
180
181
  def print_next_steps_carbon_five
181
182
  puts ""
182
183
  puts "Zap! Your application is ready. Next steps...".colorize(:yellow)
@@ -194,7 +195,7 @@ module Raygun
194
195
  puts ""
195
196
  puts "Enjoy your Carbon Five flavored Rails application!".colorize(:yellow)
196
197
  end
197
-
198
+
198
199
  def print_next_steps_for_custom_repo
199
200
  puts ""
200
201
  puts "Zap! Your application is ready.".colorize(:yellow)
@@ -204,51 +205,6 @@ module Raygun
204
205
 
205
206
  protected
206
207
 
207
- # Fetch the tags for the repo (e.g. 'carbonfive/raygun-rails') and return the latest as JSON.
208
- def fetch_latest_tag(repo)
209
- url = "https://api.github.com/repos/#{repo}/tags"
210
- uri = URI.parse(url)
211
- http = Net::HTTP.new(uri.host, uri.port)
212
- http.use_ssl = true
213
- request = Net::HTTP::Get.new(URI.encode(url))
214
-
215
- response = http.request(request)
216
-
217
- unless response.code == "200"
218
- puts ""
219
- print "Whoops - need to try again!".colorize(:red)
220
- puts ""
221
- print "We could not find (".colorize(:light_red)
222
- print "#{repo}".colorize(:white)
223
- print ") on github.".colorize(:light_red)
224
- puts ""
225
- print "The response from github was a (".colorize(:light_red)
226
- print "#{response.code}".colorize(:white)
227
- puts ") which I'm sure you can fix right up!".colorize(:light_red)
228
- puts ""
229
- exit 1
230
- end
231
-
232
- result = JSON.parse(response.body).first
233
- unless result
234
- puts ""
235
- print "Whoops - need to try again!".colorize(:red)
236
- puts ""
237
- print "We could not find any tags in the repo (".colorize(:light_red)
238
- print "#{repo}".colorize(:white)
239
- print ") on github.".colorize(:light_red)
240
- puts ""
241
- print "Raygun uses the 'largest' tag in a repository, where tags are sorted alphanumerically.".colorize(:light_red)
242
- puts ""
243
- print "E.g., tag 'v.0.10.0' > 'v.0.9.9' and 'x' > 'a'.".colorize(:light_red)
244
- print ""
245
- puts ""
246
- exit 1
247
- end
248
-
249
- result
250
- end
251
-
252
208
  def camelize(string)
253
209
  result = string.sub(/^[a-z\d]*/) { $&.capitalize }
254
210
  result.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }
@@ -0,0 +1,76 @@
1
+ module Raygun
2
+ class TemplateRepo
3
+ attr_reader :name, :branch, :tarball, :sha
4
+
5
+ def initialize(repo)
6
+ @name, @branch = repo.split('#').map(&:strip)
7
+ fetch
8
+ end
9
+
10
+ private
11
+
12
+ def fetch
13
+ return if @branch && @sha
14
+ @branch ? fetch_branches : fetch_tags
15
+ end
16
+
17
+ def handle_github_error(response)
18
+ puts ""
19
+ print "Whoops - need to try again!".colorize(:red)
20
+ puts ""
21
+ print "We could not find (".colorize(:light_red)
22
+ print "#{name}".colorize(:white)
23
+ print "##{branch}".colorize(:white) if @branch
24
+ print ") on github.".colorize(:light_red)
25
+ puts ""
26
+ print "The response from github was a (".colorize(:light_red)
27
+ print "#{response.code}".colorize(:white)
28
+ puts ") which I'm sure you can fix right up!".colorize(:light_red)
29
+ puts ""
30
+ exit 1
31
+ end
32
+
33
+ def handle_missing_tag_error
34
+ puts ""
35
+ print "Whoops - need to try again!".colorize(:red)
36
+ puts ""
37
+ print "We could not find any tags in the repo (".colorize(:light_red)
38
+ print "#{name}".colorize(:white)
39
+ print ") on github.".colorize(:light_red)
40
+ puts ""
41
+ print "Raygun uses the 'largest' tag in a repository, where tags are sorted alphanumerically.".colorize(:light_red)
42
+ puts ""
43
+ print "E.g., tag 'v.0.10.0' > 'v.0.9.9' and 'x' > 'a'.".colorize(:light_red)
44
+ print ""
45
+ puts ""
46
+ exit 1
47
+ end
48
+
49
+ def fetch_branches
50
+ response = http_get("https://api.github.com/repos/#{name}/branches/#{branch}")
51
+ handle_github_error(response) unless response.code == "200"
52
+ result = JSON.parse(response.body)
53
+ @sha = result['commit']['sha']
54
+ @tarball = result['_links']['html'].gsub(%r(/tree/#{branch}), "/archive/#{branch}.tar.gz")
55
+ end
56
+
57
+ def fetch_tags
58
+ response = http_get("https://api.github.com/repos/#{name}/tags")
59
+ handle_github_error(response) unless response.code == "200"
60
+
61
+ result = JSON.parse(response.body).first
62
+ handle_missing_tag_error unless result
63
+ @sha = result['commit']['sha']
64
+ @tarball = result['tarball_url']
65
+ end
66
+
67
+ def http_get(url)
68
+ uri = URI.parse(url)
69
+ http = Net::HTTP.new(uri.host, uri.port)
70
+ http.use_ssl = true
71
+ request = Net::HTTP::Get.new(URI.encode(url))
72
+
73
+ response = http.request(request)
74
+ end
75
+ end
76
+ end
@@ -1,3 +1,3 @@
1
1
  module Raygun
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
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: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Nelson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-31 00:00:00.000000000 Z
13
+ date: 2017-10-25 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Carbon Five Rails application generator
16
16
  email:
@@ -31,6 +31,7 @@ files:
31
31
  - bin/raygun
32
32
  - lib/colorize.rb
33
33
  - lib/raygun/raygun.rb
34
+ - lib/raygun/template_repo.rb
34
35
  - lib/raygun/version.rb
35
36
  - marvin.jpg
36
37
  - raygun.gemspec
@@ -54,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
55
  version: '0'
55
56
  requirements: []
56
57
  rubyforge_project:
57
- rubygems_version: 2.4.5.1
58
+ rubygems_version: 2.6.13
58
59
  signing_key:
59
60
  specification_version: 4
60
61
  summary: Generates and customizes Rails applications with Carbon Five best practices