forked from lostisland/faraday
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lostisland#224 from technoweenie/fix-ci
Fix CI
- Loading branch information
Showing
13 changed files
with
197 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
#!/usr/bin/env ruby | |||
# Usage: script/console | |||
# Starts an IRB console with this library loaded. | |||
|
|||
require 'rubygems' | |||
require 'irb' | |||
require File.expand_path("../ruby", __FILE__) | |||
require File.expand_path("../../lib/#{MakeScript.lib_name}", __FILE__) | |||
IRB.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
#!/usr/bin/env ruby | |||
# Usage: script/gemspec | |||
# Updates the gemspec's name, version, and file manifest. | |||
|
|||
require File.expand_path("../ruby", __FILE__) | |||
|
|||
def replace_header(head, header_name) | |||
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{MakeScript.send(header_name)}'"} | |||
end | |||
|
|||
# read spec file and split out manifest section | |||
spec = File.read(MakeScript.gemspec_file) | |||
head, manifest, tail = spec.split(" # = MANIFEST =\n") | |||
|
|||
# replace name version and date | |||
replace_header(head, :lib_name) | |||
replace_header(head, :version) | |||
|
|||
files = `git ls-files`. | |||
split("\n"). | |||
sort. | |||
reject { |file| file =~ /^\./ }. | |||
reject { |file| file =~ /^(rdoc|pkg)/ }. | |||
map { |file| " #{file}" }. | |||
join("\n") | |||
|
|||
# piece file back together and write | |||
manifest = " s.files = %w[\n#{files}\n ]\n" | |||
spec = [head, manifest, tail].join(" # = MANIFEST =\n") | |||
File.open(MakeScript.gemspec_file, 'w') { |io| io.write(spec) } | |||
puts "Updated #{MakeScript.gemspec_file}" | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
#!/usr/bin/env ruby | |||
# Usage: generate_certs | |||
# Generate test certs for testing Faraday with SSL | |||
|
|||
require File.expand_path("../ruby", __FILE__) | |||
require 'openssl' | |||
require 'fileutils' | |||
|
|||
# Adapted from WEBrick::Utils. Skips cert extensions so it | |||
# can be used as a CA bundle | |||
def create_self_signed_cert(bits, cn, comment) | |||
rsa = OpenSSL::PKey::RSA.new(bits) | |||
cert = OpenSSL::X509::Certificate.new | |||
cert.version = 2 | |||
cert.serial = 1 | |||
name = OpenSSL::X509::Name.new(cn) | |||
cert.subject = name | |||
cert.issuer = name | |||
cert.not_before = Time.now | |||
cert.not_after = Time.now + (365*24*60*60) | |||
cert.public_key = rsa.public_key | |||
cert.sign(rsa, OpenSSL::Digest::SHA1.new) | |||
return [cert, rsa] | |||
end | |||
|
|||
cert, key = create_self_signed_cert(1024, [['CN', 'localhost']], 'Faraday Test CA') | |||
FileUtils.mkdir_p 'tmp' | |||
File.open('tmp/faraday-cert.key', 'w') {|f| f.puts(key) } | |||
File.open('tmp/faraday-cert.crt', 'w') {|f| f.puts(cert.to_s) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
#!/usr/bin/env ruby | |||
# Usage: script/gem | |||
# Updates the gemspec and builds a new gem in the pkg directory. | |||
|
|||
require File.expand_path("../ruby", __FILE__) | |||
require 'fileutils' | |||
|
|||
FileUtils.mkdir_p File.expand_path("../../pkg", __FILE__) | |||
system "script/gemspec" | |||
system "gem build #{MakeScript.gemspec_file}" | |||
system "mv #{MakeScript.gem_file} pkg" | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
#!/usr/bin/env ruby | |||
# Usage: script/release | |||
# Build the package, tag a commit, push it to origin, and then release the | |||
# package publicly. | |||
|
|||
require File.expand_path("../ruby", __FILE__) | |||
|
|||
system "script/package" | |||
system "git commit --allow-empty -a -m 'Release #{MakeScript.version}'" | |||
system "git tag v#{MakeScript.version}" | |||
system "git push origin" | |||
system "git push origin v#{MakeScript.version}" | |||
system "gem push pkg/#{MakeScript.gem_file}" | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,36 @@ | |||
# Opinionated module that picks out a ruby library's name and version based on | |||
# some conventions: | |||
# | |||
# * #{lib_name}.gemspec | |||
# * A VERSION constant defined in lib/#{lib_name}.rb | |||
# | |||
# Example: | |||
# | |||
# # foo.gemspec | |||
# # lib/foo.rb | |||
# module Foo | |||
# VERSION = "0.1" | |||
# end | |||
|
|||
module MakeScript | |||
extend self | |||
|
|||
def lib_name | |||
@lib_name ||= Dir['*.gemspec'].first.split('.').first | |||
end | |||
|
|||
def version | |||
@version ||= begin | |||
line = File.read("lib/#{lib_name}.rb")[/^\s*VERSION\s*=\s*.*/] | |||
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] | |||
end | |||
end | |||
|
|||
def gemspec_file | |||
@gemspec_file ||= "#{lib_name}.gemspec" | |||
end | |||
|
|||
def gem_file | |||
@gem_file ||= "#{lib_name}-#{version}.gem" | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters