raygun 1.0.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,78 @@
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
+
15
+ @branch ? fetch_branches : fetch_tags
16
+ end
17
+
18
+ def handle_github_error(response)
19
+ puts ""
20
+ print "Whoops - need to try again!".colorize(:red)
21
+ puts ""
22
+ print "We could not find (".colorize(:light_red)
23
+ print name.to_s.colorize(:white)
24
+ print "##{branch}".colorize(:white) if @branch
25
+ print ") on github.".colorize(:light_red)
26
+ puts ""
27
+ print "The response from github was a (".colorize(:light_red)
28
+ print response.code.to_s.colorize(:white)
29
+ puts ") which I'm sure you can fix right up!".colorize(:light_red)
30
+ puts ""
31
+ exit 1
32
+ end
33
+
34
+ def handle_missing_tag_error
35
+ puts ""
36
+ print "Whoops - need to try again!".colorize(:red)
37
+ puts ""
38
+ print "We could not find any tags in the repo (".colorize(:light_red)
39
+ print name.to_s.colorize(:white)
40
+ print ") on github.".colorize(:light_red)
41
+ puts ""
42
+ print "Raygun uses the 'largest' tag in a repository, " \
43
+ "where tags are sorted alphanumerically.".colorize(:light_red)
44
+ puts ""
45
+ print "E.g., tag 'v.0.10.0' > 'v.0.9.9' and 'x' > 'a'.".colorize(:light_red)
46
+ print ""
47
+ puts ""
48
+ exit 1
49
+ end
50
+
51
+ def fetch_branches
52
+ response = http_get("https://api.github.com/repos/#{name}/branches/#{branch}")
53
+ handle_github_error(response) unless response.code == "200"
54
+ result = JSON.parse(response.body)
55
+ @sha = result["commit"]["sha"]
56
+ @tarball = result["_links"]["html"].gsub(%r{/tree/#{branch}}, "/archive/#{branch}.tar.gz")
57
+ end
58
+
59
+ def fetch_tags
60
+ response = http_get("https://api.github.com/repos/#{name}/tags")
61
+ handle_github_error(response) unless response.code == "200"
62
+
63
+ result = JSON.parse(response.body).first
64
+ handle_missing_tag_error unless result
65
+ @sha = result["commit"]["sha"]
66
+ @tarball = result["tarball_url"]
67
+ end
68
+
69
+ def http_get(url)
70
+ uri = URI(url)
71
+ http = Net::HTTP.new(uri.host, uri.port)
72
+ http.use_ssl = true
73
+ request = Net::HTTP::Get.new(uri)
74
+
75
+ http.request(request)
76
+ end
77
+ end
78
+ end
@@ -1,3 +1,3 @@
1
1
  module Raygun
2
- VERSION = "1.0.2"
2
+ VERSION = "1.2.0"
3
3
  end
data/raygun.gemspec CHANGED
@@ -1,23 +1,28 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- File.expand_path('../lib', __FILE__).tap do |lib|
1
+ File.expand_path("lib", __dir__).tap do |lib|
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  end
6
4
 
7
- require 'raygun/version'
5
+ require "raygun/version"
8
6
 
9
7
  Gem::Specification.new do |gem|
10
8
  gem.name = "raygun"
11
9
  gem.version = Raygun::VERSION
12
10
  gem.authors = ["Christian Nelson", "Jonah Williams", "Jason Wadsworth"]
13
11
  gem.email = ["christian@carbonfive.com"]
14
- gem.description = %q{Carbon Five Rails application generator}
15
- gem.summary = %q{Generates and customizes Rails applications with Carbon Five best practices baked in.}
12
+ gem.description = "Carbon Five Rails application generator"
13
+ gem.summary = "Generates and customizes Rails applications with Carbon Five best practices baked in."
16
14
  gem.homepage = "https://github.com/carbonfive/raygun"
17
- gem.license = 'MIT'
15
+ gem.license = "MIT"
18
16
 
19
- gem.files = `git ls-files`.split($/)
17
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
20
18
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
21
19
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
20
  gem.require_paths = ["lib"]
21
+
22
+ gem.required_ruby_version = ">= 2.5"
23
+
24
+ gem.add_development_dependency "bundler", "~> 2.0"
25
+ gem.add_development_dependency "rake", "~> 13.0"
26
+ gem.add_development_dependency "rspec", "~> 3.9"
27
+ gem.add_development_dependency "rubocop", "0.79.0"
23
28
  end
@@ -0,0 +1,41 @@
1
+ require_relative "../spec_helper"
2
+ require_relative "../../lib/raygun/c5_conventions"
3
+
4
+ require "tmpdir"
5
+
6
+ describe Raygun::C5Conventions do
7
+ subject(:install) { described_class.install(target: target, sources: sources) }
8
+
9
+ let(:target) { Dir.mktmpdir }
10
+ let(:sources) { described_class::SOURCES }
11
+
12
+ describe ".install" do
13
+ it "puts rubocop files into the target directory" do
14
+ install
15
+
16
+ paths = %w[
17
+ .rubocop.yml
18
+ .rubocop-common.yml
19
+ .rubocop-performance.yml
20
+ .rubocop-rails.yml
21
+ .rubocop-rspec.yml
22
+ ].map { |path| Pathname.new(File.join(target, path)) }
23
+
24
+ expect(paths).to all(be_file)
25
+ end
26
+
27
+ it "inserts an attribution header" do
28
+ install
29
+ rubocop_config = IO.read(File.join(target, ".rubocop.yml"))
30
+ expect(rubocop_config).to match(%r{^# Sourced from carbonfive/c5-conventions @ \h{7}$})
31
+ end
32
+ end
33
+
34
+ context "when a source doesn't exist" do
35
+ let(:sources) { ["https://raw.githubusercontent.com/carbonfive/c5-conventions/main/rubocop/.rubocop-whatever.yml"] }
36
+
37
+ it "prints a warning to stdout" do
38
+ expect { install }.to output(/Failed to install/).to_stdout
39
+ end
40
+ end
41
+ end
@@ -0,0 +1 @@
1
+ require "rspec"
metadata CHANGED
@@ -1,26 +1,85 @@
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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Nelson
8
8
  - Jonah Williams
9
9
  - Jason Wadsworth
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-31 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2021-05-21 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '13.0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '13.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rspec
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.9'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '3.9'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rubocop
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '='
62
+ - !ruby/object:Gem::Version
63
+ version: 0.79.0
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '='
69
+ - !ruby/object:Gem::Version
70
+ version: 0.79.0
15
71
  description: Carbon Five Rails application generator
16
72
  email:
17
73
  - christian@carbonfive.com
18
74
  executables:
19
75
  - raygun
76
+ - setup
20
77
  extensions: []
21
78
  extra_rdoc_files: []
22
79
  files:
80
+ - ".circleci/config.yml"
23
81
  - ".gitignore"
82
+ - ".rubocop.yml"
24
83
  - ".ruby-gemset"
25
84
  - ".ruby-version"
26
85
  - CHANGES.md
@@ -29,16 +88,21 @@ files:
29
88
  - README.md
30
89
  - Rakefile
31
90
  - bin/raygun
91
+ - bin/setup
32
92
  - lib/colorize.rb
93
+ - lib/raygun/c5_conventions.rb
33
94
  - lib/raygun/raygun.rb
95
+ - lib/raygun/template_repo.rb
34
96
  - lib/raygun/version.rb
35
97
  - marvin.jpg
36
98
  - raygun.gemspec
99
+ - spec/raygun/c5_conventions_spec.rb
100
+ - spec/spec_helper.rb
37
101
  homepage: https://github.com/carbonfive/raygun
38
102
  licenses:
39
103
  - MIT
40
104
  metadata: {}
41
- post_install_message:
105
+ post_install_message:
42
106
  rdoc_options: []
43
107
  require_paths:
44
108
  - lib
@@ -46,17 +110,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
110
  requirements:
47
111
  - - ">="
48
112
  - !ruby/object:Gem::Version
49
- version: '0'
113
+ version: '2.5'
50
114
  required_rubygems_version: !ruby/object:Gem::Requirement
51
115
  requirements:
52
116
  - - ">="
53
117
  - !ruby/object:Gem::Version
54
118
  version: '0'
55
119
  requirements: []
56
- rubyforge_project:
57
- rubygems_version: 2.4.5.1
58
- signing_key:
120
+ rubygems_version: 3.2.2
121
+ signing_key:
59
122
  specification_version: 4
60
123
  summary: Generates and customizes Rails applications with Carbon Five best practices
61
124
  baked in.
62
- test_files: []
125
+ test_files:
126
+ - spec/raygun/c5_conventions_spec.rb
127
+ - spec/spec_helper.rb