Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve scripts: done in shell, simpler, no gemspec gen

  • Loading branch information...
commit 86c43e5b835aaec3e1ce75ad87b2caf5a18caf77 1 parent 26e9869
Mislav Marohnić mislav authored
15 faraday.gemspec
View
@@ -1,12 +1,15 @@
+lib_file = File.expand_path('../lib/faraday.rb', __FILE__)
+File.read(lib_file) =~ /\bVERSION\s*=\s*["'](.+?)["']/
+version = $1
+
Gem::Specification.new do |spec|
spec.specification_version = 2 if spec.respond_to? :specification_version=
spec.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if spec.respond_to? :required_rubygems_version=
spec.name = 'faraday'
- spec.version = '0.9.0.pre'
+ spec.version = version
- spec.summary = "HTTP/REST API client library."
- # TODO: spec.description
+ spec.summary = "HTTP/REST API client library."
spec.authors = ["Rick Olson"]
spec.email = 'technoweenie@gmail.com'
@@ -17,9 +20,11 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake'
spec.add_development_dependency 'simplecov'
- # = MANIFEST =
spec.files = %w(Gemfile LICENSE.md README.md Rakefile faraday.gemspec script/test)
spec.files += Dir.glob("lib/**/*.rb")
spec.files += Dir.glob("test/**/*.rb")
- spec.test_files = Dir.glob("test/**/*.rb")
+
+ dev_null = File.exist?('/dev/null') ? '/dev/null' : 'NUL'
+ git_files = `git ls-files -z 2>#{dev_null}`
+ spec.files &= git_files.split("\0") if $?.success?
end
10 script/console
View
@@ -1,9 +1,7 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env bash
# 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
+gemspec="$(ls *.gemspec | head -1)"
+
+exec bundle exec irb -r "${gemspec%.*}"
32 script/gemspec
View
@@ -1,32 +0,0 @@
-#!/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}"
-
1  script/generate_certs
View
@@ -2,7 +2,6 @@
# Usage: generate_certs
# Generate test certs for testing Faraday with SSL
-require File.expand_path("../ruby", __FILE__)
require 'openssl'
require 'fileutils'
13 script/package
View
@@ -1,12 +1,7 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env bash
# 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"
-
+mkdir -p pkg
+gem build *.gemspec
+mv *.gem pkg
17 script/release
View
@@ -1,14 +1,15 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env bash
# 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__)
+set -e
-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}"
+version="$(script/package | grep Version: | awk '{print $2}')"
+[ -n "$version" ] || exit 1
+git commit --allow-empty -a -m "Release $version"
+git tag "v$version"
+git push origin
+git push origin "v$version"
+gem push pkg/*-${version}.gem
36 script/ruby.rb
View
@@ -1,36 +0,0 @@
-# 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
Please sign in to comment.
Something went wrong with that request. Please try again.