Browse files

Initial Symbol#to_path/#to_str extension

  • Loading branch information...
1 parent 01118d3 commit ce6576d60e2d9c28d90dfab67d66221c445113d8 @bitherder committed Oct 29, 2011
View
4 .gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
View
1 .rvmrc
@@ -0,0 +1 @@
+rvm '1.9.2@celebration'
View
4 Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in celebration.gemspec
+gemspec
View
1 README.md
@@ -0,0 +1 @@
+# Larry E. Baltz's (LEB's) personal collection of Ruby code
View
17 Rakefile
@@ -0,0 +1,17 @@
+require "bundler/gem_tasks"
+require 'rspec/core/rake_task'
+
+task :default => :spec
+task :spec => ['spec:1.8', 'spec:1.9']
+
+namespace :spec do
+ task '1.8' do
+ sh "/bin/bash -c 'rvm 1.8.7@celebration rake spec:just_run'"
+ end
+
+ task '1.9' do
+ sh "/bin/bash -c 'rvm 1.9.2@celebration rake spec:just_run'"
+ end
+
+ RSpec::Core::RakeTask.new(:just_run)
+end
View
26 celebration.gemspec
@@ -0,0 +1,26 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path('../lib', __FILE__)
+require 'celebration/version'
+
+Gem::Specification.new do |s|
+ s.name = 'celebration'
+ s.version = Celebration::VERSION
+ s.authors = ['Larry Baltz']
+ s.email = ['larry@baltz.org']
+ s.homepage = ''
+ s.summary = %q{Larry E. Baltz's (LEB's) personal collection of Ruby code}
+ # s.description = %q{TODO: Write a gem description}
+
+ s.rubyforge_project = 'celebration'
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ['lib']
+
+ # specify any dependencies here; for example:
+ s.add_development_dependency 'rspec'
+ s.add_development_dependency 'rr'
+ s.add_runtime_dependency 'facets'
+ s.add_runtime_dependency 'backports'
+end
View
5 lib/celebration.rb
@@ -0,0 +1,5 @@
+require "celebration/version"
+
+module Celebration
+ # Your code goes here...
+end
View
1 lib/celebration/corext/pathname.rb
@@ -0,0 +1 @@
+require 'pathname'
View
4 lib/celebration/corext/symbol.rb
@@ -0,0 +1,4 @@
+class Symbol
+ alias to_path to_s
+ alias_method :to_str, :to_s if RUBY_VERSION =~ /1\.8/
+end
View
3 lib/celebration/version.rb
@@ -0,0 +1,3 @@
+module Celebration
+ VERSION = "0.0.1"
+end
View
6 spec/pathname_spec.rb
@@ -0,0 +1,6 @@
+require 'backports'
+require_relative 'spec_helper'
+
+describe Pathname do
+
+end
View
6 spec/spec_helper.rb
@@ -0,0 +1,6 @@
+require 'backports'
+require_relative '../lib/celebration/corext/pathname'
+
+RSpec.configure do |c|
+ c.mock_with :rr
+end
View
24 spec/symbol_spec.rb
@@ -0,0 +1,24 @@
+require 'backports'
+require_relative 'spec_helper'
+require_relative '../lib/celebration/corext/symbol'
+
+describe Symbol do
+ describe '#to_path' do
+ it 'should return the text of the symbol' do
+ :some_path.to_path.should == 'some_path'
+ end
+ end
+
+ describe '#to_str' do
+ case RUBY_VERSION
+ when /^1\.8/
+ it 'should return the text of the symbol' do
+ :some_path.to_str.should == 'some_path'
+ end
+ else
+ it 'should not exist' do
+ :some_path.should_not respond_to(:to_str)
+ end
+ end
+ end
+end

0 comments on commit ce6576d

Please sign in to comment.