Permalink
Browse files

Added .gemspec, README, etc.

  • Loading branch information...
1 parent 91b8178 commit 178397a0f4268bd6b92419bd55b3116dcb037a53 @michaeldv committed Jan 4, 2012
Showing with 196 additions and 9 deletions.
  1. +22 −0 .gitignore
  2. +2 −0 CHANGELOG
  3. +2 −0 Gemfile
  4. +14 −0 Gemfile.lock
  5. +22 −0 LICENSE
  6. +86 −0 README.md
  7. +2 −0 Rakefile
  8. +7 −1 lib/quickie.rb
  9. +1 −1 lib/quickie/core_ext/object.rb
  10. +2 −2 lib/quickie/matcher.rb
  11. +1 −1 lib/quickie/runner.rb
  12. +1 −1 lib/quickie/version.rb
  13. +33 −0 quickie.gemspec
  14. +1 −3 test/quickie_test.rb
View
@@ -0,0 +1,22 @@
+## MAC OS
+.DS_Store
+
+## TEXTMATE
+*.tmproj
+tmtags
+
+## EMACS
+*~
+\#*
+.\#*
+
+## VIM
+*.swp
+
+## PROJECT::GENERAL
+coverage
+rdoc
+pkg
+
+## PROJECT::SPECIFIC
+.rvmrc
View
@@ -0,0 +1,2 @@
+0.1.0
+ - Initial Release.
View
@@ -0,0 +1,2 @@
+source "http://rubygems.org"
+gemspec
View
@@ -0,0 +1,14 @@
+PATH
+ remote: .
+ specs:
+ quickie (0.1.0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ quickie!
View
22 LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2011 Michael Dvorkin
+twitter.com/mid
+%w(mike dvorkin.net) * "@" || %w(mike fatfreecrm.com) * "@"
+
+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.
View
@@ -0,0 +1,86 @@
+## Quickie ##
+Quickie is micro library for quick in-place testing of your Ruby code. It adds two useful
+methods: <code>Object#should</code> and <code>Object#should\_not</code> for positive and
+negative assertions. With Quickie you can conveniently bundle tests together with your
+Ruby code, typically within <code>if $0 == \_\_FILE\_\_</code> conditional statement.
+
+### System Requirements ###
+Ruby 1.9.2 or later.
+
+### Installation ###
+ # Installing as Ruby gem
+ $ gem install quickie
+
+ # Cloning the repository
+ $ git clone git://github.com/michaeldv/quickie.git
+
+### Usage Example ###
+
+ $ cat > sample.rb
+ class Account # Back account class.
+ attr_reader :balance # Current account balance.
+
+ def initialize(amount) # Open the account.
+ @balance = amount # Accept initial deposit.
+ end
+
+ def deposit(amount) # Accept account deposit.
+ @balance += amount # Update current balance.
+ end
+
+ def withdraw(amount) # Withdraw from the account.
+ cash = [ @balance, amount ].min # Can't withdraw more than the balance.
+ @balance -= cash # Update current balance.
+ cash
+ end
+
+ def status # Display account status.
+ "Current balance: $#{balance}"
+ end
+ end
+
+ if $0 == __FILE__ # Execute only when running current Ruby file.
+ require "quickie" # Require the gem.
+
+ acc = Account.new(100) # Deposit $100 when opening the account.
+ acc.balance.should == 100 # Initial balance should be $100.
+ acc.deposit(200) # Deposit $200 more.
+ acc.balance.should != 100 # The balance should get updated.
+ acc.balance.should == 300 # It should be $100 + $200 = $300.
+
+ String.should === acc.status # Account#status returns a string.
+ acc.status.should_not =~ /\$$/ # Status string should contain the balance.
+ acc.status.should =~ /\$\d+$/ # The balance is one or more digits.
+
+ acc.withdraw(500).should == 300 # Withdrawal that exeeds the balance is not allowed.
+ acc.balance.should == 0 # Current balance should drop to zero.
+ acc.status.should !~ /\$[1-9]+$/ # Status no longer shows positive number.
+ acc.status.should =~ /\$0$/ # It shows $0.
+ end
+ ^D
+ $ ruby sample.rb
+ ..........
+
+ Passed: 10, not quite: 0, total tests: 10.
+
+### Testing Quickie ###
+Quickie code is tested by the Quickie itself.
+
+ $ ruby test/quickie_test.rb
+ ....................
+
+ Passed: 20, not quite: 0, total tests: 20.
+
+### Note on Patches/Pull Requests ###
+* Fork the project on Github.
+* Make your feature addition or bug fix.
+* Add test for it, making sure $ ruby test/*.rb all pass.
+* Commit, do not mess with Rakefile, version, or history.
+* Send me a pull request.
+
+### License ###
+
+ Copyright (c) 2011-12 Michael Dvorkin
+ twitter.com/mid
+ %w(mike dvorkin.net) * "@" || %w(mike fatfreecrm.com) * "@"
+ Released under the MIT license. See LICENSE file for details.
View
@@ -0,0 +1,2 @@
+require 'bundler'
+Bundler::GemHelper.install_tasks
View
@@ -1,8 +1,14 @@
# Copyright (c) 2011-12 Michael Dvorkin
#
-# Tiny Spec is freely distributable under the terms of MIT license.
+# Quickie is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
+#
+# Check Ruby version in case someone is playng with cloned source repo. Note
+# that quickie.gemspec explicitly sets required_ruby_version to ">= 1.9.2".
+#
+abort "Quickie requires Ruby 1.9.2 or later" if RUBY_VERSION < "1.9.2"
+
require File.dirname(__FILE__) + "/quickie/runner"
require File.dirname(__FILE__) + "/quickie/matcher"
require File.dirname(__FILE__) + "/quickie/version"
@@ -1,6 +1,6 @@
# Copyright (c) 2011-12 Michael Dvorkin
#
-# Tiny Spec is freely distributable under the terms of MIT license.
+# Quickie is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
class Object
View
@@ -1,12 +1,12 @@
# Copyright (c) 2011-12 Michael Dvorkin
#
-# Tiny Spec is freely distributable under the terms of MIT license.
+# Quickie is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
module Quickie
class Hell < RuntimeError
def oops
- puts "\n#{self.message.chomp} in #{self.backtrace[2].sub(':', ', line ').sub(':', ' ')}"
+ puts "\n#{message.chomp} in #{backtrace[2].sub(':', ', line ').sub(':', ' ')}"
end
end
View
@@ -1,6 +1,6 @@
# Copyright (c) 2011-12 Michael Dvorkin
#
-# Tiny Spec is freely distributable under the terms of MIT license.
+# Quickie is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
module Quickie
View
@@ -1,6 +1,6 @@
# Copyright (c) 2011-12 Michael Dvorkin
#
-# Tiny Spec is freely distributable under the terms of MIT license.
+# Quickie is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
module Quickie
View
@@ -0,0 +1,33 @@
+# Copyright (c) 2011-12 Michael Dvorkin
+#
+# Quickie is freely distributable under the terms of MIT license.
+# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
+#------------------------------------------------------------------------------
+require "rake"
+require File.dirname(__FILE__) + "/lib/quickie/version"
+
+task :default => :test
+
+task :test do
+ exec "ruby test/quickie_test.rb"
+end
+
+Gem::Specification.new do |s|
+ s.name = "quickie"
+ s.version = Quickie.version
+# s.platform = Gem::Platform::RUBY
+ s.authors = "Michael Dvorkin"
+ s.date = Time.now.strftime("%Y-%m-%d")
+ s.email = "mike@dvorkin.net"
+ s.homepage = "http://github.com/michaeldv/quickie"
+ s.summary = "Micro framework for in-place testing of Ruby code"
+ s.description = "Quickie adds Object#should and Object#should_not methods for quick testing of your Ruby code"
+
+ s.rubyforge_project = "quickie"
+ s.required_ruby_version = ">= 1.9.2"
+
+ s.files = Rake::FileList["[A-Z]*", "lib/**/*.rb", "test/*", ".gitignore"]
+ s.test_files = Rake::FileList["spec/*"]
+ s.executables = []
+ s.require_paths = ["lib"]
+end
View
@@ -1,10 +1,8 @@
# Copyright (c) 2011-12 Michael Dvorkin
#
-# Tiny Spec is freely distributable under the terms of MIT license.
+# Quickie is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
-fail "Quickie requires Ruby 1.9.2 or higher" if RUBY_VERSION < '1.9.2'
-
require "stringio"
require File.expand_path(File.dirname(__FILE__) + "/../lib/quickie")

0 comments on commit 178397a

Please sign in to comment.