-
-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require_relative '../lib/generator' | ||
require_relative '../lib/pangram_cases' | ||
|
||
Generator.new('pangram', PangramCases).generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Pangram | ||
VERSION = 1 | ||
|
||
def self.is_pangram?(str) | ||
downcased_str = str.downcase | ||
('a'..'z').all? { |letter| downcased_str.include?(letter) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env ruby | ||
gem 'minitest', '>= 5.0.0' | ||
require 'minitest/autorun' | ||
require_relative 'pangram' | ||
|
||
# Test data version: | ||
# <%= sha1 %> | ||
class PangramTest < Minitest::Test<% test_cases.each do |test_case| %> | ||
def <%= test_case.name %><% if test_case.skipped? %> | ||
skip<% end %> | ||
str = '<%= test_case.input %>'<% if test_case.expected %> | ||
assert<% else %> | ||
refute<% end %> <%= test_case.do %> | ||
end | ||
<% end %> | ||
# Problems in exercism evolve over time, | ||
# as we find better ways to ask questions. | ||
# The version number refers to the version of the problem you solved, | ||
# not your solution. | ||
# | ||
# Define a constant named VERSION inside of Pangram. | ||
# If you are curious, read more about constants on RubyDoc: | ||
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html | ||
def test_bookkeeping | ||
skip | ||
assert_equal <%= version+1 %>, Pangram::VERSION | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env ruby | ||
gem 'minitest', '>= 5.0.0' | ||
require 'minitest/autorun' | ||
require_relative 'pangram' | ||
|
||
# Test data version: | ||
# 180638f Merge pull request #217 from ErikSchierboom/patch-2 | ||
|
||
class PangramTest < Minitest::Test | ||
def test_sentence_empty | ||
str = '' | ||
refute Pangram.is_pangram?(str) | ||
end | ||
|
||
def test_pangram_with_only_lower_case | ||
skip | ||
str = 'the quick brown fox jumps over the lazy dog' | ||
assert Pangram.is_pangram?(str) | ||
end | ||
|
||
def test_missing_character_x | ||
skip | ||
str = 'a quick movement of the enemy will jeopardize five gunboats' | ||
refute Pangram.is_pangram?(str) | ||
end | ||
|
||
def test_pangram_with_mixed_case_and_punctuation | ||
skip | ||
str = '"Five quacking Zephyrs jolt my wax bed."' | ||
assert Pangram.is_pangram?(str) | ||
end | ||
|
||
def test_pangram_with_non_ascii_characters | ||
skip | ||
str = 'Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.' | ||
assert Pangram.is_pangram?(str) | ||
end | ||
|
||
# Problems in exercism evolve over time, | ||
# as we find better ways to ask questions. | ||
# The version number refers to the version of the problem you solved, | ||
# not your solution. | ||
# | ||
# Define a constant named VERSION inside of Pangram. | ||
# If you are curious, read more about constants on RubyDoc: | ||
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html | ||
def test_bookkeeping | ||
skip | ||
assert_equal 1, Pangram::VERSION | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class PangramCase < OpenStruct | ||
def name | ||
'test_%s' % description.delete("'").gsub(/[ -]/, '_') | ||
end | ||
|
||
def do | ||
'Pangram.is_pangram?(str)' | ||
end | ||
|
||
def skipped? | ||
index > 0 | ||
end | ||
end | ||
|
||
PangramCases = proc do |data| | ||
JSON.parse(data)['cases'].map.with_index do |row, i| | ||
PangramCase.new(row.merge('index' => i)) | ||
end | ||
end |