rails_seeder 0.0.2
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.rdoc +7 -0
- data/Rakefile +19 -0
- data/VERSION +1 -0
- data/lib/rails_seeder.rb +83 -0
- data/rails_seeder.gemspec +54 -0
- metadata +116 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Boba Fat
|
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.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
|
4
|
+
name = 'rails_seeder'
|
5
|
+
summary = 'Rake helper to generate models for testing rails app'
|
6
|
+
Jeweler::Tasks.new do |j|
|
7
|
+
j.name = name
|
8
|
+
j.summary = summary
|
9
|
+
j.homepage = "http://github.com/toy/#{name}"
|
10
|
+
j.authors = ["Boba Fat"]
|
11
|
+
j.add_dependency 'rake'
|
12
|
+
j.add_dependency 'rails'
|
13
|
+
j.add_dependency 'random_text'
|
14
|
+
j.add_dependency 'progress'
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/lib/rails_seeder.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
module RailsSeeder
|
2
|
+
module Helpers
|
3
|
+
require 'random_text'
|
4
|
+
require 'progress'
|
5
|
+
|
6
|
+
include RandomText
|
7
|
+
|
8
|
+
srand 1
|
9
|
+
|
10
|
+
Range.class_eval do
|
11
|
+
def rand
|
12
|
+
first + Kernel.rand(last - first + (exclude_end? ? 0 : 1))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Integer.class_eval do
|
17
|
+
def rand
|
18
|
+
Kernel.rand(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
ROMAN_SYMBOLS = {1=>'I', 5=>'V', 10=>'X', 50=>'L', 100=>'C', 500=>'D', 1000=>'M'}
|
22
|
+
ROMAN_SUBTRACTORS = [[1000, 100], [500, 100], [100, 10], [50, 10], [10, 1], [5, 1], [1, 0]]
|
23
|
+
def roman
|
24
|
+
return ROMAN_SYMBOLS[self] if ROMAN_SYMBOLS.has_key?(self)
|
25
|
+
ROMAN_SUBTRACTORS.each do |cutPoint, subtractor|
|
26
|
+
return cutPoint.roman + (self - cutPoint).roman if self > cutPoint
|
27
|
+
return subtractor.roman + (self + subtractor).roman if self >= cutPoint - subtractor && self < cutPoint
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Float.class_eval do
|
33
|
+
def rand
|
34
|
+
Kernel.rand * self
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
NilClass.class_eval do
|
39
|
+
def rand
|
40
|
+
Kernel.rand
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def random_days_ago(max_days)
|
45
|
+
rand(max_days - 1).days.ago - rand(23).hours - rand(59).minutes - rand(60).seconds
|
46
|
+
end
|
47
|
+
|
48
|
+
Array.class_eval do
|
49
|
+
def shuffled_part(max = nil)
|
50
|
+
max ||= length
|
51
|
+
sort_by{ Kernel.rand }.slice(0, max.rand)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.new(*args, &block)
|
57
|
+
name, arg_names, deps = Rake.application.resolve_args(args, &block)
|
58
|
+
|
59
|
+
unless defined? @@regenerate_defined
|
60
|
+
desc "run all generate tasks"
|
61
|
+
task :generate
|
62
|
+
|
63
|
+
desc "reset db, delete assets and run all generate tasks"
|
64
|
+
task :regenerate => 'db:migrate:reset'
|
65
|
+
if Rake::Task.task_defined?('assets:delete')
|
66
|
+
task :regenerate => 'assets:delete'
|
67
|
+
end
|
68
|
+
task :regenerate => :generate
|
69
|
+
|
70
|
+
@@regenerate_defined = true
|
71
|
+
end
|
72
|
+
|
73
|
+
task :generate => "generate:#{name}"
|
74
|
+
|
75
|
+
namespace :generate do
|
76
|
+
desc "generate #{name}"
|
77
|
+
task name => [:environment, deps].flatten.compact do
|
78
|
+
block.binding.eval("include #{self.name}::Helpers", __FILE__, __LINE__)
|
79
|
+
block.call
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -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{rails_seeder}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Boba Fat"]
|
12
|
+
s.date = %q{2010-05-29}
|
13
|
+
s.extra_rdoc_files = [
|
14
|
+
"LICENSE",
|
15
|
+
"README.rdoc"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
".gitignore",
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"lib/rails_seeder.rb",
|
24
|
+
"rails_seeder.gemspec"
|
25
|
+
]
|
26
|
+
s.homepage = %q{http://github.com/toy/rails_seeder}
|
27
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
s.rubygems_version = %q{1.3.6}
|
30
|
+
s.summary = %q{Rake helper to generate models for testing rails app}
|
31
|
+
|
32
|
+
if s.respond_to? :specification_version then
|
33
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
34
|
+
s.specification_version = 3
|
35
|
+
|
36
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
37
|
+
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
38
|
+
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
39
|
+
s.add_runtime_dependency(%q<random_text>, [">= 0"])
|
40
|
+
s.add_runtime_dependency(%q<progress>, [">= 0"])
|
41
|
+
else
|
42
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
43
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
44
|
+
s.add_dependency(%q<random_text>, [">= 0"])
|
45
|
+
s.add_dependency(%q<progress>, [">= 0"])
|
46
|
+
end
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
49
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
50
|
+
s.add_dependency(%q<random_text>, [">= 0"])
|
51
|
+
s.add_dependency(%q<progress>, [">= 0"])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_seeder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Boba Fat
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-29 00:00:00 +04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rails
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: random_text
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id003
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: progress
|
58
|
+
prerelease: false
|
59
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id004
|
68
|
+
description:
|
69
|
+
email:
|
70
|
+
executables: []
|
71
|
+
|
72
|
+
extensions: []
|
73
|
+
|
74
|
+
extra_rdoc_files:
|
75
|
+
- LICENSE
|
76
|
+
- README.rdoc
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- LICENSE
|
80
|
+
- README.rdoc
|
81
|
+
- Rakefile
|
82
|
+
- VERSION
|
83
|
+
- lib/rails_seeder.rb
|
84
|
+
- rails_seeder.gemspec
|
85
|
+
has_rdoc: true
|
86
|
+
homepage: http://github.com/toy/rails_seeder
|
87
|
+
licenses: []
|
88
|
+
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options:
|
91
|
+
- --charset=UTF-8
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 1.3.6
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Rake helper to generate models for testing rails app
|
115
|
+
test_files: []
|
116
|
+
|