seedy 0.6.3

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.
Files changed (60) hide show
  1. data/.document +5 -0
  2. data/Gemfile +16 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.rdoc +19 -0
  5. data/Rakefile +57 -0
  6. data/VERSION +1 -0
  7. data/lib/seedy.rb +12 -0
  8. data/lib/seedy/buffer.rb +2 -0
  9. data/lib/seedy/buffer/abstract_buffer.rb +27 -0
  10. data/lib/seedy/buffer/database_buffer.rb +38 -0
  11. data/lib/seedy/connection.rb +15 -0
  12. data/lib/seedy/exceptions.rb +2 -0
  13. data/lib/seedy/generators.rb +22 -0
  14. data/lib/seedy/generators/address.rb +19 -0
  15. data/lib/seedy/generators/company.rb +10 -0
  16. data/lib/seedy/generators/customer.rb +7 -0
  17. data/lib/seedy/generators/date_time.rb +7 -0
  18. data/lib/seedy/generators/department.rb +329 -0
  19. data/lib/seedy/generators/description.rb +7 -0
  20. data/lib/seedy/generators/direction.rb +8 -0
  21. data/lib/seedy/generators/duration.rb +7 -0
  22. data/lib/seedy/generators/email_address.rb +7 -0
  23. data/lib/seedy/generators/guid.rb +7 -0
  24. data/lib/seedy/generators/industry.rb +40 -0
  25. data/lib/seedy/generators/money.rb +7 -0
  26. data/lib/seedy/generators/name.rb +13 -0
  27. data/lib/seedy/generators/ownership.rb +8 -0
  28. data/lib/seedy/generators/password.rb +10 -0
  29. data/lib/seedy/generators/phone.rb +7 -0
  30. data/lib/seedy/generators/priority.rb +8 -0
  31. data/lib/seedy/generators/status.rb +7 -0
  32. data/lib/seedy/generators/subject.rb +7 -0
  33. data/lib/seedy/generators/title.rb +484 -0
  34. data/lib/seedy/generators/user.rb +7 -0
  35. data/lib/seedy/generators/website.rb +7 -0
  36. data/lib/seedy/graph.rb +3 -0
  37. data/lib/seedy/graphs/abstract_graph.rb +143 -0
  38. data/lib/seedy/graphs/instance_methods.rb +0 -0
  39. data/lib/seedy/graphs/simple_graph.rb +36 -0
  40. data/lib/seedy/graphs/user_graph.rb +35 -0
  41. data/lib/seedy/random.rb +7 -0
  42. data/lib/seedy/record.rb +13 -0
  43. data/lib/seedy/records/accounts.rb +49 -0
  44. data/lib/seedy/records/attribute_methods.rb +121 -0
  45. data/lib/seedy/records/bugs.rb +38 -0
  46. data/lib/seedy/records/calls.rb +41 -0
  47. data/lib/seedy/records/cases.rb +38 -0
  48. data/lib/seedy/records/contacts.rb +46 -0
  49. data/lib/seedy/records/email_addresses.rb +20 -0
  50. data/lib/seedy/records/emails.rb +32 -0
  51. data/lib/seedy/records/leads.rb +48 -0
  52. data/lib/seedy/records/opportunities.rb +42 -0
  53. data/lib/seedy/records/record.rb +45 -0
  54. data/lib/seedy/records/teams.rb +32 -0
  55. data/lib/seedy/records/users.rb +45 -0
  56. data/seedy.gemspec +140 -0
  57. data/test/helper.rb +18 -0
  58. data/test/test_generators.rb +10 -0
  59. data/test/test_seedy.rb +18 -0
  60. metadata +315 -0
