Skip to content

Commit

Permalink
Giving it the long-needed specs, cleaning out unnecessary dummy, reor…
Browse files Browse the repository at this point in the history
…ganizing for rubygems push
  • Loading branch information
caleon committed Oct 22, 2012
1 parent 3e0a7e9 commit a9e892e
Show file tree
Hide file tree
Showing 53 changed files with 546 additions and 573 deletions.
5 changes: 5 additions & 0 deletions .document
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
lib/**/*.rb
bin/*
-
features/**/*.feature
LICENSE.txt
59 changes: 53 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,54 @@
*.gem
.rvmrc

# rcov generated
coverage
coverage.data

# rdoc generated
rdoc

# yard generated
doc
.yardoc

# bundler
.bundle
Gemfile.lock
pkg/*
test/dummy/db/*.sqlite3
test/dummy/db/schema.rb
test/dummy/log/*.log

# jeweler generated
pkg

# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
#
# * Create a file at ~/.gitignore
# * Include files you want ignored
# * Run: git config --global core.excludesfile ~/.gitignore
#
# After doing this, these files will be ignored in all your git projects,
# saving you from having to 'pollute' every project you touch with them
#
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
#
# For MacOS:
#
.DS_Store

# For TextMate
#*.tmproj
#tmtags

# For emacs:
#*~
#\#*
#.\#*

# For vim:
#*.swp

# For redcar:
#.redcar

# For rubinius:
#*.rbc

*.log

1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
30 changes: 15 additions & 15 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"

# Declare your gem's dependencies in schrodinger.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# jquery-rails is used by the dummy application
gem "jquery-rails"

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "rspec", "~> 2.11.0"
gem "rdoc", "~> 3.12"
gem "bundler", ">= 1.0.0"
gem "jeweler", "~> 1.8.4"
# gem "rcov", ">= 0"
gem 'i18n'
gem 'activesupport', '>= 3.1.0'
gem 'justools', '~> 1.1.8', :github => 'caleon/justools'
end
44 changes: 44 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
GIT
remote: git://github.com/caleon/justools.git
revision: 0f5215f4c6777fc96795924d62f4e2200602f5e3
specs:
justools (1.1.10)

GEM
remote: http://rubygems.org/
specs:
activesupport (3.1.1)
multi_json (~> 1.0)
diff-lcs (1.1.3)
git (1.2.5)
i18n (0.6.1)
jeweler (1.8.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.7.5)
multi_json (1.0.3)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)

PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 3.1.0)
bundler (>= 1.0.0)
i18n
jeweler (~> 1.8.4)
justools (~> 1.1.8)!
rdoc (~> 3.12)
rspec (~> 2.11.0)
2 changes: 1 addition & 1 deletion MIT-LICENSE → LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2011 caleon.
Copyright (c) 2012 caleon

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
4 changes: 3 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

== Usage:

gem 'schrodingers-cat'
# or with GitHub for latest:
gem 'schrodinger', :git => "git://github.com/caleon/schrodinger.git"

== Use case:
Expand Down Expand Up @@ -94,4 +96,4 @@ http://github.com/caleon/schrodinger/contributors

== License

MIT License. Copyright 2011 caleon.
MIT License. Copyright 2011-2012 caleon.
73 changes: 46 additions & 27 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,56 @@
#!/usr/bin/env rake
# encoding: utf-8

require 'rubygems'
require 'bundler'
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
require 'rake'

require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "schrodingers-cat"
gem.homepage = "http://github.com/caleon/schrodinger"
gem.license = "MIT"
gem.summary = %Q{A convenience utility for dealing with the unknown state of an object's existence in order to avoid common code inelegance.}
gem.description = <<-DESC
The Schrodinger's Cat gem is a library that boasts neither novelty or
ingenuity, just the potential for writing more efficient code when it comes
to (and we've all been there) dealing with the ubiquitous cases wherein the
existence (or nil'ness) of the object referenced is ever in flux. To this
end, Schrodinger's Cat defines Object-level methods designed for theses
common cases.
DESC
gem.email = "[email protected]"
gem.authors = ["caleon"]
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Schrodinger'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end

RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end

task :default => :spec

Bundler::GemHelper.install_tasks

require 'rake/testtask'
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "Schrodinger's Cat #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end


task :default => :test
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.4
3 changes: 0 additions & 3 deletions lib/schrodinger/version.rb

This file was deleted.

8 changes: 2 additions & 6 deletions lib/schrodinger.rb → lib/schrodingers-cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
require 'active_support/core_ext/array/wrap'

require 'justools'
require 'schrodinger/schrodingers_cat'
require 'schrodinger/core_ext'

module Schrodinger

end
require 'schrodingers_cat/schrodingers_cat'
require 'schrodingers_cat/core_ext'
2 changes: 2 additions & 0 deletions lib/schrodingers/cat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# File exists only to resolve default library path lookup when name has dash.
require File.expand_path('../../schrodingers-cat', __FILE__)
24 changes: 12 additions & 12 deletions lib/schrodinger/core_ext.rb → lib/schrodingers_cat/core_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,37 @@ def only_unless_a?(*others, &block)
def assuming_a(*others, &block)
if_a?(*others.merge_options(:chain => true), &block)
end

##################################
# Exact comparison of #== in is_one_of? rather than utilizing #=== in #is_one_kind_of
###############################
def if_equals_a?(*others, &block); if_a?(*others.merge_options(:check => :is_included_in?), &block); end
def unless_equals_a?(*others, &block); if_equals_a?(*others.merge_options(:opposite => true), &block); end
def only_if_equals_a?(*others, &block); if_equals_a?(*others.merge_options(:else => nil), &block); end
def only_unless_equals_a?(*others, &block); unless_equals_a?(*others.merge_options(:else => nil), &block); end
def assuming_equals_a(*others, &block); if_equals_a?(*others.merge_options(:chain => true), &block); end
def if_equals_a?(*others, &block); if_a?(*others.merge_options(:conditions => in?(others)), &block); end
def unless_equals_a?(*others, &block); if_equals_a?(*others.merge_options(:opposite => true), &block); end
def only_if_equals_a?(*others, &block); if_equals_a?(*others.merge_options(:else => nil), &block); end
def only_unless_equals_a?(*others, &block); unless_equals_a?(*others.merge_options(:else => nil), &block); end
def assuming_equals_a(*others, &block); if_equals_a?(*others.merge_options(:chain => true), &block); end

#########################
# Custom conditionals. ##
#########################
def if?(varied, *args, &block) if_a?(*args.merge_options(:conditions => resolve_conditions(varied)), &block); end
def unless?(*args, &block); if?(*args.merge_options(:opposite => true), &block); end
def only_if?(*args, &block); if?(*args.merge_options(:else => nil), &block); end
def only_unless?(*args, &block); only_if?(*args.merge_options(:opposite => true), &block); end
#def assuming(*args, &block); if?(*args.merge_options(:chain => true), &block); end
#def assuming(*args, &block); if?(*args.merge_options(:chain => true), &block); end

#########################
# Utilities ##
#########################
def present_else_nil; present_else(nil); end
def significant_else_nil; significant_else(nil); end

protected
def present_else(other); if?(:present?, :else => other) { self }; end
def significant_else(other); if?(:significant?, :else => other) { self }; end

private
def resolve_conditions(varied)
varied.is_a?(Symbol) ? __send__(varied) : varied.is_a?(Array) ? __send__(*varied) : varied.is_a?(String) ? varied[0] =~ /\./ ? __send__(:eval, "self#{varied}") : eval(varied) : !!varied
varied.is_a?(Symbol) ? __send__(varied) : varied.is_a?(Array) ? __send__(*varied) : varied.is_a?(String) ? varied =~ /^\./ ? __send__(:eval, "self#{varied}") : eval(varied) : !!varied
end
end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def initialize(original, attrs={})
class_eval %{ def #{meth}; MODEL_OBJECT.#{meth}; end; }
end
#delegate *[ 'inspect', 'to_s', 'to_i', 'nil?', 'empty?' ,'blank?' ].map(&:intern), :to => :MODEL_OBJECT

# if Rails.env.development?
# def inspect; "nil (SchrodingersCat)"; end
# end
Expand All @@ -44,7 +44,7 @@ def initialize(original, attrs={})
class_eval %{ def #{meth}(other); MODEL_OBJECT.#{meth}(other); end; }
end
#delegate *[ "==", "eql?", "&", "^", "|" ].map(&:intern), :to => :MODEL_OBJECT

def dup; nil; end

def method_missing(method_sym, *arguments, &block)
Expand All @@ -53,4 +53,4 @@ def method_missing(method_sym, *arguments, &block)
self
end
private :method_missing
end
end
24 changes: 0 additions & 24 deletions schrodinger.gemspec

This file was deleted.

Loading

0 comments on commit a9e892e

Please sign in to comment.