diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..555aadd --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +*.gem +*.rbc +.bundle +.config +.yardoc +Gemfile.lock +InstalledFiles +_yardoc +coverage +doc/ +lib/bundler/man +pkg +rdoc +spec/reports +test/tmp +test/version_tmp +tmp +.ruby-version diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ee0c71c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: ruby +notifications: + email: + on_success: change + on_failure: always +rvm: + - 1.9.3 + - 2.0.0 + - 2.1.6 + - 2.2.2 + - 2.3.1 +before_install: + - gem update --system $RUBYGEMS_VERSION + - gem --version + - gem install bundler + - bundle --version + diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e74666f --- /dev/null +++ b/Gemfile @@ -0,0 +1,19 @@ +source 'https://rubygems.org' + +# Specify your gem's dependencies in hola.gemspec +gemspec + +platforms :ruby_18 do + # mime-types 2.0 requires Ruby version >= 1.9.2 + gem 'mime-types', '< 2.0' +end +platforms :ruby_18, :ruby_19 do + # json 2.0.1 requires Ruby >= 2.0 + gem 'json', '< 2.0' +end +platforms :ruby_22, :ruby_23 do + gem 'test-unit' + gem 'minitest' +end +gem 'coveralls', :require => false, :group => :development +gem 'tins', '<1.7.0' if RUBY_VERSION =~ /^1\./ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..369879e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,31 @@ +No copyright clause was included with code on github. + +Note https://help.github.com/articles/github-terms-of-service clause F.1 states: + +We claim no intellectual property rights over the material you provide to the Service. +Your profile and materials uploaded remain yours. +However, by setting your pages to be viewed publicly, you agree to allow others to view your Content. +By setting your repositories to be viewed publicly, you agree to allow others to view and fork your repositories. + +Code supplied by Ian Heggie is Copyright (C) 2014 Ian Heggie under MIT LICENCE + +MIT License + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..198c543 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Hola + +Expanded “hello world” gem, with tests and code coverage + +[![Travis CI tests](https://travis-ci.org/ianheggie/hola-ianh.png)](https://travis-ci.org/ianheggie/hola-ianh) +[![Coverage Status](https://coveralls.io/repos/ianheggie/hola-ianh/badge.png)](https://coveralls.io/r/ianheggie/hola-ianh) + +## Installation + +Add this line to your application's Gemfile: + + gem 'hola-ianh' + +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install hola-ianh + +## Usage + +See http://guides.rubygems.org/make-your-own-gem/ + +## Contributing + +1. Fork it +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create new Pull Request + +## Thanks + +Forked with thanks to qrush from https://github.com/qrush/hola. +Thanks for contributions of extra languages from various people. diff --git a/Rakefile b/Rakefile index debc11c..71887a8 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +require "bundler/gem_tasks" + require 'rake/testtask' Rake::TestTask.new do |t| diff --git a/hola.gemspec b/hola.gemspec index 7ebbbb3..017ebc4 100644 --- a/hola.gemspec +++ b/hola.gemspec @@ -1,22 +1,29 @@ -Gem::Specification.new do |s| - s.name = "hola" - s.version = "0.0.1" - s.default_executable = "hola" +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'hola/version' - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Nick Quaranto"] - s.date = %q{2010-04-03} - s.description = %q{A simple hello world gem} - s.email = %q{nick@quaran.to} - 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} - s.summary = %q{Hola!} +Gem::Specification.new do |spec| + spec.name = 'hola-ianh' + spec.version = Hola::VERSION + spec.authors = ['Nick Quaranto', 'Ian Heggie'] + spec.email = %q{nick@quaran.to ian@heggie.biz} + spec.description = %q{An expanded example of a simple hello world gem} + spec.summary = %q{Hola!} + spec.homepage = %q{http://rubygems.org/gems/hola-ianh} + spec.license = 'UNKNOWN+MIT' - if s.respond_to? :specification_version then - s.specification_version = 3 + spec.files = `git ls-files`.split($/) + spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ['lib'] + + spec.add_development_dependency 'bundler', '~> 1.3' + spec.add_development_dependency 'rake' + + spec.required_rubygems_version = Gem::Requirement.new('>= 0') if spec.respond_to? :required_rubygems_version= + if spec.respond_to? :specification_version then + spec.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then else @@ -24,4 +31,3 @@ Gem::Specification.new do |s| else end end - diff --git a/lib/hola.rb b/lib/hola.rb index 11183c3..67d442e 100644 --- a/lib/hola.rb +++ b/lib/hola.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + class Hola def self.hi(language) translator = Translator.new(language) @@ -6,3 +8,4 @@ def self.hi(language) end require 'hola/translator' +require 'hola/version' diff --git a/lib/hola/translator.rb b/lib/hola/translator.rb index a33abe6..fdbd3ab 100644 --- a/lib/hola/translator.rb +++ b/lib/hola/translator.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + class Hola::Translator def initialize(language = "english") @language = language @@ -9,6 +11,14 @@ def hi "hola mundo" when "korean" "anyoung ha se yo" + when "dutch" + "hallo wereld" + when "polish" + "witaj świecie" + when "german" + "hallo welt" + when "brazilian portuguese" + "olá mundo" else "hello world" end diff --git a/lib/hola/version.rb b/lib/hola/version.rb new file mode 100644 index 0000000..e184d33 --- /dev/null +++ b/lib/hola/version.rb @@ -0,0 +1,3 @@ +class Hola + VERSION = '0.1.0' +end diff --git a/test/test_hola.rb b/test/test_hola.rb index 54d1b20..09beee8 100644 --- a/test/test_hola.rb +++ b/test/test_hola.rb @@ -1,3 +1,7 @@ +# encoding: UTF-8 +require 'coveralls' +Coveralls.wear! + require 'test/unit' require 'hola' @@ -13,4 +17,24 @@ def test_any_hello def test_spanish_hello assert_equal "hola mundo", Hola.hi("spanish") end + + def test_dutch_hello + assert_equal "hallo wereld", Hola.hi("dutch") + end + + def test_korean_hello + assert_equal "anyoung ha se yo", Hola.hi("korean") + end + + def test_polish_hello + assert_equal "witaj świecie", Hola.hi("polish") + end + + def test_german_hello + assert_equal "hallo welt", Hola.hi("german") + end + + def test_brazilian_portuguese_hello + assert_equal "olá mundo", Hola.hi("brazilian portuguese") + end end