@@ -0,0 +1,41 @@
1
+ module Seedy
2
+ class Calls < Record
3
+ self.columns = {
4
+ :id => :guid,
5
+ :name => :subject,
6
+ :date_entered => :date_time,
7
+ :date_modified => :date_time,
8
+ :modified_user_id => :association,
9
+ :created_by => :association,
10
+ :description => :description,
11
+ :deleted => 0,
12
+ :assigned_user_id => :association,
13
+ :team_id => :association,
14
+ :duration_hours => :duration,
15
+ :durection_minutes => :duration,
16
+ :date_start => :date_time,
17
+ :status => :status,
18
+ :direction => :direction,
19
+ }
20
+
21
+ class << self
22
+ def build(user, team, contact)
23
+ call = Calls.new
24
+ call.associate(user,team,contact)
25
+ call
26
+ end
27
+ end
28
+
29
+ def associate(user, team, contact)
30
+ write_attribute(:modified_user_id, user.id)
31
+ write_attribute(:assigned_user_id, user.id)
32
+ write_attribute(:team_id, team)
33
+ write_attribute(:created_by, user.id)
34
+ join("calls_contacts", {
35
+ :id => Random.guid,
36
+ :contact_id => contact,
37
+ :call_id => read_attribute(:id),
38
+ :date_modified => read_attribute(:date_modified)})
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ module Seedy
2
+ class Cases < Record
3
+ self.columns = {
4
+ :id => :guid,
5
+ :name => :subject,
6
+ :date_entered => :date_time,
7
+ :date_modified => :date_time,
8
+ :modified_user_id => :association,
9
+ :created_by => :association,
10
+ :description => :description,
11
+ :deleted => 0,
12
+ :assigned_user_id => :association,
13
+ :team_id => :association,
14
+ :status => :status,
15
+ :priority => :priority,
16
+ }
17
+
18
+ class << self
19
+ def build(user, team, account)
20
+ cases = Cases.new
21
+ cases.associate(user,team,account)
22
+ cases
23
+ end
24
+ end
25
+
26
+ def associate(user, team, account)
27
+ write_attribute(:modified_user_id, user.id)
28
+ write_attribute(:assigned_user_id, user.id)
29
+ write_attribute(:team_id, team)
30
+ write_attribute(:created_by, user.id)
31
+ join("accounts_cases", {
32
+ :id => Random.guid,
33
+ :account_id => account,
34
+ :case_id => read_attribute(:id),
35
+ :date_modified => read_attribute(:date_modified)})
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,46 @@
1
+ module Seedy
2
+ class Contacts < Record
3
+ self.columns = {
4
+ :id => :guid,
5
+ :date_entered => :date_time,
6
+ :date_modified => :date_time,
7
+ :modified_user_id => :association,
8
+ :created_by => :association,
9
+ :description => :description,
10
+ :deleted => 0,
11
+ :assigned_user_id => :association,
12
+ :team_id => :association,
13
+ :first_name => :first_name,
14
+ :last_name => :last_name,
15
+ :title => :title,
16
+ :department => :department,
17
+ :phone_mobile => :phone,
18
+ :phone_work => :phone,
19
+ :primary_address_street => :address_street,
20
+ :primary_address_city => :city,
21
+ :primary_address_state => :state,
22
+ :primary_address_postalcode => :zip,
23
+ :primary_address_country => :country,
24
+ }
25
+
26
+ class << self
27
+ def build(user, team, account)
28
+ contact = Contacts.new
29
+ contact.associate(user,team,account)
30
+ contact
31
+ end
32
+ end
33
+
34
+ def associate(user, team, account)
35
+ write_attribute(:modified_user_id, user.id)
36
+ write_attribute(:assigned_user_id, user.id)
37
+ write_attribute(:team_id, team)
38
+ write_attribute(:created_by, user.id)
39
+ join("accounts_contacts", {
40
+ :id => Random.guid,
41
+ :account_id => account,
42
+ :contact_id => read_attribute(:id),
43
+ :date_modified => read_attribute(:date_modified)})
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,20 @@
1
+ module Seedy
2
+ class EmailAddresses < Record
3
+ self.columns = {
4
+ :id => :guid,
5
+ :email_address => :email,
6
+ :date_created => :date_time,
7
+ :date_modified => :date_time,
8
+ :deleted => 0,
9
+ }
10
+
11
+ class << self
12
+ def build(user, team, account)
13
+ email_address = EmailAddresses.new
14
+ email_address.email_address_caps = email_address.email_address
15
+ email_address
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,32 @@
1
+ module Seedy
2
+ class Emails < Record
3
+ self.columns = {
4
+ :team_id => :association,
5
+ :id => :guid,
6
+ :date_entered => :date_time,
7
+ :date_modified => :date_time,
8
+ :assigned_user_id => :association,
9
+ :modified_user_id => :association,
10
+ :created_by => :association,
11
+ :deleted => 0,
12
+ :date_sent => :date_time,
13
+ :message_id => :guid,
14
+ :name => :subject,
15
+ }
16
+
17
+ class << self
18
+ def build(user, team, account)
19
+ email = Emails.new
20
+ email.associate(user,team)
21
+ email
22
+ end
23
+ end
24
+
25
+ def associate(user, team)
26
+ write_attribute(:modified_user_id, user.id)
27
+ write_attribute(:assigned_user_id, user.id)
28
+ write_attribute(:team_id, team)
29
+ write_attribute(:created_by, user.id)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,48 @@
1
+ module Seedy
2
+ class Leads < Record
3
+ self.columns = {
4
+ :id => :guid,
5
+ :date_entered => :date_time,
6
+ :date_modified => :date_time,
7
+ :modified_user_id => :association,
8
+ :created_by => :association,
9
+ :description => :description,
10
+ :deleted => 0,
11
+ :assigned_user_id => :association,
12
+ :team_id => :association,
13
+ :first_name => :first_name,
14
+ :last_name => :last_name,
15
+ :title => :title,
16
+ :department => :department,
17
+ :phone_mobile => :phone,
18
+ :phone_work => :phone,
19
+ :primary_address_street => :address_street,
20
+ :primary_address_city => :city,
21
+ :primary_address_state => :state,
22
+ :primary_address_postalcode => :zip,
23
+ :primary_address_country => :country,
24
+ :website => :website,
25
+ :contact_id => :association,
26
+ :account_id => :association,
27
+ :opportunity_id => :association,
28
+ }
29
+
30
+ class << self
31
+ def build(user, team, contact, opp, account)
32
+ lead = Leads.new
33
+ lead.associate(user,team,contact,opp,account)
34
+ lead
35
+ end
36
+ end
37
+
38
+ def associate(user, team, contact, opp, account)
39
+ write_attribute(:modified_user_id, user.id)
40
+ write_attribute(:assigned_user_id, user.id)
41
+ write_attribute(:team_id, team)
42
+ write_attribute(:created_by, user.id)
43
+ write_attribute(:contact_id, contact)
44
+ write_attribute(:account_id, account)
45
+ write_attribute(:opportunity_id, opp)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,42 @@
1
+ module Seedy
2
+ class Opportunities < Record
3
+ self.columns = {
4
+ :id => :guid,
5
+ :name => :company,
6
+ :date_entered => :date_time,
7
+ :date_modified => :date_time,
8
+ :modified_user_id => :association,
9
+ :created_by => :association,
10
+ :description => :description,
11
+ :deleted => 0,
12
+ :assigned_user_id => :association,
13
+ :team_id => :association,
14
+ :opportunity_type => :customer_type,
15
+ :amount => :monetary_sum,
16
+ :date_closed => :date_time,
17
+ :next_step => :subject,
18
+ :sales_stage => :subject
19
+ }
20
+
21
+ class << self
22
+ def build(user, team, account)
23
+ opportunity = Opportunities.new
24
+ opportunity.associate(user,team,account)
25
+ puts opportunity
26
+ opportunity
27
+ end
28
+ end
29
+
30
+ def associate(user, team, account)
31
+ write_attribute(:modified_user_id, user.id)
32
+ write_attribute(:assigned_user_id, user.id)
33
+ write_attribute(:team_id, team)
34
+ write_attribute(:created_by, user.id)
35
+ join("accounts_opportunities", {
36
+ :id => Random.guid,
37
+ :account_id => account,
38
+ :opportunity_id => read_attribute(:id),
39
+ :date_modified => read_attribute(:date_modified)})
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,45 @@
1
+ module Seedy
2
+ class Record
3
+
4
+ class_attribute :columns
5
+ self.columns = {}
6
+
7
+ # Tracks if we have extended our class with attribute methods yet.
8
+ class_attribute :attribute_methods_generated
9
+ self.attribute_methods_generated = false
10
+
11
+ def initialize(params={})
12
+ define_attribute_methods
13
+ @params = params
14
+ @attributes = {}
15
+ generate_attributes_for(self.columns)
16
+ end
17
+
18
+ def to_sql
19
+ sql = <<-EOF
20
+ INSERT INTO #{table_name}
21
+ (#{@attributes.keys.join(",")})
22
+ VALUES
23
+ (#{quote(@attributes.values).join(",")});
24
+ EOF
25
+ sql.gsub!(/^\s{6}/, '')
26
+ end
27
+
28
+ def inspect
29
+ self
30
+ end
31
+
32
+ def to_s
33
+ attrs = []
34
+ @attributes.keys.each do |k|
35
+ attrs << "#{k}: #{attribute_for_inspect(k)}"
36
+ end
37
+ "#<#{self.class} #{attrs.join(", ")}>"
38
+ end
39
+
40
+ Record.class_eval do
41
+ include Seedy::AttributeMethods
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+ module Seedy
2
+ class Teams < Record
3
+ self.columns = {
4
+ :id => :guid,
5
+ :name => :association,
6
+ :date_entered => :date_time,
7
+ :date_modified => :date_time,
8
+ :associated_user_id => :association,
9
+ :modified_user_id => 1,
10
+ :private => 1,
11
+ :description => :association
12
+ }
13
+
14
+ class << self
15
+ def build(user)
16
+ team = Teams.new
17
+ team.associate(user)
18
+ team
19
+ end
20
+ end
21
+
22
+ def associate(user)
23
+ write_attribute(:name, user.first_name + " " + user.last_name)
24
+ write_attribute(:associated_user_id, user.id)
25
+ write_attribute(:description, team_description)
26
+ end
27
+
28
+ def team_description
29
+ "Private team for #{read_attribute(:name)}"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ module Seedy
2
+ class Users < Record
3
+ self.columns = {
4
+ :id => :guid,
5
+ :user_name => :association,
6
+ :user_hash => :user_hash,
7
+ :system_generated_password => :password,
8
+ :pwd_last_changed => :date_time,
9
+ :sugar_login => :association,
10
+ :first_name => :first_name,
11
+ :last_name => :last_name,
12
+ :date_entered => :date_time,
13
+ :date_modified => :date_time,
14
+ :created_by => 1,
15
+ :title => :title,
16
+ :department => :department,
17
+ :phone_mobile => :phone,
18
+ :phone_work => :phone,
19
+ :status => :status,
20
+ :address_street => :address_street,
21
+ :address_city => :city,
22
+ :address_state => :state,
23
+ :address_country => :country,
24
+ :address_postalcode => :zip,
25
+ :employee_status => :status,
26
+ }
27
+
28
+ class << self
29
+ def build
30
+ user = Users.new
31
+ user.update_attributes
32
+ user
33
+ end
34
+ end
35
+
36
+ def update_attributes
37
+ write_attribute(:user_name, set_user_name)
38
+ write_attribute(:sugar_login, set_user_name)
39
+ end
40
+
41
+ def set_user_name
42
+ (@attributes[:first_name][0,1] + @attributes[:last_name][0,6]).downcase
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,140 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{seedy}
8
+ s.version = "0.6.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Carl Hicks"]
12
+ s.date = %q{2010-12-12}
13
+ s.description = %q{Seed databases with a Quickness(tm).}
14
+ s.email = %q{carl.hicks@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/seedy.rb",
27
+ "lib/seedy/buffer.rb",
28
+ "lib/seedy/buffer/abstract_buffer.rb",
29
+ "lib/seedy/buffer/database_buffer.rb",
30
+ "lib/seedy/connection.rb",
31
+ "lib/seedy/exceptions.rb",
32
+ "lib/seedy/generators.rb",
33
+ "lib/seedy/generators/address.rb",
34
+ "lib/seedy/generators/company.rb",
35
+ "lib/seedy/generators/customer.rb",
36
+ "lib/seedy/generators/date_time.rb",
37
+ "lib/seedy/generators/department.rb",
38
+ "lib/seedy/generators/description.rb",
39
+ "lib/seedy/generators/direction.rb",
40
+ "lib/seedy/generators/duration.rb",
41
+ "lib/seedy/generators/email_address.rb",
42
+ "lib/seedy/generators/guid.rb",
43
+ "lib/seedy/generators/industry.rb",
44
+ "lib/seedy/generators/money.rb",
45
+ "lib/seedy/generators/name.rb",
46
+ "lib/seedy/generators/ownership.rb",
47
+ "lib/seedy/generators/password.rb",
48
+ "lib/seedy/generators/phone.rb",
49
+ "lib/seedy/generators/priority.rb",
50
+ "lib/seedy/generators/status.rb",
51
+ "lib/seedy/generators/subject.rb",
52
+ "lib/seedy/generators/title.rb",
53
+ "lib/seedy/generators/user.rb",
54
+ "lib/seedy/generators/website.rb",
55
+ "lib/seedy/graph.rb",
56
+ "lib/seedy/graphs/abstract_graph.rb",
57
+ "lib/seedy/graphs/instance_methods.rb",
58
+ "lib/seedy/graphs/simple_graph.rb",
59
+ "lib/seedy/graphs/user_graph.rb",
60
+ "lib/seedy/random.rb",
61
+ "lib/seedy/record.rb",
62
+ "lib/seedy/records/accounts.rb",
63
+ "lib/seedy/records/attribute_methods.rb",
64
+ "lib/seedy/records/bugs.rb",
65
+ "lib/seedy/records/calls.rb",
66
+ "lib/seedy/records/cases.rb",
67
+ "lib/seedy/records/contacts.rb",
68
+ "lib/seedy/records/email_addresses.rb",
69
+ "lib/seedy/records/emails.rb",
70
+ "lib/seedy/records/leads.rb",
71
+ "lib/seedy/records/opportunities.rb",
72
+ "lib/seedy/records/record.rb",
73
+ "lib/seedy/records/teams.rb",
74
+ "lib/seedy/records/users.rb",
75
+ "seedy.gemspec",
76
+ "test/helper.rb",
77
+ "test/test_generators.rb",
78
+ "test/test_seedy.rb"
79
+ ]
80
+ s.homepage = %q{http://github.com/chicks/seedy}
81
+ s.licenses = ["MIT"]
82
+ s.require_paths = ["lib"]
83
+ s.rubygems_version = %q{1.3.7}
84
+ s.summary = %q{Seed databases with a Quickness(tm).}
85
+ s.test_files = [
86
+ "test/helper.rb",
87
+ "test/test_generators.rb",
88
+ "test/test_seedy.rb"
89
+ ]
90
+
91
+ if s.respond_to? :specification_version then
92
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
93
+ s.specification_version = 3
94
+
95
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
96
+ s.add_runtime_dependency(%q<mysql>, [">= 0"])
97
+ s.add_runtime_dependency(%q<guid>, [">= 0"])
98
+ s.add_runtime_dependency(%q<faker>, [">= 0"])
99
+ s.add_runtime_dependency(%q<i18n>, [">= 0"])
100
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0"])
101
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
102
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
103
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
104
+ s.add_development_dependency(%q<rcov>, [">= 0"])
105
+ s.add_runtime_dependency(%q<activesupport>, ["> 3.0"])
106
+ s.add_runtime_dependency(%q<mysql>, [">= 0"])
107
+ s.add_runtime_dependency(%q<guid>, [">= 0"])
108
+ s.add_runtime_dependency(%q<faker>, [">= 0"])
109
+ else
110
+ s.add_dependency(%q<mysql>, [">= 0"])
111
+ s.add_dependency(%q<guid>, [">= 0"])
112
+ s.add_dependency(%q<faker>, [">= 0"])
113
+ s.add_dependency(%q<i18n>, [">= 0"])
114
+ s.add_dependency(%q<activesupport>, [">= 3.0"])
115
+ s.add_dependency(%q<shoulda>, [">= 0"])
116
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
117
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
118
+ s.add_dependency(%q<rcov>, [">= 0"])
119
+ s.add_dependency(%q<activesupport>, ["> 3.0"])
120
+ s.add_dependency(%q<mysql>, [">= 0"])
121
+ s.add_dependency(%q<guid>, [">= 0"])
122
+ s.add_dependency(%q<faker>, [">= 0"])
123
+ end
124
+ else
125
+ s.add_dependency(%q<mysql>, [">= 0"])
126
+ s.add_dependency(%q<guid>, [">= 0"])
127
+ s.add_dependency(%q<faker>, [">= 0"])
128
+ s.add_dependency(%q<i18n>, [">= 0"])
129
+ s.add_dependency(%q<activesupport>, [">= 3.0"])
130
+ s.add_dependency(%q<shoulda>, [">= 0"])
131
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
132
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
133
+ s.add_dependency(%q<rcov>, [">= 0"])
134
+ s.add_dependency(%q<activesupport>, ["> 3.0"])
135
+ s.add_dependency(%q<mysql>, [">= 0"])
136
+ s.add_dependency(%q<guid>, [">= 0"])
137
+ s.add_dependency(%q<faker>, [">= 0"])
138
+ end
139
+ end
140
+