Skip to content

Commit

Permalink
moar code
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed Apr 29, 2011
1 parent ea44e82 commit a792e73
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs << 'test'
end

desc "Run tests"
task :default => :test
4 changes: 4 additions & 0 deletions bin/hola
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require 'hola'
puts Hola.hi(ARGV[0])
12 changes: 6 additions & 6 deletions hola.gemspec
Original file line number Diff line number Diff line change
@@ -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{[email protected]}
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:https://rubygems.org/gems/hola}
s.require_paths = ["lib"]
s.rubygems_version = %q{1.6.2}
Expand Down
2 changes: 1 addition & 1 deletion lib/hola.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Hola
def self.hi(language)
translator = Translator.new(language)
puts translator.hi
translator.hi
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/hola/translator.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
16 changes: 16 additions & 0 deletions test/test_hola.rb
Original file line number Diff line number Diff line change
@@ -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

2 comments on commit a792e73

@Wirachmat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make my first gem, trying...
wirachmat

@Wirachmat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hola_wirachmat
wirachmat

Please sign in to comment.