cyrillizer 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/{History.txt → CHANGELOG} +5 -2
- data/README.rdoc +18 -8
- data/Rakefile +12 -25
- data/VERSION +1 -0
- data/cyrillizer.gemspec +54 -0
- data/features/convert_latin_to_cyrillic.feature +86 -86
- data/features/support/env.rb +0 -8
- data/lib/cyrillizer/converter.rb +22 -14
- data/lib/cyrillizer.rb +0 -4
- data/spec/cyrillizer_spec.rb +21 -9
- data/spec/spec.opts +4 -1
- metadata +33 -36
- data/Manifest.txt +0 -17
- data/PostInstall.txt +0 -8
- data/features/development.feature +0 -13
- data/features/step_definitions/common_steps.rb +0 -163
- data/features/support/common.rb +0 -29
- data/features/support/matchers.rb +0 -11
data/.gitignore
ADDED
data/{History.txt → CHANGELOG}
RENAMED
@@ -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
|
11
|
+
- Ruby version <= 1.8.7
|
12
12
|
|
13
13
|
$KCODE = 'UTF8'
|
14
14
|
require 'rubygems'
|
15
15
|
require 'cyrillizer'
|
16
|
-
puts '
|
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 '
|
22
|
+
puts 'kirilica'.to_cyr
|
23
|
+
puts 'латиница'.to_lat
|
22
24
|
|
23
25
|
== INSTALL:
|
24
26
|
|
25
|
-
gem install
|
26
|
-
|
27
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
data/cyrillizer.gemspec
ADDED
@@ -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
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
Examples:
|
89
|
+
| latin | cyrilic |
|
90
|
+
| abeceda | абецеда |
|
91
|
+
| Cela rechenica | Цела реченица |
|
92
92
|
|
data/features/support/env.rb
CHANGED
@@ -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
|
data/lib/cyrillizer/converter.rb
CHANGED
@@ -1,27 +1,35 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
module Cyrillizer
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
30
|
+
end
|
23
31
|
|
24
|
-
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
# Add to_cyr method to all Strings
|
data/lib/cyrillizer.rb
CHANGED
data/spec/cyrillizer_spec.rb
CHANGED
@@ -1,17 +1,29 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
3
|
describe "Convertor" do
|
4
|
-
|
5
|
-
it "
|
4
|
+
|
5
|
+
it "should change original string when using to_cyr!" do
|
6
6
|
string = 'orginalen'
|
7
|
-
|
8
|
-
|
7
|
+
string.to_cyr!.should == 'оргинален'
|
8
|
+
string.should == 'оргинален'
|
9
9
|
end
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
it "should not change original string when using to_cyr" do
|
12
12
|
string = 'orginalen'
|
13
|
-
|
14
|
-
|
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
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyrillizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
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:
|
18
|
+
date: 2010-05-23 00:00:00 +02:00
|
13
19
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
-
|
34
|
-
- Manifest.txt
|
35
|
-
- PostInstall.txt
|
29
|
+
- README.rdoc
|
36
30
|
files:
|
37
|
-
-
|
38
|
-
-
|
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:
|
49
|
+
post_install_message:
|
59
50
|
rdoc_options:
|
60
|
-
- --
|
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:
|
79
|
-
rubygems_version: 1.3.
|
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,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
|
data/features/support/common.rb
DELETED
@@ -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)
|