cyrillizer 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *~
2
+ *.swp
3
+ pkg/*
@@ -1,10 +1,13 @@
1
+ === 0.1.0 2009-11-08
2
+
3
+ * Added to_lat and to_lat! methods
4
+ * Removed/Simplified development dependencies
5
+
1
6
  === 0.0.2 2009-11-08
2
7
 
3
- * 1 major enhancement:
4
8
  * Fixed convertions for upper case latters
5
9
 
6
10
  === 0.0.1 2009-10-12
7
11
 
8
- * 1 major enhancement:
9
12
  * Initial release
10
13
 
data/README.rdoc CHANGED
@@ -4,27 +4,37 @@
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- Character conversion from latin alphabet to Macedonian cyrillic alphabet
7
+ Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa
8
8
 
9
9
  == SYNOPSIS:
10
10
 
11
- - Ruby 1.8.6, 1.8.7
11
+ - Ruby version <= 1.8.7
12
12
 
13
13
  $KCODE = 'UTF8'
14
14
  require 'rubygems'
15
15
  require 'cyrillizer'
16
- puts 'Konvertiraj go ova na kirilica'.to_cyr
16
+ puts 'kirilica'.to_cyr
17
+ puts 'латиница'.to_lat
17
18
 
18
- - Ruby 1.9.1, ...
19
+ - Ruby version >= 1.9.1
19
20
 
20
21
  require 'cyrillizer'
21
- puts 'Konvertiraj go ova na kirilica'.to_cyr
22
+ puts 'kirilica'.to_cyr
23
+ puts 'латиница'.to_lat
22
24
 
23
25
  == INSTALL:
24
26
 
25
- gem install gemcutter
26
- gem tumble
27
- gem install cyrillizer
27
+ [sudo] gem install cyrillizer
28
+
29
+ To run the scenarios/specs, you have to first install cucumber and rspec gems
30
+
31
+ [sudo] gem install cucumber
32
+ [sudo] gem install rspec
33
+
34
+ And then, use their command line utillities:
35
+
36
+ spec spec --options spec/spec.opts
37
+ cucumber features
28
38
 
29
39
  == LICENSE:
30
40
 
data/Rakefile CHANGED
@@ -1,26 +1,13 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/cyrillizer'
6
-
7
- Hoe.plugin :newgem
8
- # Hoe.plugin :website
9
- Hoe.plugin :cucumberfeatures
10
-
11
- # Generate all the Rake tasks
12
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
- $hoe = Hoe.spec 'cyrillizer' do
14
- self.developer 'Dalibor Nasevic', 'dalibor.nasevic@gmail.com'
15
- self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
- self.rubyforge_name = self.name # TODO this is default value
17
- # self.extra_deps = [['activesupport','>= 2.0.2']]
18
-
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "cyrillizer"
5
+ gemspec.summary = "Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa"
6
+ gemspec.description = "Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa"
7
+ gemspec.email = "dalibor.nasevic@gmail.com"
8
+ gemspec.homepage = "http://github.com/dalibor/cyrillizer"
9
+ gemspec.authors = ["Dalibor Nasevic"]
10
+ end
11
+ rescue LoadError
12
+ puts "Jeweler not available. Install it with: gem install jeweler"
19
13
  end
20
-
21
- require 'newgem/tasks'
22
- Dir['tasks/**/*.rake'].each { |t| load t }
23
-
24
- # TODO - want other tests/tasks run by default? Add them to the list
25
- # remove_task :default
26
- # task :default => [:spec, :features]
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{cyrillizer}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dalibor Nasevic"]
12
+ s.date = %q{2010-05-23}
13
+ s.description = %q{Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa}
14
+ s.email = %q{dalibor.nasevic@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "CHANGELOG",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "cyrillizer.gemspec",
25
+ "features/convert_latin_to_cyrillic.feature",
26
+ "features/step_definitions/convert_latin_to_cyrillic_steps.rb",
27
+ "features/support/env.rb",
28
+ "lib/cyrillizer.rb",
29
+ "lib/cyrillizer/converter.rb",
30
+ "spec/cyrillizer_spec.rb",
31
+ "spec/spec.opts",
32
+ "spec/spec_helper.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/dalibor/cyrillizer}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.7}
38
+ s.summary = %q{Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa}
39
+ s.test_files = [
40
+ "spec/spec_helper.rb",
41
+ "spec/cyrillizer_spec.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ else
50
+ end
51
+ else
52
+ end
53
+ end
54
+
@@ -1,92 +1,92 @@
1
1
  Feature: Convert Latin To Cyrilic
2
- In order to use appropriate alphabet
3
- As an administrator
4
- I want to be able to convert all latic characters to cyrilic
2
+ In order to use appropriate alphabet
3
+ As an administrator
4
+ I want to be able to convert all latic characters to cyrilic
5
5
 
6
- Scenario Outline: User enters latic characters
7
- When user writes <latin> character
8
- Then that character will be converted into <cyrilic>
6
+ Scenario Outline: User enters latic characters
7
+ When user writes <latin> character
8
+ Then that character will be converted into <cyrilic>
9
9
 
10
- Examples:
11
- | latin | cyrilic |
12
- | a | а |
13
- | A | А |
14
- | b | б |
15
- | B | Б |
16
- | v | в |
17
- | V | В |
18
- | g | г |
19
- | G | Г |
20
- | d | д |
21
- | D | Д |
22
- | gj | ѓ |
23
- | GJ | Ѓ |
24
- | Gj | Ѓ |
25
- | e | е |
26
- | E | Е |
27
- | zh | ж |
28
- | ZH | Ж |
29
- | Zh | Ж |
30
- | z | з |
31
- | Z | З |
32
- | dz | ѕ |
33
- | DZ | Ѕ |
34
- | Dz | Ѕ |
35
- | i | и |
36
- | I | И |
37
- | j | ј |
38
- | J | Ј |
39
- | k | к |
40
- | K | К |
41
- | l | л |
42
- | L | Л |
43
- | lj | љ |
44
- | LJ | Љ |
45
- | Lj | Љ |
46
- | m | м |
47
- | M | М |
48
- | n | н |
49
- | N | Н |
50
- | nj | њ |
51
- | NJ | Њ |
52
- | Nj | Њ |
53
- | o | о |
54
- | O | О |
55
- | p | п |
56
- | P | П |
57
- | r | р |
58
- | R | Р |
59
- | s | с |
60
- | S | С |
61
- | t | т |
62
- | T | Т |
63
- | kj | ќ |
64
- | KJ | Ќ |
65
- | Kj | Ќ |
66
- | u | у |
67
- | U | У |
68
- | f | ф |
69
- | F | Ф |
70
- | h | х |
71
- | H | Х |
72
- | c | ц |
73
- | C | Ц |
74
- | ch | ч |
75
- | CH | Ч |
76
- | Ch | Ч |
77
- | dzh | џ |
78
- | DZH | Џ |
79
- | Dzh | Џ |
80
- | sh | ш |
81
- | SH | Ш |
82
- | Sh | Ш |
10
+ Examples:
11
+ | latin | cyrilic |
12
+ | a | а |
13
+ | A | А |
14
+ | b | б |
15
+ | B | Б |
16
+ | v | в |
17
+ | V | В |
18
+ | g | г |
19
+ | G | Г |
20
+ | d | д |
21
+ | D | Д |
22
+ | gj | ѓ |
23
+ | GJ | Ѓ |
24
+ | Gj | Ѓ |
25
+ | e | е |
26
+ | E | Е |
27
+ | zh | ж |
28
+ | ZH | Ж |
29
+ | Zh | Ж |
30
+ | z | з |
31
+ | Z | З |
32
+ | dz | ѕ |
33
+ | DZ | Ѕ |
34
+ | Dz | Ѕ |
35
+ | i | и |
36
+ | I | И |
37
+ | j | ј |
38
+ | J | Ј |
39
+ | k | к |
40
+ | K | К |
41
+ | l | л |
42
+ | L | Л |
43
+ | lj | љ |
44
+ | LJ | Љ |
45
+ | Lj | Љ |
46
+ | m | м |
47
+ | M | М |
48
+ | n | н |
49
+ | N | Н |
50
+ | nj | њ |
51
+ | NJ | Њ |
52
+ | Nj | Њ |
53
+ | o | о |
54
+ | O | О |
55
+ | p | п |
56
+ | P | П |
57
+ | r | р |
58
+ | R | Р |
59
+ | s | с |
60
+ | S | С |
61
+ | t | т |
62
+ | T | Т |
63
+ | kj | ќ |
64
+ | KJ | Ќ |
65
+ | Kj | Ќ |
66
+ | u | у |
67
+ | U | У |
68
+ | f | ф |
69
+ | F | Ф |
70
+ | h | х |
71
+ | H | Х |
72
+ | c | ц |
73
+ | C | Ц |
74
+ | ch | ч |
75
+ | CH | Ч |
76
+ | Ch | Ч |
77
+ | dzh | џ |
78
+ | DZH | Џ |
79
+ | Dzh | Џ |
80
+ | sh | ш |
81
+ | SH | Ш |
82
+ | Sh | Ш |
83
83
 
84
- Scenario Outline: User writes sentences in latic characters
85
- When user writes <latin> text
86
- Then that text will be converted into <cyrilic>
84
+ Scenario Outline: User writes sentences in latic characters
85
+ When user writes <latin> text
86
+ Then that text will be converted into <cyrilic>
87
87
 
88
- Examples:
89
- | latin | cyrilic |
90
- | abeceda | абецеда |
91
- | Cela rechenica | Цела реченица |
88
+ Examples:
89
+ | latin | cyrilic |
90
+ | abeceda | абецеда |
91
+ | Cela rechenica | Цела реченица |
92
92
 
@@ -4,11 +4,3 @@ gem 'cucumber'
4
4
  require 'cucumber'
5
5
  gem 'rspec'
6
6
  require 'spec'
7
-
8
- Before do
9
- @tmp_root = File.dirname(__FILE__) + "/../../tmp"
10
- @home_path = File.expand_path(File.join(@tmp_root, "home"))
11
- FileUtils.rm_rf @tmp_root
12
- FileUtils.mkdir_p @home_path
13
- ENV['HOME'] = @home_path
14
- end
@@ -1,27 +1,35 @@
1
1
  # coding: utf-8
2
2
  module Cyrillizer
3
- module Converter
4
-
5
- Latin = %w(DZH Dzh dzh GJ Gj gj ZH Zh zh DZ Dz dz LJ Lj lj NJ Nj nj KJ Kj kj CH Ch ch SH Sh sh A a B b V v G g D d E e Z z I i J j K k L l M m N n O o P p R r S s T t U u F f H h C c)
3
+ module Converter
4
+
5
+ Latin = %w(DZH Dzh dzh GJ Gj gj ZH Zh zh DZ Dz dz LJ Lj lj NJ Nj nj KJ Kj kj CH Ch ch SH Sh sh A a B b V v G g D d E e Z z I i J j K k L l M m N n O o P p R r S s T t U u F f H h C c)
6
6
  Cyrillic = %w(Џ Џ џ Ѓ Ѓ ѓ Ж Ж ж Ѕ Ѕ ѕ Љ Љ љ Њ Њ њ Ќ Ќ ќ Ч Ч ч Ш Ш ш А а Б б В в Г г Д д Е е З з И и Ј ј К к Л л М м Н н О о П п Р р С с Т т У у Ф ф Х х Ц ц)
7
-
8
- def to_cyr
9
- code(self.dup, Latin, Cyrillic)
10
- end
11
-
12
- def to_cyr!
13
- code(self, Latin, Cyrillic)
14
- end
15
-
7
+
8
+ def to_cyr
9
+ code(self.dup, Latin, Cyrillic)
10
+ end
11
+
12
+ def to_cyr!
13
+ code(self, Latin, Cyrillic)
14
+ end
15
+
16
+ def to_lat
17
+ code(self.dup, Cyrillic, Latin)
18
+ end
19
+
20
+ def to_lat!
21
+ code(self, Cyrillic, Latin)
22
+ end
23
+
16
24
  private
17
25
  def code(text, from, to)
18
26
  from.each_with_index do |latin, i|
19
27
  text.gsub!(latin, to[i])
20
28
  end
21
29
  return text
22
- end
30
+ end
23
31
 
24
- end
32
+ end
25
33
  end
26
34
 
27
35
  # Add to_cyr method to all Strings
data/lib/cyrillizer.rb CHANGED
@@ -2,7 +2,3 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  require 'cyrillizer/converter'
5
-
6
- module Cyrillizer
7
- VERSION = '0.0.2'
8
- end
@@ -1,17 +1,29 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "Convertor" do
4
-
5
- it "changes original string" do
4
+
5
+ it "should change original string when using to_cyr!" do
6
6
  string = 'orginalen'
7
- string.to_cyr!.should == 'оргинален'
8
- string.should == 'оргинален'
7
+ string.to_cyr!.should == 'оргинален'
8
+ string.should == 'оргинален'
9
9
  end
10
-
11
- it "does not changes original string" do
10
+
11
+ it "should not change original string when using to_cyr" do
12
12
  string = 'orginalen'
13
- string.to_cyr.should == 'оргинален'
14
- string.should == 'orginalen'
13
+ string.to_cyr.should == 'оргинален'
14
+ string.should == 'orginalen'
15
+ end
16
+
17
+ it "should change original string when using to_lat!" do
18
+ string = 'оргинален'
19
+ string.to_lat!.should == 'orginalen'
20
+ string.should == 'orginalen'
15
21
  end
16
-
22
+
23
+ it "should not change original string when using to_lat" do
24
+ string = 'оргинален'
25
+ string.to_lat.should == 'orginalen'
26
+ string.should == 'оргинален'
27
+ end
28
+
17
29
  end
data/spec/spec.opts CHANGED
@@ -1 +1,4 @@
1
- --colour
1
+ --colour
2
+ --format specdoc
3
+ --loadby mtime
4
+ --reverse
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyrillizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Dalibor Nasevic
@@ -9,43 +15,28 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-11-08 00:00:00 +01:00
18
+ date: 2010-05-23 00:00:00 +02:00
13
19
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: hoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 2.3.2
24
- version:
25
- description: Character conversion from latin alphabet to Macedonian cyrillic alphabet
26
- email:
27
- - dalibor.nasevic@gmail.com
20
+ dependencies: []
21
+
22
+ description: Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa
23
+ email: dalibor.nasevic@gmail.com
28
24
  executables: []
29
25
 
30
26
  extensions: []
31
27
 
32
28
  extra_rdoc_files:
33
- - History.txt
34
- - Manifest.txt
35
- - PostInstall.txt
29
+ - README.rdoc
36
30
  files:
37
- - History.txt
38
- - Manifest.txt
39
- - PostInstall.txt
31
+ - .gitignore
32
+ - CHANGELOG
40
33
  - README.rdoc
41
34
  - Rakefile
35
+ - VERSION
36
+ - cyrillizer.gemspec
42
37
  - features/convert_latin_to_cyrillic.feature
43
- - features/development.feature
44
- - features/step_definitions/common_steps.rb
45
38
  - features/step_definitions/convert_latin_to_cyrillic_steps.rb
46
- - features/support/common.rb
47
39
  - features/support/env.rb
48
- - features/support/matchers.rb
49
40
  - lib/cyrillizer.rb
50
41
  - lib/cyrillizer/converter.rb
51
42
  - spec/cyrillizer_spec.rb
@@ -55,30 +46,36 @@ has_rdoc: true
55
46
  homepage: http://github.com/dalibor/cyrillizer
56
47
  licenses: []
57
48
 
58
- post_install_message: PostInstall.txt
49
+ post_install_message:
59
50
  rdoc_options:
60
- - --main
61
- - README.rdoc
51
+ - --charset=UTF-8
62
52
  require_paths:
63
53
  - lib
64
54
  required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
65
56
  requirements:
66
57
  - - ">="
67
58
  - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
68
62
  version: "0"
69
- version:
70
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
71
65
  requirements:
72
66
  - - ">="
73
67
  - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
74
71
  version: "0"
75
- version:
76
72
  requirements: []
77
73
 
78
- rubyforge_project: cyrillizer
79
- rubygems_version: 1.3.5
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.7
80
76
  signing_key:
81
77
  specification_version: 3
82
- summary: Character conversion from latin alphabet to Macedonian cyrillic alphabet
83
- test_files: []
84
-
78
+ summary: Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa
79
+ test_files:
80
+ - spec/spec_helper.rb
81
+ - spec/cyrillizer_spec.rb
data/Manifest.txt DELETED
@@ -1,17 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- PostInstall.txt
4
- README.rdoc
5
- Rakefile
6
- features/convert_latin_to_cyrillic.feature
7
- features/development.feature
8
- features/step_definitions/common_steps.rb
9
- features/step_definitions/convert_latin_to_cyrillic_steps.rb
10
- features/support/common.rb
11
- features/support/env.rb
12
- features/support/matchers.rb
13
- lib/cyrillizer.rb
14
- lib/cyrillizer/converter.rb
15
- spec/cyrillizer_spec.rb
16
- spec/spec.opts
17
- spec/spec_helper.rb
data/PostInstall.txt DELETED
@@ -1,8 +0,0 @@
1
-
2
- Usage:
3
-
4
- require 'rubygems'
5
- require 'cyrillizer'
6
- puts 'Konvertiraj go ova na kirilica'.to_cyr
7
-
8
- For more information on cyrillizer, see http://github.com/dalibor/cyrillizer
@@ -1,13 +0,0 @@
1
- Feature: Development processes of newgem itself (rake tasks)
2
-
3
- As a Newgem maintainer or contributor
4
- I want rake tasks to maintain and release the gem
5
- So that I can spend time on the tests and code, and not excessive time on maintenance processes
6
-
7
- Scenario: Generate RubyGem
8
- Given this project is active project folder
9
- And "pkg" folder is deleted
10
- When I invoke task "rake gem"
11
- Then folder "pkg" is created
12
- And file with name matching "pkg/*.gem" is created else you should run "rake manifest" to fix this
13
- And gem spec key "rdoc_options" contains /--mainREADME.rdoc/
@@ -1,163 +0,0 @@
1
- Given /^this project is active project folder/ do
2
- @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
3
- end
4
-
5
- Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
6
- ENV[env_var] = value
7
- end
8
-
9
- Given /"(.*)" folder is deleted/ do |folder|
10
- in_project_folder { FileUtils.rm_rf folder }
11
- end
12
-
13
- When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
14
- @stdout = StringIO.new
15
- in_project_folder do
16
- if Object.const_defined?("APP_ROOT")
17
- APP_ROOT.replace(FileUtils.pwd)
18
- else
19
- APP_ROOT = FileUtils.pwd
20
- end
21
- run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
22
- end
23
- File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
24
- @stdout.rewind
25
- f << @stdout.read
26
- end
27
- end
28
-
29
- When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
30
- @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
31
- in_project_folder do
32
- system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
33
- end
34
- end
35
-
36
- When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
37
- @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
38
- in_project_folder do
39
- system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
40
- end
41
- end
42
-
43
- When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
44
- @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
45
- executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
46
- in_project_folder do
47
- system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
48
- end
49
- end
50
-
51
- When /^I invoke task "rake (.*)"/ do |task|
52
- @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
53
- in_project_folder do
54
- system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
55
- end
56
- end
57
-
58
- Then /^folder "(.*)" (is|is not) created/ do |folder, is|
59
- in_project_folder do
60
- File.exists?(folder).should(is == 'is' ? be_true : be_false)
61
- end
62
- end
63
-
64
- Then /^file "(.*)" (is|is not) created/ do |file, is|
65
- in_project_folder do
66
- File.exists?(file).should(is == 'is' ? be_true : be_false)
67
- end
68
- end
69
-
70
- Then /^file with name matching "(.*)" is created/ do |pattern|
71
- in_project_folder do
72
- Dir[pattern].should_not be_empty
73
- end
74
- end
75
-
76
- Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
77
- in_project_folder do
78
- actual_output = File.read(file)
79
- (does == 'does') ?
80
- actual_output.should(match(/#{regex}/)) :
81
- actual_output.should_not(match(/#{regex}/))
82
- end
83
- end
84
-
85
- Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
86
- File.exists?(gem_file).should be_true
87
- File.exists?(project_file).should be_true
88
- gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
89
- project_file_contents = File.read(File.join(@active_project_folder, project_file))
90
- project_file_contents.should == gem_file_contents
91
- end
92
-
93
- Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
94
- actual_output = File.read(@stdout)
95
- does_invoke == "does" ?
96
- actual_output.should(match(/dependency\s+#{generator}/)) :
97
- actual_output.should_not(match(/dependency\s+#{generator}/))
98
- end
99
-
100
- Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
101
- actual_output = File.read(@stdout)
102
- actual_output.should match(/#{opt1}/)
103
- actual_output.should match(/#{opt2}/)
104
- end
105
-
106
- Then /^I should see$/ do |text|
107
- actual_output = File.read(@stdout)
108
- actual_output.should contain(text)
109
- end
110
-
111
- Then /^I should not see$/ do |text|
112
- actual_output = File.read(@stdout)
113
- actual_output.should_not contain(text)
114
- end
115
-
116
- Then /^I should see exactly$/ do |text|
117
- actual_output = File.read(@stdout)
118
- actual_output.should == text
119
- end
120
-
121
- Then /^I should see all (\d+) tests pass/ do |expected_test_count|
122
- expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
123
- actual_output = File.read(@stdout)
124
- actual_output.should match(expected)
125
- end
126
-
127
- Then /^I should see all (\d+) examples pass/ do |expected_test_count|
128
- expected = %r{^#{expected_test_count} examples?, 0 failures}
129
- actual_output = File.read(@stdout)
130
- actual_output.should match(expected)
131
- end
132
-
133
- Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
134
- in_project_folder do
135
- yaml = eval yaml
136
- YAML.load(File.read(file)).should == yaml
137
- end
138
- end
139
-
140
- Then /^Rakefile can display tasks successfully/ do
141
- @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
142
- in_project_folder do
143
- system "rake -T > #{@stdout} 2> #{@stdout}"
144
- end
145
- actual_output = File.read(@stdout)
146
- actual_output.should match(/^rake\s+\w+\s+#\s.*/)
147
- end
148
-
149
- Then /^task "rake (.*)" is executed successfully/ do |task|
150
- @stdout.should_not be_nil
151
- actual_output = File.read(@stdout)
152
- actual_output.should_not match(/^Don't know how to build task '#{task}'/)
153
- actual_output.should_not match(/Error/i)
154
- end
155
-
156
- Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
157
- in_project_folder do
158
- gem_file = Dir["pkg/*.gem"].first
159
- gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
160
- spec_value = gem_spec.send(key.to_sym)
161
- spec_value.to_s.should match(/#{regex}/)
162
- end
163
- end
@@ -1,29 +0,0 @@
1
- module CommonHelpers
2
- def in_tmp_folder(&block)
3
- FileUtils.chdir(@tmp_root, &block)
4
- end
5
-
6
- def in_project_folder(&block)
7
- project_folder = @active_project_folder || @tmp_root
8
- FileUtils.chdir(project_folder, &block)
9
- end
10
-
11
- def in_home_folder(&block)
12
- FileUtils.chdir(@home_path, &block)
13
- end
14
-
15
- def force_local_lib_override(project_name = @project_name)
16
- rakefile = File.read(File.join(project_name, 'Rakefile'))
17
- File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
18
- f << "$:.unshift('#{@lib_path}')\n"
19
- f << rakefile
20
- end
21
- end
22
-
23
- def setup_active_project_folder project_name
24
- @active_project_folder = File.join(@tmp_root, project_name)
25
- @project_name = project_name
26
- end
27
- end
28
-
29
- World(CommonHelpers)
@@ -1,11 +0,0 @@
1
- module Matchers
2
- def contain(expected)
3
- simple_matcher("contain #{expected.inspect}") do |given, matcher|
4
- matcher.failure_message = "expected #{given.inspect} to contain #{expected.inspect}"
5
- matcher.negative_failure_message = "expected #{given.inspect} not to contain #{expected.inspect}"
6
- given.index expected
7
- end
8
- end
9
- end
10
-
11
- World(Matchers)