forgery 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,6 +31,10 @@ plugin includes a generator providing directories to make your own forgeries.
31
31
 
32
32
  ruby script/generate forgery
33
33
 
34
+ ## Rails 3 Generator
35
+
36
+ rails generate forgery
37
+
34
38
  In a rails project this generator creates:
35
39
 
36
40
  * Rails.root/lib/forgery
@@ -42,7 +46,7 @@ In a rails project this generator creates:
42
46
  You can then use these directories to write your own dictionaries, class
43
47
  extensions, forgeries, and formats.
44
48
 
45
- Forgery will look first here for dictionaries and formats, so you can override
49
+ Forgery will first look here for dictionaries and formats, so you can override
46
50
  the ones used in the plugin.
47
51
 
48
52
  See the forgeries in the plugin for examples of how to write your own.
@@ -73,6 +77,26 @@ for individual examples.
73
77
  Forgery(:monetary).formatted_money # => "$3.48"
74
78
  Forgery(:monetary).money :min => 100, :max => 1000 # => "923.36"
75
79
 
80
+ ##Customization
81
+ You can utilize the directories generated in /lib to customize the behavior of forgery.
82
+ Examples of each of these components are available in the source.
83
+
84
+ ###Dictionaries
85
+ Dictionaries are files with no extensions. Entries are separated by new lines.
86
+
87
+ ###Forgeries
88
+ Forgeries are classes that inherit from the Forgery class. A basic forgery definition is as follows
89
+
90
+ class NewForgery < Forgery
91
+ end
92
+
93
+ ###Extensions
94
+ Extensions are additional methods/functionality that are added to classes (Ruby core or otherwise)
95
+ that are loaded by Forgery. Follow standard Ruby practices.
96
+
97
+ ###Formats
98
+ Formatting for numerical fields. Each numerical entry corresponds to a # mark.
99
+
76
100
  ## DOCUMENTATION
77
101
 
