Skip to content

Commit 99b395a

Browse files
committed
convert the plugin to rails 3
1 parent 0e35505 commit 99b395a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1020
-44
lines changed

Gemfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
source "http://rubygems.org"
2+
3+
# Declare your gem's dependencies in partitioned.gemspec.
4+
# Bundler will treat runtime dependencies like base dependencies, and
5+
# development dependencies will be added by default to the :development group.
6+
gemspec
7+
8+
# jquery-rails is used by the dummy application
9+
gem "jquery-rails"
10+
11+
# Declare any dependencies that are still in development here instead of in
12+
# your gemspec. These might include edge Rails or gems from your path or
13+
# Git. Remember to move these dependencies to your gemspec before releasing
14+
# your gem to rubygems.org.
15+
16+
# To use debugger
17+
# gem 'ruby-debug'

Gemfile.lock

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
PATH
2+
remote: .
3+
specs:
4+
partitioned (0.8.0)
5+
pg
6+
rails (~> 3.2.3)
7+
rspec-rails
8+
9+
GEM
10+
remote: http://rubygems.org/
11+
specs:
12+
actionmailer (3.2.3)
13+
actionpack (= 3.2.3)
14+
mail (~> 2.4.4)
15+
actionpack (3.2.3)
16+
activemodel (= 3.2.3)
17+
activesupport (= 3.2.3)
18+
builder (~> 3.0.0)
19+
erubis (~> 2.7.0)
20+
journey (~> 1.0.1)
21+
rack (~> 1.4.0)
22+
rack-cache (~> 1.2)
23+
rack-test (~> 0.6.1)
24+
sprockets (~> 2.1.2)
25+
activemodel (3.2.3)
26+
activesupport (= 3.2.3)
27+
builder (~> 3.0.0)
28+
activerecord (3.2.3)
29+
activemodel (= 3.2.3)
30+
activesupport (= 3.2.3)
31+
arel (~> 3.0.2)
32+
tzinfo (~> 0.3.29)
33+
activeresource (3.2.3)
34+
activemodel (= 3.2.3)
35+
activesupport (= 3.2.3)
36+
activesupport (3.2.3)
37+
i18n (~> 0.6)
38+
multi_json (~> 1.0)
39+
arel (3.0.2)
40+
builder (3.0.0)
41+
diff-lcs (1.1.3)
42+
erubis (2.7.0)
43+
hike (1.2.1)
44+
i18n (0.6.0)
45+
journey (1.0.3)
46+
jquery-rails (2.0.1)
47+
railties (>= 3.2.0, < 5.0)
48+
thor (~> 0.14)
49+
json (1.6.6)
50+
mail (2.4.4)
51+
i18n (>= 0.4.0)
52+
mime-types (~> 1.16)
53+
treetop (~> 1.4.8)
54+
mime-types (1.18)
55+
multi_json (1.2.0)
56+
pg (0.13.2)
57+
polyglot (0.3.3)
58+
rack (1.4.1)
59+
rack-cache (1.2)
60+
rack (>= 0.4)
61+
rack-ssl (1.3.2)
62+
rack
63+
rack-test (0.6.1)
64+
rack (>= 1.0)
65+
rails (3.2.3)
66+
actionmailer (= 3.2.3)
67+
actionpack (= 3.2.3)
68+
activerecord (= 3.2.3)
69+
activeresource (= 3.2.3)
70+
activesupport (= 3.2.3)
71+
bundler (~> 1.0)
72+
railties (= 3.2.3)
73+
railties (3.2.3)
74+
actionpack (= 3.2.3)
75+
activesupport (= 3.2.3)
76+
rack-ssl (~> 1.3.2)
77+
rake (>= 0.8.7)
78+
rdoc (~> 3.4)
79+
thor (~> 0.14.6)
80+
rake (0.9.2.2)
81+
rdoc (3.12)
82+
json (~> 1.4)
83+
rspec (2.9.0)
84+
rspec-core (~> 2.9.0)
85+
rspec-expectations (~> 2.9.0)
86+
rspec-mocks (~> 2.9.0)
87+
rspec-core (2.9.0)
88+
rspec-expectations (2.9.0)
89+
diff-lcs (~> 1.1.3)
90+
rspec-mocks (2.9.0)
91+
rspec-rails (2.9.0)
92+
actionpack (>= 3.0)
93+
activesupport (>= 3.0)
94+
railties (>= 3.0)
95+
rspec (~> 2.9.0)
96+
sprockets (2.1.2)
97+
hike (~> 1.2)
98+
rack (~> 1.0)
99+
tilt (~> 1.1, != 1.3.0)
100+
thor (0.14.6)
101+
tilt (1.3.3)
102+
treetop (1.4.10)
103+
polyglot
104+
polyglot (>= 0.3.1)
105+
tzinfo (0.3.32)
106+
107+
PLATFORMS
108+
ruby
109+
110+
DEPENDENCIES
111+
jquery-rails
112+
partitioned!

Rakefile

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
#!/usr/bin/env rake
2-
require 'rake/testtask'
3-
require 'rdoc/task'
4-
5-
desc 'Default: run unit tests.'
6-
task :default => :test
7-
8-
desc 'Test the partitioned plugin.'
9-
Rake::TestTask.new(:test) do |t|
10-
t.libs << 'lib'
11-
t.libs << 'test'
12-
t.pattern = 'test/**/*_test.rb'
13-
t.verbose = true
2+
begin
3+
require 'bundler/setup'
4+
rescue LoadError
5+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6+
end
7+
begin
8+
require 'rdoc/task'
9+
rescue LoadError
10+
require 'rdoc/rdoc'
11+
require 'rake/rdoctask'
12+
RDoc::Task = Rake::RDocTask
1413
end
1514

