Skip to content

Commit

Permalink
Initial Symbol#to_path/#to_str extension
Browse files Browse the repository at this point in the history
  • Loading branch information
bitherder committed Oct 29, 2011
1 parent 01118d3 commit ce6576d
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm '1.9.2@celebration'
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in celebration.gemspec
gemspec
1 change: 1 addition & 0 deletions README.md
@@ -0,0 +1 @@
# Larry E. Baltz's (LEB's) personal collection of Ruby code
17 changes: 17 additions & 0 deletions 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
26 changes: 26 additions & 0 deletions 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
5 changes: 5 additions & 0 deletions lib/celebration.rb
@@ -0,0 +1,5 @@
require "celebration/version"

module Celebration
# Your code goes here...
end
1 change: 1 addition & 0 deletions lib/celebration/corext/pathname.rb
@@ -0,0 +1 @@
require 'pathname'
4 changes: 4 additions & 0 deletions 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
3 changes: 3 additions & 0 deletions lib/celebration/version.rb
@@ -0,0 +1,3 @@
module Celebration
VERSION = "0.0.1"
end
6 changes: 6 additions & 0 deletions spec/pathname_spec.rb
@@ -0,0 +1,6 @@
require 'backports'
require_relative 'spec_helper'

describe Pathname do

end
6 changes: 6 additions & 0 deletions 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
24 changes: 24 additions & 0 deletions 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.