mingusbabcock-composite_primary_keys 2.2.2 → 2.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +156 -0
- data/Manifest.txt +122 -0
- data/README.txt +41 -0
- data/README_DB2.txt +33 -0
- data/Rakefile +65 -0
- data/init.rb +2 -0
- data/install.rb +30 -0
- data/lib/adapter_helper/base.rb +63 -0
- data/lib/adapter_helper/mysql.rb +13 -0
- data/lib/adapter_helper/oracle.rb +12 -0
- data/lib/adapter_helper/postgresql.rb +13 -0
- data/lib/adapter_helper/sqlite3.rb +13 -0
- data/lib/composite_primary_keys.rb +56 -0
- data/lib/composite_primary_keys/association_preload.rb +253 -0
- data/lib/composite_primary_keys/associations.rb +428 -0
- data/lib/composite_primary_keys/attribute_methods.rb +84 -0
- data/lib/composite_primary_keys/base.rb +341 -0
- data/lib/composite_primary_keys/calculations.rb +69 -0
- data/lib/composite_primary_keys/composite_arrays.rb +30 -0
- data/lib/composite_primary_keys/connection_adapters/ibm_db_adapter.rb +21 -0
- data/lib/composite_primary_keys/connection_adapters/oracle_adapter.rb +15 -0
- data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +53 -0
- data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +15 -0
- data/lib/composite_primary_keys/fixtures.rb +8 -0
- data/lib/composite_primary_keys/migration.rb +20 -0
- data/lib/composite_primary_keys/reflection.rb +19 -0
- data/lib/composite_primary_keys/version.rb +8 -0
- data/loader.rb +24 -0
- data/local/database_connections.rb.sample +10 -0
- data/local/paths.rb.sample +2 -0
- data/local/tasks.rb.sample +2 -0
- data/scripts/console.rb +48 -0
- data/scripts/txt2html +67 -0
- data/scripts/txt2js +59 -0
- data/tasks/activerecord_selection.rake +43 -0
- data/tasks/databases.rake +12 -0
- data/tasks/databases/mysql.rake +30 -0
- data/tasks/databases/oracle.rake +25 -0
- data/tasks/databases/postgresql.rake +26 -0
- data/tasks/databases/sqlite3.rake +28 -0
- data/tasks/deployment.rake +22 -0
- data/tasks/local_setup.rake +13 -0
- data/tasks/website.rake +18 -0
- data/test/README_tests.txt +67 -0
- data/test/abstract_unit.rb +94 -0
- data/test/connections/native_ibm_db/connection.rb +23 -0
- data/test/connections/native_mysql/connection.rb +13 -0
- data/test/connections/native_oracle/connection.rb +14 -0
- data/test/connections/native_postgresql/connection.rb +9 -0
- data/test/connections/native_sqlite/connection.rb +9 -0
- data/test/fixtures/article.rb +5 -0
- data/test/fixtures/articles.yml +6 -0
- data/test/fixtures/comment.rb +6 -0
- data/test/fixtures/comments.yml +16 -0
- data/test/fixtures/db_definitions/db2-create-tables.sql +113 -0
- data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -0
- data/test/fixtures/db_definitions/mysql.sql +174 -0
- data/test/fixtures/db_definitions/oracle.drop.sql +39 -0
- data/test/fixtures/db_definitions/oracle.sql +188 -0
- data/test/fixtures/db_definitions/postgresql.sql +199 -0
- data/test/fixtures/db_definitions/sqlite.sql +160 -0
- data/test/fixtures/department.rb +5 -0
- data/test/fixtures/departments.yml +3 -0
- data/test/fixtures/employee.rb +4 -0
- data/test/fixtures/employees.yml +9 -0
- data/test/fixtures/group.rb +3 -0
- data/test/fixtures/groups.yml +3 -0
- data/test/fixtures/hack.rb +6 -0
- data/test/fixtures/hacks.yml +2 -0
- data/test/fixtures/membership.rb +7 -0
- data/test/fixtures/membership_status.rb +3 -0
- data/test/fixtures/membership_statuses.yml +10 -0
- data/test/fixtures/memberships.yml +6 -0
- data/test/fixtures/product.rb +7 -0
- data/test/fixtures/product_tariff.rb +5 -0
- data/test/fixtures/product_tariffs.yml +12 -0
- data/test/fixtures/products.yml +6 -0
- data/test/fixtures/reading.rb +4 -0
- data/test/fixtures/readings.yml +10 -0
- data/test/fixtures/reference_code.rb +7 -0
- data/test/fixtures/reference_codes.yml +28 -0
- data/test/fixtures/reference_type.rb +7 -0
- data/test/fixtures/reference_types.yml +9 -0
- data/test/fixtures/street.rb +3 -0
- data/test/fixtures/streets.yml +15 -0
- data/test/fixtures/suburb.rb +6 -0
- data/test/fixtures/suburbs.yml +9 -0
- data/test/fixtures/tariff.rb +6 -0
- data/test/fixtures/tariffs.yml +13 -0
- data/test/fixtures/user.rb +10 -0
- data/test/fixtures/users.yml +6 -0
- data/test/hash_tricks.rb +34 -0
- data/test/plugins/pagination.rb +405 -0
- data/test/plugins/pagination_helper.rb +135 -0
- data/test/test_associations.rb +160 -0
- data/test/test_attribute_methods.rb +22 -0
- data/test/test_attributes.rb +84 -0
- data/test/test_clone.rb +34 -0
- data/test/test_composite_arrays.rb +51 -0
- data/test/test_create.rb +68 -0
- data/test/test_delete.rb +96 -0
- data/test/test_dummy.rb +28 -0
- data/test/test_exists.rb +29 -0
- data/test/test_find.rb +73 -0
- data/test/test_ids.rb +97 -0
- data/test/test_miscellaneous.rb +39 -0
- data/test/test_pagination.rb +38 -0
- data/test/test_polymorphic.rb +31 -0
- data/test/test_santiago.rb +27 -0
- data/test/test_tutorial_examle.rb +26 -0
- data/test/test_update.rb +40 -0
- data/website/index.html +199 -0
- data/website/index.txt +159 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +126 -0
- data/website/template.js +3 -0
- data/website/template.rhtml +53 -0
- data/website/version-raw.js +3 -0
- data/website/version-raw.txt +2 -0
- data/website/version.js +4 -0
- data/website/version.txt +3 -0
- metadata +180 -18
data/History.txt
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
== 2.2.1 2009-01-21
|
2
|
+
|
3
|
+
* fix ActiveRecord#exists? to work when passing conditions instead of ids
|
4
|
+
|
5
|
+
== 2.2.0 2008-10-29
|
6
|
+
|
7
|
+
* Rails 2.2.0 compatibility
|
8
|
+
|
9
|
+
== 1.1.0 2008-10-29
|
10
|
+
|
11
|
+
* fixes to get cpk working for Rails 2.1.2
|
12
|
+
|
13
|
+
== 1.0.10 2008-10-22
|
14
|
+
|
15
|
+
* add composite key where clause creator method [timurv]
|
16
|
+
|
17
|
+
== 1.0.9 2008-09-08
|
18
|
+
|
19
|
+
* fix postgres tests
|
20
|
+
* fix for delete_records when has_many association has composite keys [darxriggs]
|
21
|
+
* more consistent table/column name quoting [pbrant]
|
22
|
+
|
23
|
+
== 1.0.8 2008-08-27
|
24
|
+
|
25
|
+
* fix has_many :through for non composite models [thx rcarver]
|
26
|
+
|
27
|
+
== 1.0.7 2008-08-12
|
28
|
+
|
29
|
+
* fix for the last fix -- when has_many is composite and belongs_to is single
|
30
|
+
|
31
|
+
== 1.0.6 2008-08-06
|
32
|
+
|
33
|
+
* fix associations create
|
34
|
+
|
35
|
+
== 1.0.5 2008-07-25
|
36
|
+
|
37
|
+
* fix for calculations with a group by clause [thx Sirius Black]
|
38
|
+
|
39
|
+
== 1.0.4 2008-07-15
|
40
|
+
|
41
|
+
* support for oracle_enhanced adapter [thx Raimonds Simanovskis]
|
42
|
+
|
43
|
+
== 1.0.3 2008-07-13
|
44
|
+
|
45
|
+
* more fixes and tests for has many through [thx Menno van der Sman]
|
46
|
+
|
47
|
+
== 1.0.2 2008-06-07
|
48
|
+
|
49
|
+
* fix for has many through when through association has composite keys
|
50
|
+
|
51
|
+
== 1.0.1 2008-06-06
|
52
|
+
|
53
|
+
* Oracle fixes
|
54
|
+
|
55
|
+
== 1.0.0 2008-06-05
|
56
|
+
|
57
|
+
* Support for Rails 2.1
|
58
|
+
|
59
|
+
== 0.9.93 2008-06-01
|
60
|
+
|
61
|
+
* set fixed dependency on activerecord 2.0.2
|
62
|
+
|
63
|
+
== 0.9.92 2008-02-22
|
64
|
+
|
65
|
+
* Support for has_and_belongs_to_many
|
66
|
+
|
67
|
+
== 0.9.91 2008-01-27
|
68
|
+
|
69
|
+
* Incremented activerecord dependency to 2.0.2 [thx emmanuel.pirsch]
|
70
|
+
|
71
|
+
== 0.9.90 2008-01-27
|
72
|
+
|
73
|
+
* Trial release for rails/activerecord 2.0.2 supported
|
74
|
+
|
75
|
+
== 0.9.1 2007-10-28
|
76
|
+
|
77
|
+
* Migrations fix - allow :primary_key => [:name] to work [no unit test] [thx Shugo Maeda]
|
78
|
+
|
79
|
+
== 0.9.0 2007-09-28
|
80
|
+
|
81
|
+
* Added support for polymorphs [thx nerdrew]
|
82
|
+
* init.rb file so gem can be installed as a plugin for Rails [thx nerdrew]
|
83
|
+
* Added ibm_db support [thx K Venkatasubramaniyan]
|
84
|
+
* Support for cleaning dependents [thx K Venkatasubramaniyan]
|
85
|
+
* Rafactored db rake tasks into namespaces
|
86
|
+
* Added namespaced tests (e.g. mysql:test for test_mysql)
|
87
|
+
|
88
|
+
== 0.8.6 / 2007-6-12
|
89
|
+
|
90
|
+
* 1 emergency fix due to Rails Core change
|
91
|
+
* Rails v7004 removed #quote; fixed with connection.quote_column_name [thx nerdrew]
|
92
|
+
|
93
|
+
== 0.8.5 / 2007-6-5
|
94
|
+
|
95
|
+
* 1 change due to Rails Core change
|
96
|
+
* Can no longer use RAILS_CONNECTION_ADAPTERS from Rails core
|
97
|
+
* 7 dev improvement:
|
98
|
+
* Changed History.txt syntax to rdoc format
|
99
|
+
* Added deploy tasks
|
100
|
+
* Removed CHANGELOG + migrated into History.txt
|
101
|
+
* Changed PKG_NAME -> GEM_NAME in Rakefile
|
102
|
+
* Renamed README -> README.txt for :publish_docs task
|
103
|
+
* Added :check_version task
|
104
|
+
* VER => VERS in rakefile
|
105
|
+
* 1 website improvement:
|
106
|
+
* website/index.txt includes link to "8 steps to fix other ppls code"
|
107
|
+
|
108
|
+
== 0.8.4 / 2007-5-3
|
109
|
+
|
110
|
+
* 1 bugfix
|
111
|
+
* Corrected ids_list => ids in the exception message. That'll teach me for not adding unit tests before fixing bugs.
|
112
|
+
|
113
|
+
== 0.8.3 / 2007-5-3
|
114
|
+
|
115
|
+
* 1 bugfix
|
116
|
+
* Explicit reference to ::ActiveRecord::RecordNotFound
|
117
|
+
* 1 website addition:
|
118
|
+
* Added routing help [Pete Sumskas]
|
119
|
+
|
120
|
+
== 0.8.2 / 2007-4-11
|
121
|
+
|
122
|
+
* 1 major enhancement:
|
123
|
+
* Oracle unit tests!! [Darrin Holst]
|
124
|
+
* And they work too
|
125
|
+
|
126
|
+
== 0.8.1 / 2007-4-10
|
127
|
+
|
128
|
+
* 1 bug fix:
|
129
|
+
* Fixed the distinct(count) for oracle (removed 'as')
|
130
|
+
|
131
|
+
== 0.8.0 / 2007-4-6
|
132
|
+
|
133
|
+
* 1 major enhancement:
|
134
|
+
* Support for calcualtions on associations
|
135
|
+
* 2 new DB supported:
|
136
|
+
* Tests run on sqlite
|
137
|
+
* Tests run on postgresql
|
138
|
+
* History.txt to keep track of changes like these
|
139
|
+
* Using Hoe for Rakefile
|
140
|
+
* Website generator rake tasks
|
141
|
+
|
142
|
+
== 0.3.3
|
143
|
+
* id=
|
144
|
+
* create now work
|
145
|
+
|
146
|
+
== 0.1.4
|
147
|
+
* it was important that #{primary_key} for composites --> 'key1,key2' and not 'key1key2' so created PrimaryKeys class
|
148
|
+
|
149
|
+
== 0.0.1
|
150
|
+
* Initial version
|
151
|
+
* set_primary_keys(*keys) is the activation class method to transform an ActiveRecord into a composite primary key AR
|
152
|
+
* find(*ids) supports the passing of
|
153
|
+
* id sets: Foo.find(2,1),
|
154
|
+
* lists of id sets: Foo.find([2,1], [7,3], [8,12]),
|
155
|
+
* and even stringified versions of the above:
|
156
|
+
* Foo.find '2,1' or Foo.find '2,1;7,3'
|
data/Manifest.txt
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
README_DB2.txt
|
5
|
+
Rakefile
|
6
|
+
init.rb
|
7
|
+
install.rb
|
8
|
+
lib/adapter_helper/base.rb
|
9
|
+
lib/adapter_helper/mysql.rb
|
10
|
+
lib/adapter_helper/oracle.rb
|
11
|
+
lib/adapter_helper/postgresql.rb
|
12
|
+
lib/adapter_helper/sqlite3.rb
|
13
|
+
lib/composite_primary_keys.rb
|
14
|
+
lib/composite_primary_keys/association_preload.rb
|
15
|
+
lib/composite_primary_keys/associations.rb
|
16
|
+
lib/composite_primary_keys/attribute_methods.rb
|
17
|
+
lib/composite_primary_keys/base.rb
|
18
|
+
lib/composite_primary_keys/calculations.rb
|
19
|
+
lib/composite_primary_keys/composite_arrays.rb
|
20
|
+
lib/composite_primary_keys/connection_adapters/ibm_db_adapter.rb
|
21
|
+
lib/composite_primary_keys/connection_adapters/oracle_adapter.rb
|
22
|
+
lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
|
23
|
+
lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
|
24
|
+
lib/composite_primary_keys/fixtures.rb
|
25
|
+
lib/composite_primary_keys/migration.rb
|
26
|
+
lib/composite_primary_keys/reflection.rb
|
27
|
+
lib/composite_primary_keys/version.rb
|
28
|
+
loader.rb
|
29
|
+
local/database_connections.rb.sample
|
30
|
+
local/paths.rb.sample
|
31
|
+
local/tasks.rb.sample
|
32
|
+
scripts/console.rb
|
33
|
+
scripts/txt2html
|
34
|
+
scripts/txt2js
|
35
|
+
tasks/activerecord_selection.rake
|
36
|
+
tasks/databases.rake
|
37
|
+
tasks/databases/mysql.rake
|
38
|
+
tasks/databases/oracle.rake
|
39
|
+
tasks/databases/postgresql.rake
|
40
|
+
tasks/databases/sqlite3.rake
|
41
|
+
tasks/deployment.rake
|
42
|
+
tasks/local_setup.rake
|
43
|
+
tasks/website.rake
|
44
|
+
test/README_tests.txt
|
45
|
+
test/abstract_unit.rb
|
46
|
+
test/connections/native_ibm_db/connection.rb
|
47
|
+
test/connections/native_mysql/connection.rb
|
48
|
+
test/connections/native_oracle/connection.rb
|
49
|
+
test/connections/native_postgresql/connection.rb
|
50
|
+
test/connections/native_sqlite/connection.rb
|
51
|
+
test/fixtures/article.rb
|
52
|
+
test/fixtures/articles.yml
|
53
|
+
test/fixtures/comment.rb
|
54
|
+
test/fixtures/comments.yml
|
55
|
+
test/fixtures/db_definitions/db2-create-tables.sql
|
56
|
+
test/fixtures/db_definitions/db2-drop-tables.sql
|
57
|
+
test/fixtures/db_definitions/mysql.sql
|
58
|
+
test/fixtures/db_definitions/oracle.drop.sql
|
59
|
+
test/fixtures/db_definitions/oracle.sql
|
60
|
+
test/fixtures/db_definitions/postgresql.sql
|
61
|
+
test/fixtures/db_definitions/sqlite.sql
|
62
|
+
test/fixtures/department.rb
|
63
|
+
test/fixtures/departments.yml
|
64
|
+
test/fixtures/employee.rb
|
65
|
+
test/fixtures/employees.yml
|
66
|
+
test/fixtures/group.rb
|
67
|
+
test/fixtures/groups.yml
|
68
|
+
test/fixtures/hack.rb
|
69
|
+
test/fixtures/hacks.yml
|
70
|
+
test/fixtures/membership.rb
|
71
|
+
test/fixtures/membership_status.rb
|
72
|
+
test/fixtures/membership_statuses.yml
|
73
|
+
test/fixtures/memberships.yml
|
74
|
+
test/fixtures/product.rb
|
75
|
+
test/fixtures/product_tariff.rb
|
76
|
+
test/fixtures/product_tariffs.yml
|
77
|
+
test/fixtures/products.yml
|
78
|
+
test/fixtures/reading.rb
|
79
|
+
test/fixtures/readings.yml
|
80
|
+
test/fixtures/reference_code.rb
|
81
|
+
test/fixtures/reference_codes.yml
|
82
|
+
test/fixtures/reference_type.rb
|
83
|
+
test/fixtures/reference_types.yml
|
84
|
+
test/fixtures/street.rb
|
85
|
+
test/fixtures/streets.yml
|
86
|
+
test/fixtures/suburb.rb
|
87
|
+
test/fixtures/suburbs.yml
|
88
|
+
test/fixtures/tariff.rb
|
89
|
+
test/fixtures/tariffs.yml
|
90
|
+
test/fixtures/user.rb
|
91
|
+
test/fixtures/users.yml
|
92
|
+
test/hash_tricks.rb
|
93
|
+
test/plugins/pagination.rb
|
94
|
+
test/plugins/pagination_helper.rb
|
95
|
+
test/test_associations.rb
|
96
|
+
test/test_attribute_methods.rb
|
97
|
+
test/test_attributes.rb
|
98
|
+
test/test_clone.rb
|
99
|
+
test/test_composite_arrays.rb
|
100
|
+
test/test_create.rb
|
101
|
+
test/test_delete.rb
|
102
|
+
test/test_dummy.rb
|
103
|
+
test/test_exists.rb
|
104
|
+
test/test_find.rb
|
105
|
+
test/test_ids.rb
|
106
|
+
test/test_miscellaneous.rb
|
107
|
+
test/test_pagination.rb
|
108
|
+
test/test_polymorphic.rb
|
109
|
+
test/test_santiago.rb
|
110
|
+
test/test_tutorial_examle.rb
|
111
|
+
test/test_update.rb
|
112
|
+
tmp/test.db
|
113
|
+
website/index.html
|
114
|
+
website/index.txt
|
115
|
+
website/javascripts/rounded_corners_lite.inc.js
|
116
|
+
website/stylesheets/screen.css
|
117
|
+
website/template.js
|
118
|
+
website/template.rhtml
|
119
|
+
website/version-raw.js
|
120
|
+
website/version-raw.txt
|
121
|
+
website/version.js
|
122
|
+
website/version.txt
|
data/README.txt
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
= Composite Primary Keys for ActiveRecords
|
2
|
+
|
3
|
+
== Summary
|
4
|
+
|
5
|
+
ActiveRecords/Rails famously doesn't support composite primary keys.
|
6
|
+
This RubyGem extends the activerecord gem to provide CPK support.
|
7
|
+
|
8
|
+
== Installation
|
9
|
+
|
10
|
+
gem install composite_primary_keys
|
11
|
+
|
12
|
+
== Usage
|
13
|
+
|
14
|
+
require 'composite_primary_keys'
|
15
|
+
class ProductVariation
|
16
|
+
set_primary_keys :product_id, :variation_seq
|
17
|
+
end
|
18
|
+
|
19
|
+
pv = ProductVariation.find(345, 12)
|
20
|
+
|
21
|
+
It even supports composite foreign keys for associations.
|
22
|
+
|
23
|
+
See http://compositekeys.rubyforge.org for more.
|
24
|
+
|
25
|
+
== Running Tests
|
26
|
+
|
27
|
+
See test/README.tests.txt
|
28
|
+
|
29
|
+
== Url
|
30
|
+
|
31
|
+
http://compositekeys.rubyforge.org
|
32
|
+
|
33
|
+
== Questions, Discussion and Contributions
|
34
|
+
|
35
|
+
http://groups.google.com/compositekeys
|
36
|
+
|
37
|
+
== Author
|
38
|
+
|
39
|
+
Written by Dr Nic Williams, drnicwilliams@gmail
|
40
|
+
Contributions by many!
|
41
|
+
|
data/README_DB2.txt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Composite Primary key support for db2
|
2
|
+
|
3
|
+
== Driver Support ==
|
4
|
+
|
5
|
+
DB2 support requires the IBM_DB driver provided by http://rubyforge.org/projects/rubyibm/
|
6
|
+
project. Install using gem install ibm_db. Tested against version 0.60 of the driver.
|
7
|
+
This rubyforge project appears to be permenant location for the IBM adapter.
|
8
|
+
Older versions of the driver available from IBM Alphaworks will not work.
|
9
|
+
|
10
|
+
== Driver Bug and workaround provided as part of this plugin ==
|
11
|
+
|
12
|
+
Unlike the basic quote routine available for Rails AR, the DB2 adapter's quote
|
13
|
+
method doesn't return " column_name = 1 " when string values (integers in string type variable)
|
14
|
+
are passed for quoting numeric column. Rather it returns "column_name = '1'.
|
15
|
+
DB2 doesn't accept single quoting numeric columns in SQL. Currently, as part of
|
16
|
+
this plugin a fix is provided for the DB2 adapter since this plugin does
|
17
|
+
pass string values like this. Perhaps a patch should be sent to the DB2 adapter
|
18
|
+
project for a permanant fix.
|
19
|
+
|
20
|
+
== Database Setup ==
|
21
|
+
|
22
|
+
Database must be manually created using a separate command. Read the rake task
|
23
|
+
for creating tables and change the db name, user and passwords accordingly.
|
24
|
+
|
25
|
+
== Tested Database Server version ==
|
26
|
+
|
27
|
+
This is tested against DB2 v9.1 in Ubuntu Feisty Fawn (7.04)
|
28
|
+
|
29
|
+
== Tested Database Client version ==
|
30
|
+
|
31
|
+
This is tested against DB2 v9.1 in Ubuntu Feisty Fawn (7.04)
|
32
|
+
|
33
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/rdoctask'
|
6
|
+
require 'rake/packagetask'
|
7
|
+
require 'rake/gempackagetask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'hoe'
|
11
|
+
include FileUtils
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib', 'composite_primary_keys', 'version')
|
13
|
+
|
14
|
+
AUTHOR = "Dr Nic Williams"
|
15
|
+
EMAIL = "drnicwilliams@gmail.com"
|
16
|
+
DESCRIPTION = "Composite key support for ActiveRecords"
|
17
|
+
GEM_NAME = "composite_primary_keys" # what ppl will type to install your gem
|
18
|
+
if File.exists?("~/.rubyforge/user-config.yml")
|
19
|
+
# TODO this should prob go in a local/ file
|
20
|
+
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
21
|
+
RUBYFORGE_USERNAME = config["username"]
|
22
|
+
end
|
23
|
+
RUBYFORGE_PROJECT = "compositekeys"
|
24
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
25
|
+
|
26
|
+
REV = nil #File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
|
27
|
+
VERS = ENV['VERSION'] || (CompositePrimaryKeys::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
28
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config','debug.log','*.db','logfile','log/**/*','**/.DS_Store', '.project']
|
29
|
+
RDOC_OPTS = ['--quiet', '--title', "newgem documentation",
|
30
|
+
"--opname", "index.html",
|
31
|
+
"--line-numbers",
|
32
|
+
"--main", "README",
|
33
|
+
"--inline-source"]
|
34
|
+
|
35
|
+
class Hoe
|
36
|
+
def extra_deps
|
37
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Generate all the Rake tasks
|
42
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
43
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
44
|
+
p.author = AUTHOR
|
45
|
+
p.description = DESCRIPTION
|
46
|
+
p.email = EMAIL
|
47
|
+
p.summary = DESCRIPTION
|
48
|
+
p.url = HOMEPATH
|
49
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
50
|
+
p.test_globs = ["test/**/test*.rb"]
|
51
|
+
p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
|
52
|
+
|
53
|
+
# == Optional
|
54
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
55
|
+
p.extra_deps = [['activerecord', '>= 2.2.0']] #An array of rubygem dependencies.
|
56
|
+
#p.spec_extras - A hash of extra values to set in the gemspec.
|
57
|
+
end
|
58
|
+
|
59
|
+
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
|
60
|
+
PATH = RUBYFORGE_PROJECT
|
61
|
+
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
62
|
+
|
63
|
+
PROJECT_ROOT = File.expand_path(".")
|
64
|
+
|
65
|
+
require 'loader'
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'find'
|
3
|
+
require 'ftools'
|
4
|
+
|
5
|
+
include Config
|
6
|
+
|
7
|
+
# this was adapted from rdoc's install.rb by ways of Log4r
|
8
|
+
|
9
|
+
$sitedir = CONFIG["sitelibdir"]
|
10
|
+
unless $sitedir
|
11
|
+
version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
|
12
|
+
$libdir = File.join(CONFIG["libdir"], "ruby", version)
|
13
|
+
$sitedir = $:.find {|x| x =~ /site_ruby/ }
|
14
|
+
if !$sitedir
|
15
|
+
$sitedir = File.join($libdir, "site_ruby")
|
16
|
+
elsif $sitedir !~ Regexp.quote(version)
|
17
|
+
$sitedir = File.join($sitedir, version)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# the acual gruntwork
|
22
|
+
Dir.chdir("lib")
|
23
|
+
|
24
|
+
Find.find("composite_primary_keys", "composite_primary_keys.rb") { |f|
|
25
|
+
if f[-3..-1] == ".rb"
|
26
|
+
File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
|
27
|
+
else
|
28
|
+
File::makedirs(File.join($sitedir, *f.split(/\//)))
|
29
|
+
end
|
30
|
+
}
|