16-
desc 'Generate documentation for the partitioned plugin.'
17-
Rake::RDocTask.new(:rdoc) do |rdoc|
15+
RDoc::Task.new(:rdoc) do |rdoc|
1816
rdoc.rdoc_dir = 'rdoc'
1917
rdoc.title = 'Partitioned'
20-
rdoc.options << '--line-numbers' << '--inline-source'
18+
rdoc.options << '--line-numbers'
2119
rdoc.rdoc_files.include('README')
2220
rdoc.rdoc_files.include('lib/**/*.rb')
2321
end
22+
23+
24+
25+
26+
Bundler::GemHelper.install_tasks
27+

examples/company_id.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env ../../../../script/rails runner
1+
#!/usr/bin/env ../spec/dummy/script/rails runner
22
# if you use linux, please change previous line to the
3-
# "#!../../../../script/rails runner"
3+
# "#! ../spec/dummy/script/rails runner"
44

55
# Initial data:
66
#
@@ -301,6 +301,7 @@
301301

302302
class Employee < ByCompanyId
303303
belongs_to :company, :class_name => 'Company'
304+
attr_accessible :salary, :company_id, :name
304305

305306
connection.execute <<-SQL
306307
create table employees

examples/company_id_and_created_at.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env ../../../../script/rails runner
1+
#!/usr/bin/env ../spec/dummy/script/rails runner
22
# if you use linux, please change previous line to the
3-
# "#!../../../../script/rails runner"
3+
# "#! ../spec/dummy/script/rails runner"
44

55
# Initial data:
66
#
@@ -499,6 +499,7 @@
499499

500500
class Employee < Partitioned::MultiLevel
501501
belongs_to :company, :class_name => 'Company'
502+
attr_accessible :created_at, :salary, :company_id, :name
502503

503504
partitioned do |partition|
504505
partition.using_classes ByCompanyId, Partitioned::ByCreatedAt

examples/created_at.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env ../../../../script/rails runner
1+
#!/usr/bin/env ../spec/dummy/script/rails runner
22
# if you use linux, please change previous line to the
3-
# "#!../../../../script/rails runner"
3+
# "#! ../spec/dummy/script/rails runner"
44

55
# Initial data:
66
#
@@ -417,6 +417,7 @@
417417

418418
class Employee < Partitioned::ByCreatedAt
419419
belongs_to :company, :class_name => 'Company'
420+
attr_accessible :name, :company_id, :salary, :created_at
420421

421422
partitioned do |partition|
422423
partition.index :id, :unique => true

examples/created_at_referencing_awards.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env ../../../../script/rails runner
1+
#!/usr/bin/env ../spec/dummy/script/rails runner
22
# if you use linux, please change previous line to the
3-
# "#!../../../../script/rails runner"
3+
# "#! ../spec/dummy/script/rails runner"
44

55
# Initial data:
66
#
@@ -660,6 +660,7 @@
660660

661661
class Employee < Partitioned::ByCreatedAt
662662
belongs_to :company, :class_name => 'Company'
663+
attr_accessible :created_at, :salary, :name, :company_id
663664

664665
partitioned do |partition|
665666
partition.index :id, :unique => true
@@ -689,6 +690,7 @@ def self.partition_time_field
689690

690691
class Award < ByEmployeeCreatedAt
691692
belongs_to :employee, :class_name => 'Employee'
693+
attr_accessible :award_title, :employee_created_at, :employee_id, :awarded_on
692694

693695
partitioned do |partition|
694696
partition.foreign_key lambda {|model, *partition_key_values|
@@ -895,7 +897,7 @@ class Award < ByEmployeeCreatedAt
895897
base += $new_individual
896898

897899
updates = {}
898-
puts "update many employees#{$update_many}"
900+
puts "update many employees #{$update_many}"
899901
(1..$update_many).each do |i|
900902
index = rand(employees.length)
901903
employee_record = employees[index]

examples/id.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#!/usr/bin/env ../../../../script/rails runner
1+
#!/usr/bin/env ../spec/dummy/script/rails runner
22
# if you use linux, please change previous line to the
3-
# "#!../../../../script/rails runner"
3+
# "#! ../spec/dummy/script/rails runner"
4+
45
# Initial data:
56
#
67
# Companies table is completed by four companies:
@@ -350,6 +351,7 @@
350351

351352
class Employee < Partitioned::ById
352353
belongs_to :company, :class_name => 'Company'
354+
attr_accessible :company_id, :salary, :name
353355

354356
def self.partition_table_size
355357
return $partition_table_size

examples/start_date.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env ../../../../script/rails runner
1+
#!/usr/bin/env ../spec/dummy/script/rails runner
22
# if you use linux, please change previous line to the
3-
# "#!../../../../script/rails runner"
3+
# "#! ../spec/dummy/script/rails runner"
44

55
# Initial data:
66
#
@@ -486,6 +486,7 @@ def self.partition_time_field
486486

487487
class Employee < Partitioned::ByStartDate
488488
belongs_to :company, :class_name => 'Company'
489+
attr_accessible :company_id, :start_date, :salary, :name
489490

490491
partitioned do |partition|
491492
partition.index :id, :unique => true

install.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)