forgery 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/LICENSE +20 -0
- data/README.markdown +13 -13
- data/Rakefile +50 -0
- data/VERSION.yml +3 -2
- data/forgery.gemspec +120 -0
- data/init.rb +1 -0
- data/lib/forgery.rb +14 -28
- data/lib/forgery/dictionaries.rb +24 -0
- data/lib/{dictionaries → forgery/dictionaries}/cities +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/colors +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/company_names +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/countries +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/female_first_names +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/frequencies +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/genders +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/languages +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/last_names +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/lorem_ipsum +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/male_first_names +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/name_suffixes +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/name_titles +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/province_abbrevs +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/provinces +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/races +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/shirt_sizes +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/state_abbrevs +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/states +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/street_suffixes +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/streets +0 -0
- data/lib/{dictionaries → forgery/dictionaries}/top_level_domains +0 -0
- data/lib/{extensions → forgery/extensions}/array.rb +0 -0
- data/lib/{extensions → forgery/extensions}/hash.rb +0 -0
- data/lib/{extensions → forgery/extensions}/range.rb +0 -0
- data/lib/{extensions → forgery/extensions}/string.rb +1 -0
- data/lib/forgery/file_reader.rb +69 -0
- data/lib/forgery/forgery.rb +23 -0
- data/lib/{forgeries/address_forgery.rb → forgery/forgery/address.rb} +27 -25
- data/lib/{forgeries/basic_forgery.rb → forgery/forgery/basic.rb} +41 -1
- data/lib/{forgeries/internet_forgery.rb → forgery/forgery/internet.rb} +4 -2
- data/lib/{forgeries/lorem_ipsum_forgery.rb → forgery/forgery/lorem_ipsum.rb} +1 -2
- data/lib/{forgeries/monetary_forgery.rb → forgery/forgery/monetary.rb} +3 -1
- data/lib/{forgeries/name_forgery.rb → forgery/forgery/name.rb} +2 -1
- data/lib/{forgeries/personal_forgery.rb → forgery/forgery/personal.rb} +2 -1
- data/lib/forgery/forgery_api.rb +9 -0
- data/lib/forgery/formats.rb +24 -0
- data/lib/{formats → forgery/formats}/phone +0 -0
- data/lib/{formats → forgery/formats}/street_number +0 -0
- data/lib/{formats → forgery/formats}/zip +0 -0
- data/spec/dictionaries_spec.rb +4 -4
- data/spec/file_reader_spec.rb +3 -3
- data/spec/{forgeries/address_forgery_spec.rb → forgery/address_spec.rb} +13 -13
- data/spec/{forgeries/basic_forgery_spec.rb → forgery/basic_spec.rb} +51 -51
- data/spec/{forgeries/internet_forgery_spec.rb → forgery/internet_spec.rb} +6 -6
- data/spec/{forgeries/lorem_ipsum_forgery_spec.rb → forgery/lorem_ipsum_spec.rb} +26 -26
- data/spec/{forgeries/monetary_forgery_spec.rb → forgery/monetary_spec.rb} +1 -1
- data/spec/{forgeries/name_forgery_spec.rb → forgery/name_spec.rb} +1 -1
- data/spec/{forgeries/personal_forgery_spec.rb → forgery/personal_spec.rb} +3 -3
- data/spec/forgery_spec.rb +33 -6
- data/spec/formats_spec.rb +4 -4
- metadata +78 -57
- data/lib/dictionaries.rb +0 -24
- data/lib/file_reader.rb +0 -53
- data/lib/formats.rb +0 -24
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Sevenwire LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
CHANGED
@@ -15,21 +15,21 @@ plugin includes a generator providing directories to make your own forgeries.
|
|
15
15
|
Install
|
16
16
|
=======
|
17
17
|
|
18
|
-
config.gem
|
18
|
+
config.gem 'forgery', :source => 'http://gemcutter.org'
|
19
19
|
|
20
20
|
|
21
21
|
Generator
|
22
22
|
=========
|
23
23
|
|
24
|
-
|
24
|
+
ruby script/generate forgery
|
25
25
|
|
26
26
|
In a rails project this generator creates:
|
27
27
|
|
28
|
-
*
|
29
|
-
*
|
30
|
-
*
|
31
|
-
*
|
32
|
-
*
|
28
|
+
* Rails.root/lib/forgery
|
29
|
+
* Rails.root/lib/forgery/dictionaries
|
30
|
+
* Rails.root/lib/forgery/extensions
|
31
|
+
* Rails.root/lib/forgery/forgeries
|
32
|
+
* Rails.root/lib/forgery/formats
|
33
33
|
|
34
34
|
You can then use these directories to write your own dictionaries, class
|
35
35
|
extensions, forgeries, and formats.
|
@@ -49,13 +49,13 @@ Here I'll supply a few examples of how it works, in general. See each forgery
|
|
49
49
|
for individual examples.
|
50
50
|
|
51
51
|
# Traditional syntax
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
Forgery::Basic.password # => "wYMYvq"
|
53
|
+
Forgery::Basic.password :allow_special => true # => ";Qo^N[T"
|
54
|
+
Forgery::Basic.hex_color # => "#f4d841"
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
Forgery::Monetary.money # => "8.21"
|
57
|
+
Forgery::Monetary.formatted_money # => "$3.25"
|
58
|
+
Forgery::Monetary.money :min => 100, :max => 1000 # => "848.97"
|
59
59
|
|
60
60
|
# Alternate syntax
|
61
61
|
Forgery(:basic).password # => "b6qZTQEH"
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'spec/rake/spectask'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'sdoc_helpers'
|
7
|
+
rescue LoadError
|
8
|
+
puts "sdoc support not enabled. Please gem install sdoc-helpers."
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
desc 'Default: run specs with rcov.'
|
13
|
+
task :default => :rcov_spec
|
14
|
+
|
15
|
+
desc 'Run the specs'
|
16
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
17
|
+
t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
|
18
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Run the specs with rcov'
|
22
|
+
Spec::Rake::SpecTask.new("rcov_spec") do |t|
|
23
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
t.spec_opts = ['--color']
|
25
|
+
t.rcov = true
|
26
|
+
t.rcov_opts = ['--exclude', '^spec,/gems/']
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::RDocTask.new do |t|
|
30
|
+
t.rdoc_dir = 'doc'
|
31
|
+
t.rdoc_files.include('lib/**/*.rb')
|
32
|
+
t.options << '--inline-source'
|
33
|
+
t.options << '--all'
|
34
|
+
t.options << '--line-numbers'
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
require 'jeweler'
|
39
|
+
Jeweler::Tasks.new do |s|
|
40
|
+
s.name = "forgery"
|
41
|
+
s.summary = "Easy and customizable generation of forged data."
|
42
|
+
s.email = "nate@sevenwire.com"
|
43
|
+
s.homepage = "http://github.com/sevenwire/forgery"
|
44
|
+
s.description = "Easy and customizable generation of forged data. Can be used as a gem or a rails plugin. Includes rails generators for creating your own forgeries."
|
45
|
+
s.authors = ["Nathan Sutton"]
|
46
|
+
end
|
47
|
+
Jeweler::GemcutterTasks.new
|
48
|
+
rescue LoadError
|
49
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
50
|
+
end
|
data/VERSION.yml
CHANGED
data/forgery.gemspec
ADDED
@@ -0,0 +1,120 @@
|
|
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{forgery}
|
8
|
+
s.version = "0.3.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Nathan Sutton"]
|
12
|
+
s.date = %q{2009-11-13}
|
13
|
+
s.description = %q{Easy and customizable generation of forged data. Can be used as a gem or a rails plugin. Includes rails generators for creating your own forgeries.}
|
14
|
+
s.email = %q{nate@sevenwire.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.markdown",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION.yml",
|
25
|
+
"forgery.gemspec",
|
26
|
+
"generators/forgery/USAGE",
|
27
|
+
"generators/forgery/forgery_generator.rb",
|
28
|
+
"init.rb",
|
29
|
+
"lib/forgery.rb",
|
30
|
+
"lib/forgery/dictionaries.rb",
|
31
|
+
"lib/forgery/dictionaries/cities",
|
32
|
+
"lib/forgery/dictionaries/colors",
|
33
|
+
"lib/forgery/dictionaries/company_names",
|
34
|
+
"lib/forgery/dictionaries/countries",
|
35
|
+
"lib/forgery/dictionaries/female_first_names",
|
36
|
+
"lib/forgery/dictionaries/frequencies",
|
37
|
+
"lib/forgery/dictionaries/genders",
|
38
|
+
"lib/forgery/dictionaries/languages",
|
39
|
+
"lib/forgery/dictionaries/last_names",
|
40
|
+
"lib/forgery/dictionaries/lorem_ipsum",
|
41
|
+
"lib/forgery/dictionaries/male_first_names",
|
42
|
+
"lib/forgery/dictionaries/name_suffixes",
|
43
|
+
"lib/forgery/dictionaries/name_titles",
|
44
|
+
"lib/forgery/dictionaries/province_abbrevs",
|
45
|
+
"lib/forgery/dictionaries/provinces",
|
46
|
+
"lib/forgery/dictionaries/races",
|
47
|
+
"lib/forgery/dictionaries/shirt_sizes",
|
48
|
+
"lib/forgery/dictionaries/state_abbrevs",
|
49
|
+
"lib/forgery/dictionaries/states",
|
50
|
+
"lib/forgery/dictionaries/street_suffixes",
|
51
|
+
"lib/forgery/dictionaries/streets",
|
52
|
+
"lib/forgery/dictionaries/top_level_domains",
|
53
|
+
"lib/forgery/extensions/array.rb",
|
54
|
+
"lib/forgery/extensions/hash.rb",
|
55
|
+
"lib/forgery/extensions/range.rb",
|
56
|
+
"lib/forgery/extensions/string.rb",
|
57
|
+
"lib/forgery/file_reader.rb",
|
58
|
+
"lib/forgery/forgery.rb",
|
59
|
+
"lib/forgery/forgery/address.rb",
|
60
|
+
"lib/forgery/forgery/basic.rb",
|
61
|
+
"lib/forgery/forgery/internet.rb",
|
62
|
+
"lib/forgery/forgery/lorem_ipsum.rb",
|
63
|
+
"lib/forgery/forgery/monetary.rb",
|
64
|
+
"lib/forgery/forgery/name.rb",
|
65
|
+
"lib/forgery/forgery/personal.rb",
|
66
|
+
"lib/forgery/forgery_api.rb",
|
67
|
+
"lib/forgery/formats.rb",
|
68
|
+
"lib/forgery/formats/phone",
|
69
|
+
"lib/forgery/formats/street_number",
|
70
|
+
"lib/forgery/formats/zip",
|
71
|
+
"spec/dictionaries_spec.rb",
|
72
|
+
"spec/extensions/array_spec.rb",
|
73
|
+
"spec/extensions/range_spec.rb",
|
74
|
+
"spec/extensions/string_spec.rb",
|
75
|
+
"spec/file_reader_spec.rb",
|
76
|
+
"spec/forgery/address_spec.rb",
|
77
|
+
"spec/forgery/basic_spec.rb",
|
78
|
+
"spec/forgery/internet_spec.rb",
|
79
|
+
"spec/forgery/lorem_ipsum_spec.rb",
|
80
|
+
"spec/forgery/monetary_spec.rb",
|
81
|
+
"spec/forgery/name_spec.rb",
|
82
|
+
"spec/forgery/personal_spec.rb",
|
83
|
+
"spec/forgery_spec.rb",
|
84
|
+
"spec/formats_spec.rb",
|
85
|
+
"spec/spec_helper.rb"
|
86
|
+
]
|
87
|
+
s.homepage = %q{http://github.com/sevenwire/forgery}
|
88
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
89
|
+
s.require_paths = ["lib"]
|
90
|
+
s.rubygems_version = %q{1.3.5}
|
91
|
+
s.summary = %q{Easy and customizable generation of forged data.}
|
92
|
+
s.test_files = [
|
93
|
+
"spec/dictionaries_spec.rb",
|
94
|
+
"spec/extensions/array_spec.rb",
|
95
|
+
"spec/extensions/range_spec.rb",
|
96
|
+
"spec/extensions/string_spec.rb",
|
97
|
+
"spec/file_reader_spec.rb",
|
98
|
+
"spec/forgery/address_spec.rb",
|
99
|
+
"spec/forgery/basic_spec.rb",
|
100
|
+
"spec/forgery/internet_spec.rb",
|
101
|
+
"spec/forgery/lorem_ipsum_spec.rb",
|
102
|
+
"spec/forgery/monetary_spec.rb",
|
103
|
+
"spec/forgery/name_spec.rb",
|
104
|
+
"spec/forgery/personal_spec.rb",
|
105
|
+
"spec/forgery_spec.rb",
|
106
|
+
"spec/formats_spec.rb",
|
107
|
+
"spec/spec_helper.rb"
|
108
|
+
]
|
109
|
+
|
110
|
+
if s.respond_to? :specification_version then
|
111
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
112
|
+
s.specification_version = 3
|
113
|
+
|
114
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
115
|
+
else
|
116
|
+
end
|
117
|
+
else
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/lib/forgery'
|
data/lib/forgery.rb
CHANGED
@@ -1,47 +1,33 @@
|
|
1
1
|
# Require forgeries at the bottom of the file so Forgery works as a gem both
|
2
2
|
# within rails and outside of it.
|
3
3
|
|
4
|
+
current_path = File.expand_path(File.dirname(__FILE__))
|
5
|
+
|
4
6
|
# Loading forgery helpers.
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
7
|
+
require current_path + '/forgery/file_reader'
|
8
|
+
require current_path + '/forgery/dictionaries'
|
9
|
+
require current_path + '/forgery/formats'
|
8
10
|
|
9
11
|
# Loading class extensions
|
10
|
-
Dir[
|
12
|
+
Dir[current_path + '/forgery/extensions/**/*.rb'].uniq.each do |file|
|
11
13
|
require file
|
12
14
|
end
|
13
15
|
|
14
|
-
class
|
15
|
-
|
16
|
-
def self.dictionaries
|
17
|
-
@@dictionaries ||= Dictionaries.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.formats
|
21
|
-
@@formats ||= Formats.new
|
22
|
-
end
|
16
|
+
# Load the forgery base class
|
17
|
+
require current_path + '/forgery/forgery'
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
# Alternate Forgery api, see spec/forgery_spec.rb for examples.
|
27
|
-
def Forgery(forgery, method=nil, *args)
|
28
|
-
klass = "#{forgery.to_s.camelize}Forgery".constantize
|
29
|
-
if method
|
30
|
-
klass.send(method, *args)
|
31
|
-
else
|
32
|
-
klass
|
33
|
-
end
|
34
|
-
end
|
19
|
+
# Load the forgery api method
|
20
|
+
require current_path + '/forgery/forgery_api'
|
35
21
|
|
36
|
-
# Loading the other forgeries AFTER the initial
|
37
|
-
Dir[
|
22
|
+
# Loading the other forgeries AFTER the initial forgery class is defined.
|
23
|
+
Dir[current_path + '/forgery/forgery/**/*.rb'].uniq.each do |file|
|
38
24
|
require file
|
39
25
|
end
|
40
26
|
|
41
27
|
# Loading rails forgeries to override current forgery methods and add new
|
42
28
|
# forgeries
|
43
|
-
if
|
44
|
-
Dir[File.expand_path(
|
29
|
+
if Forgery.rails?
|
30
|
+
Dir[File.expand_path(Forgery.rails_root + '/lib/forgery/**/*.rb')].uniq.each do |file|
|
45
31
|
require file
|
46
32
|
end
|
47
33
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Forgery
|
2
|
+
|
3
|
+
class Dictionaries
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@dictionaries = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def [](key)
|
10
|
+
symbolized_key = key.to_sym
|
11
|
+
@dictionaries[symbolized_key] ||= FileReader.read_dictionary(symbolized_key)
|
12
|
+
end
|
13
|
+
|
14
|
+
def loaded?(key)
|
15
|
+
@dictionaries.has_key?(key.to_sym)
|
16
|
+
end
|
17
|
+
|
18
|
+
def reset!
|
19
|
+
@dictionaries = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class Forgery
|
2
|
+
|
3
|
+
class FileReader
|
4
|
+
|
5
|
+
# Returns an array of strings containing each line in the dictionary
|
6
|
+
def self.read_dictionary(dictionary)
|
7
|
+
read_file(path_to_dictionary(dictionary))
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns an array of strings containing each line in the format
|
11
|
+
def self.read_format(format)
|
12
|
+
read_file(path_to_format(format))
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
# Reads a file while stripping leading and trailing whitespace, including
|
18
|
+
# newlines
|
19
|
+
def self.read_file(file)
|
20
|
+
lines = []
|
21
|
+
IO.foreach(file) do |line|
|
22
|
+
lines << line.strip unless line.strip == ''
|
23
|
+
end
|
24
|
+
lines
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns the path to a format. It will return the external path if the
|
28
|
+
# file exists, otherwise it will return the internal path.
|
29
|
+
def self.path_to_format(format)
|
30
|
+
if external_path_to_format(format) && File.exists?(external_path_to_format(format))
|
31
|
+
external_path_to_format(format)
|
32
|
+
else
|
33
|
+
internal_path_to_format(format)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns the path to a format outside of forgery
|
38
|
+
def self.external_path_to_format(format)
|
39
|
+
Forgery.rails_root + '/lib/forgery/formats/' + format.to_s if Forgery.rails?
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns the path to a format inside of forgery
|
43
|
+
def self.internal_path_to_format(format)
|
44
|
+
File.dirname(__FILE__) + '/formats/' + format.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the path to a dictionary. It will return the external path if
|
48
|
+
# the file exists, otherwise it will return the internal path.
|
49
|
+
def self.path_to_dictionary(dictionary)
|
50
|
+
if external_path_to_dictionary(dictionary) && File.exists?(external_path_to_dictionary(dictionary))
|
51
|
+
external_path_to_dictionary(dictionary)
|
52
|
+
else
|
53
|
+
internal_path_to_dictionary(dictionary)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns the path to a dictionary outside of forgery
|
58
|
+
def self.external_path_to_dictionary(dictionary)
|
59
|
+
Forgery.rails_root + '/lib/forgery/dictionaries/' + dictionary.to_s if Forgery.rails?
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the path to a dictionary within forgery
|
63
|
+
def self.internal_path_to_dictionary(dictionary)
|
64
|
+
File.dirname(__FILE__) + '/dictionaries/' + dictionary.to_s
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|