Skip to content

Instantly share code, notes, and snippets.

View chrisarcand's full-sized avatar
🏒

Chris Arcand chrisarcand

🏒
View GitHub Profile
@chrisarcand
chrisarcand / UsingGitInYourGemspec_example3.rb
Created February 13, 2014 22:55
Using Git in Your Gemspec, example 3
# Part of Vagrant's gemspec
# The following block of code determines the files that should be included
# in the gem. It does this by reading all the files in the directory where
# this gemspec is, and parsing out the ignored files from the gitignore.
# Note that the entire gitignore(5) syntax is not supported, specifically
# the "!" syntax, but it should mostly work correctly.
root_path = File.dirname(__FILE__)
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
@chrisarcand
chrisarcand / UsingGitInYourGemspec_example2.rb
Created February 13, 2014 22:54
Using Git in Your Gemspec, example 2
# Part of Bundler's gemspec
spec.files = `git ls-files -z`.split("\x0")
spec.files += Dir.glob('lib/bundler/man/**/*') # man/ is ignored by git
@chrisarcand
chrisarcand / UsingGitInYourGemspec_example1.rb
Last active August 29, 2015 13:56
Using Git in Your Gemspec
# A generated gemspec file using Bundler
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'test/version'
Gem::Specification.new do |spec|
spec.name = "test"
spec.version = Test::VERSION