raygun 1.0.1 → 1.1.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.
@@ -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.1"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -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,27 @@
1
+ require_relative "../spec_helper"
2
+ require_relative "../../lib/raygun/raygun"
3
+
4
+ describe Raygun::Runner do
5
+ describe "#fetch_rubocop_file" do
6
+ context "the repo is the standard carbonfive raygun-rails repo" do
7
+ before do
8
+ @runner = described_class.new("target/dir", "carbonfive/raygun-rails")
9
+ allow(URI).to receive(:open).and_return(StringIO.new("# rubocop contents"))
10
+ allow(IO).to receive(:write)
11
+ allow(@runner).to receive(:shell).and_return("GitSHAgoeshere")
12
+ end
13
+ it "inserts a copy of the rubocop file pulled from the carbonfive/c5-conventions repo" do
14
+ @runner.send(:fetch_rubocop_file)
15
+ expect(@runner).to have_received(:shell)
16
+ .with("git ls-remote https://github.com/carbonfive/c5-conventions master")
17
+ expect(URI).to have_received(:open)
18
+ .with("https://raw.githubusercontent.com/carbonfive/c5-conventions/master/rubocop/rubocop.yml")
19
+ expect(IO).to have_received(:write) do |path, contents|
20
+ expect(path).to eq(File.absolute_path("target/dir/.rubocop.yml"))
21
+ expect(contents).to include("@ GitSHA")
22
+ expect(contents).to include("# rubocop contents")
23
+ end
24
+ end
25
+ end
26
+ end
27
+ 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.1
4
+ version: 1.1.1
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-01-30 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2021-01-12 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,20 @@ files:
29
88
  - README.md
30
89
  - Rakefile
31
90
  - bin/raygun
91
+ - bin/setup
32
92
  - lib/colorize.rb
33
93
  - lib/raygun/raygun.rb
94
+ - lib/raygun/template_repo.rb
34
95
  - lib/raygun/version.rb
35
96
  - marvin.jpg
36
97
  - raygun.gemspec
98
+ - spec/raygun/runner_spec.rb
99
+ - spec/spec_helper.rb
37
100
  homepage: https://github.com/carbonfive/raygun
38
101
  licenses:
39
102
  - MIT
40
103
  metadata: {}
41
- post_install_message:
104
+ post_install_message:
42
105
  rdoc_options: []
43
106
  require_paths:
44
107
  - lib
@@ -46,17 +109,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
109
  requirements:
47
110
  - - ">="
48
111
  - !ruby/object:Gem::Version
49
- version: '0'
112
+ version: '2.5'
50
113
  required_rubygems_version: !ruby/object:Gem::Requirement
51
114
  requirements:
52
115
  - - ">="
53
116
  - !ruby/object:Gem::Version
54
117
  version: '0'
55
118
  requirements: []
56
- rubyforge_project:
57
- rubygems_version: 2.4.5
58
- signing_key:
119
+ rubygems_version: 3.1.4
120
+ signing_key:
59
121
  specification_version: 4
60
122
  summary: Generates and customizes Rails applications with Carbon Five best practices
61
123
  baked in.
62
- test_files: []
124
+ test_files:
125
+ - spec/raygun/runner_spec.rb
126
+ - spec/spec_helper.rb