Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial version
  • Loading branch information
evanphx committed Jun 1, 2011
0 parents commit d4e3d91
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .autotest
@@ -0,0 +1,23 @@
# -*- ruby -*-

require 'autotest/restart'

# Autotest.add_hook :initialize do |at|
# at.extra_files << "../some/external/dependency.rb"
#
# at.libs << ":../some/external"
#
# at.add_exception 'vendor'
#
# at.add_mapping(/dependency.rb/) do |f, _|
# at.files_matching(/test_.*rb$/)
# end
#
# %w(TestA TestB).each do |klass|
# at.extra_class_map[klass] = "test/test_misc.rb"
# end
# end

# Autotest.add_hook :run_command do |at|
# system "rake build"
# end
6 changes: 6 additions & 0 deletions History.txt
@@ -0,0 +1,6 @@
=== 1.0.0 / 2011-06-01

* 1 major enhancement

* Birthday!

7 changes: 7 additions & 0 deletions Manifest.txt
@@ -0,0 +1,7 @@
.autotest
History.txt
Manifest.txt
README.txt
Rakefile
lib/rubygems_fp.rb
test/test_rubygems_fp.rb
60 changes: 60 additions & 0 deletions README.txt
@@ -0,0 +1,60 @@
= rubygems_fp

* RubyGems Temporal/Version proof utilities

== DESCRIPTION:

Provide a set of APIs that work across all versions of rubygems,
no matter the version.

== FEATURES/PROBLEMS:

* Backport new APIs for availability on older Rubygems releases

== SYNOPSIS:

require 'rubygems_fp'

<use it>

== REQUIREMENTS:

* RubyGems

== INSTALL:

* gem install rubygems_fp

== DEVELOPERS:

After checking out the source, run:

$ rake newb

This task will install any missing dependencies, run the tests/specs,
and generate the RDoc.

== LICENSE:

(The MIT License)

Copyright (c) 2011 Evan Phoenix <evan@fallingsnow.net>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 changes: 27 additions & 0 deletions Rakefile
@@ -0,0 +1,27 @@
# -*- ruby -*-

require 'rubygems'
require 'hoe'

# Hoe.plugin :compiler
# Hoe.plugin :email
# Hoe.plugin :gem_prelude_sucks
# Hoe.plugin :git
# Hoe.plugin :inline
# Hoe.plugin :minitest
# Hoe.plugin :perforce
# Hoe.plugin :racc
# Hoe.plugin :rubyforge
# Hoe.plugin :seattlerb

Hoe.spec 'rubygems_fp' do
# HEY! If you fill these out in ~/.hoe_template/Rakefile.erb then
# you'll never have to touch them again!
# (delete this comment too, of course)

# developer('FIX', 'FIX@example.com')

# self.rubyforge_name = 'rubygems_fpx' # if different than 'rubygems_fp'
end

# vim: syntax=ruby
21 changes: 21 additions & 0 deletions lib/rubygems_fp.rb
@@ -0,0 +1,21 @@
class RubyGemsFP
VERSION = '1.0.0'

class Specification
def initialize(spec)
@spec = spec
end

def gem_dir
if @spec.respond_to? :gem_dir
@spec.gem_dir
else
@spec.full_gem_path
end
end

def file_exists?(path)
File.exists? File.join(gem_dir, path)
end
end
end
85 changes: 85 additions & 0 deletions test/test_rubygems_fp.rb
@@ -0,0 +1,85 @@
require "test/unit"
require "rubygems_fp"
require "yaml"
require "pathname"
require "fileutils"
require "rubygems"

STDERR.puts "===== Testing against RubyGems: #{Gem::VERSION}"

class TestRubyGemsFPSpecification < Test::Unit::TestCase

def setup
tmpdir = File.expand_path("tmp/test")

if ENV['KEEP_FILES'] then
@tempdir = File.join(tmpdir, "test_rubygems_#{$$}.#{Time.now.to_i}")
else
@tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
end

@tempdir.untaint
@gemhome = File.join @tempdir, 'gemhome'
@userhome = File.join @tempdir, 'userhome'

FileUtils.mkdir_p @gemhome
FileUtils.mkdir_p @userhome

Gem.use_paths @gemhome
end

def teardown
FileUtils.rm_rf @tempdir unless ENV['KEEP_FILES']
end

def write_file(path)
path = File.join @gemhome, path unless Pathname.new(path).absolute?
dir = File.dirname path
FileUtils.mkdir_p dir

open path, 'wb' do |io|
yield io if block_given?
end

path
end

def spec_path(spec)
File.join @gemhome, "specifications", "#{spec.name}-#{spec.version}.gemspec"
end

def quick_gem(name, version='2')
require 'rubygems/specification'

spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = name
s.version = version
s.author = 'A User'
s.email = 'example@example.com'
s.homepage = 'http://example.com'
s.summary = "this is a summary"
s.description = "This is a test description"

yield(s) if block_given?
end

written_path = write_file spec_path(spec) do |io|
io.write spec.to_ruby
end

spec.loaded_from = spec.loaded_from = written_path

return spec
end

def test_sanity
a = quick_gem "a", "2"

s = RubyGemsFP::Specification.new(a)

expected = File.join @gemhome, "gems", "a-2"

assert_equal expected, s.gem_dir
end
end

0 comments on commit d4e3d91

Please sign in to comment.