78
102
  Documentation can be found at [http://sevenwire.github.com/forgery/](http://sevenwire.github.com/forgery/)
@@ -96,6 +120,7 @@ Thanks to the authors and contributors:
96
120
  * Mike Dungan
97
121
  * Andrew Selder (aselder)
98
122
  * Thomas Sinclair (anathematic)
123
+ * Stafford Brunk (wingrunr21)
99
124
 
100
125
  ## Notes
101
126
 
@@ -27,6 +27,6 @@ Dir[current_path + 'forgery/forgery/**/*.rb'].uniq.each do |file|
27
27
  require file
28
28
  end
29
29
 
30
- # Loading rails forgeries to override current forgery methods and add new
31
- # forgeries
32
- Forgery.load_from! "#{Forgery.rails_root}/lib/forgery" if Forgery.rails?
30
+ # Loading rails forgeries to override current forgery methods and add new forgeries
31
+ # Only run this for Rails < 3.0 since we need to use a Railtie to initialize >= 3.0
32
+ Forgery.load_from! "#{Forgery.rails_root}/lib/forgery" if Forgery.rails? && Rails::VERSION::STRING < "3.0.0"
@@ -0,0 +1,7 @@
1
+ Asia
2
+ North America
3
+ South America
4
+ Australia
5
+ Africa
6
+ Europe
7
+ Antarctica
@@ -0,0 +1,108 @@
1
+ Howarts School of Witchcraft and Wizardry
2
+ Beauxbatons Academy of Magic
3
+ Durmstrang Institude for Magical Learning
4
+ Diagon Alley
5
+ The Burrow
6
+ Azkaban Prison
7
+ Gringotts Bank
8
+ Malfoy Manor
9
+ Number 12, Grimmauld Place
10
+ Shell Cottage
11
+ Number 4, Privet Drive
12
+ The Leaky Cauldron
13
+ Arkham Asylum
14
+ Wayne Manor
15
+ Wayne Tower
16
+ The Batcave
17
+ Blackgate Prison
18
+ Daily Planet
19
+ Springfield Nuclear Power Plant
20
+ Kwik-E-Mart
21
+ Try-N-Save
22
+ Monstro Mart
23
+ King Toots
24
+ Moe's Tavern
25
+ Krusty Krab
26
+ Krusty Burger
27
+ Lard Lad Donuts
28
+ The Frying Dutchman
29
+ Springfield Elementary School
30
+ The Atlantic Hotel
31
+ The Bates Hotel
32
+ The Possum Lodge
33
+ The Inn of the Prancing Pony
34
+ Minas Morgul
35
+ Isengard
36
+ The Hornburg
37
+ Castle Wolfenstein
38
+ The Baxter Building
39
+ Nakatomi Plaza
40
+ The Citadel
41
+ The Fortress of Solitude
42
+ Starfleet Headquarters
43
+ The International Space Station
44
+ The Cathedral of Learning
45
+ FedEx Field
46
+ New Meadowlands Stadium
47
+ Arrowhead Stadium
48
+ Cowboys Stadium
49
+ Invesco Field at Mile High
50
+ Sun Life Stadium
51
+ Ralph Wilson Stadium
52
+ Bank of America Stadium
53
+ Cleveland Browns Stadium
54
+ Louisiana Superdome
55
+ Lambeau Field
56
+ Reliant Stadium
57
+ Qualcomm Stadium
58
+ Georgia Dome
59
+ M&T Bank Stdium
60
+ Candlestick Park
61
+ Lincoln Financial Field
62
+ LP Field
63
+ Gillette Stadium
64
+ EverBank Field
65
+ Qwest Field
66
+ Edward Jones Dome
67
+ Lucas Oil Stadium
68
+ Raymond James Stadium
69
+ Heinz Field
70
+ Ford Field
71
+ Hubert H. Humphrey Metrodome
72
+ University of Phoenix Stadium
73
+ Oakland-Alameda County Coliseum
74
+ Soldier Field
75
+ Jedi Temple
76
+ Loony Land
77
+ Moron Mountain
78
+ 1938 Sullivan
79
+ Centennial Hotel
80
+ Centennial Park
81
+ Union Station
82
+ City Hall
83
+ Hotel Metropolis
84
+ Metropolis Museum of Art
85
+ The Children's Museum
86
+ LexCorp Towers
87
+ Lincoln Memorial
88
+ Washington Monument
89
+ The White House
90
+ Torquilstone
91
+ The Bombursts Castle
92
+ The Royal Castle
93
+ The Pentagon
94
+ The Eiffel Tower
95
+ The Statue of Liberty
96
+ Mount Rushmore
97
+ Mount Everest
98
+ Churchill Downs
99
+ Alcatraz Island
100
+ The Sears Tower
101
+ The Empire State Building
102
+ The Bellagio Casino
103
+ The Mirage Casino
104
+ The MGM Grand Casino
105
+ The Bank Casino
106
+ The Casino Royale
107
+ MI6 Headquarters
108
+ The Palace of Westminster
@@ -18,7 +18,7 @@ class Forgery
18
18
  end
19
19
 
20
20
  def self.rails_root
21
- if defined?(Rails)
21
+ if defined?(Rails) && Rails.respond_to?(:root)
22
22
  Rails.root.to_s
23
23
  elsif defined?(RAILS_ROOT)
24
24
  RAILS_ROOT
@@ -135,4 +135,16 @@ class Forgery::Address < Forgery
135
135
  dictionaries[:countries].random
136
136
  end
137
137
 
138
+
139
+ # Gets a random continent out of the 'continents' dictionary.
140
+ #
141
+ # Forgery(:address).continent
142
+ # # => "Africa"
143
+ #
144
+ # Forgery(:address).continent
145
+ # # => "Europe"
146
+ def self.continent
147
+ dictionaries[:continents].random
148
+ end
149
+
138
150
  end
@@ -40,4 +40,7 @@ class Forgery::Name < Forgery
40
40
  dictionaries[:name_suffixes].random
41
41
  end
42
42
 
43
+ def self.location
44
+ dictionaries[:locations].random
45
+ end
43
46
  end
@@ -0,0 +1,10 @@
1
+ require 'forgery'
2
+ require 'rails'
3
+
4
+ module Forgery
5
+ class Railtie < Rails::Railtie
6
+ initializer "forgery.initialize" do
7
+ Forgery.load_from! "#{Rails.root}/lib/forgery"
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  class Forgery
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators/base'
2
+
3
+ class ForgeryGenerator < Rails::Generators::Base
4
+ desc "Create the necessary directories in /lib to customize forgery's behavior"
5
+
6
+ def self.source_root
7
+ @_forgery_source_root ||= File.expand_path(File.dirname(__FILE__))
8
+ end
9
+
10
+ def create_directories
11
+ puts "Creating directories in /lib/forgery..."
12
+
13
+ FileUtils.mkdir_p 'lib/forgery/dictionaries'
14
+ FileUtils.mkdir_p 'lib/forgery/extensions'
15
+ FileUtils.mkdir_p 'lib/forgery/forgeries'
16
+ FileUtils.mkdir_p 'lib/forgery/formats'
17
+ end
18
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 4
9
- version: 0.3.4
8
+ - 5
9
+ version: 0.3.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nathan Sutton
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-09 00:00:00 -05:00
17
+ date: 2010-10-19 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -43,6 +43,7 @@ files:
43
43
  - lib/forgery/dictionaries/cities
44
44
  - lib/forgery/dictionaries/colors
45
45
  - lib/forgery/dictionaries/company_names
46
+ - lib/forgery/dictionaries/continents
46
47
  - lib/forgery/dictionaries/countries
47
48
  - lib/forgery/dictionaries/country_code_top_level_domains
48
49
  - lib/forgery/dictionaries/female_first_names
@@ -52,6 +53,7 @@ files:
52
53
  - lib/forgery/dictionaries/job_titles
53
54
  - lib/forgery/dictionaries/languages
54
55
  - lib/forgery/dictionaries/last_names
56
+ - lib/forgery/dictionaries/locations
55
57
  - lib/forgery/dictionaries/lorem_ipsum
56
58
  - lib/forgery/dictionaries/male_first_names
57
59
  - lib/forgery/dictionaries/name_suffixes
@@ -86,8 +88,10 @@ files:
86
88
  - lib/forgery/formats/street_number
87
89
  - lib/forgery/formats/zip
88
90
  - lib/forgery/formats.rb
91
+ - lib/forgery/railtie.rb
89
92
  - lib/forgery/version.rb
90
93
  - lib/forgery.rb
94
+ - lib/generators/forgery/forgery_generator.rb
91
95
  - LICENSE
92
96
  - README.markdown
93
97
  - Rakefile