diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..debc11c --- /dev/null +++ b/Rakefile @@ -0,0 +1,8 @@ +require 'rake/testtask' + +Rake::TestTask.new do |t| + t.libs << 'test' +end + +desc "Run tests" +task :default => :test diff --git a/bin/hola b/bin/hola new file mode 100755 index 0000000..c42fd11 --- /dev/null +++ b/bin/hola @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +require 'hola' +puts Hola.hi(ARGV[0]) diff --git a/hola.gemspec b/hola.gemspec index bc49344..7ebbbb3 100644 --- a/hola.gemspec +++ b/hola.gemspec @@ -1,15 +1,15 @@ -# -*- encoding: utf-8 -*- - Gem::Specification.new do |s| - s.name = %q{hola} - s.version = "0.0.0" + s.name = "hola" + s.version = "0.0.1" + s.default_executable = "hola" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Nick Quaranto"] - s.date = %q{2010-10-03} + s.date = %q{2010-04-03} s.description = %q{A simple hello world gem} s.email = %q{nick@quaran.to} - s.files = ["lib/hola.rb"] + s.files = ["Rakefile", "lib/hola.rb", "lib/hola/translator.rb", "bin/hola"] + s.test_files = ["test/test_hola.rb"] s.homepage = %q{http://rubygems.org/gems/hola} s.require_paths = ["lib"] s.rubygems_version = %q{1.6.2} diff --git a/lib/hola.rb b/lib/hola.rb index e0f5277..11183c3 100644 --- a/lib/hola.rb +++ b/lib/hola.rb @@ -1,7 +1,7 @@ class Hola def self.hi(language) translator = Translator.new(language) - puts translator.hi + translator.hi end end diff --git a/lib/hola/translator.rb b/lib/hola/translator.rb index eff8bfc..311fde9 100644 --- a/lib/hola/translator.rb +++ b/lib/hola/translator.rb @@ -1,11 +1,11 @@ class Hola::Translator - def initialize(language = :english) + def initialize(language = "english") @language = language end def hi case @language - when :spanish + when "spanish" "hola mundo" else "hello world" diff --git a/test/test_hola.rb b/test/test_hola.rb new file mode 100644 index 0000000..54d1b20 --- /dev/null +++ b/test/test_hola.rb @@ -0,0 +1,16 @@ +require 'test/unit' +require 'hola' + +class HolaTest < Test::Unit::TestCase + def test_english_hello + assert_equal "hello world", Hola.hi("english") + end + + def test_any_hello + assert_equal "hello world", Hola.hi("ruby") + end + + def test_spanish_hello + assert_equal "hola mundo", Hola.hi("spanish") + end +end