composite_primary_keys 12.0.9 → 14.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +894 -877
- data/README.rdoc +182 -180
- data/Rakefile +37 -37
- data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -19
- data/lib/composite_primary_keys/arel/sqlserver.rb +37 -37
- data/lib/composite_primary_keys/arel/to_sql.rb +18 -18
- data/lib/composite_primary_keys/associations/association.rb +23 -23
- data/lib/composite_primary_keys/associations/association_scope.rb +66 -68
- data/lib/composite_primary_keys/associations/collection_association.rb +31 -31
- data/lib/composite_primary_keys/associations/foreign_association.rb +15 -15
- data/lib/composite_primary_keys/associations/has_many_association.rb +35 -35
- data/lib/composite_primary_keys/associations/join_dependency.rb +137 -103
- data/lib/composite_primary_keys/associations/preloader/association.rb +68 -53
- data/lib/composite_primary_keys/associations/through_association.rb +25 -25
- data/lib/composite_primary_keys/attribute_methods/primary_key.rb +0 -2
- data/lib/composite_primary_keys/attribute_methods/read.rb +30 -30
- data/lib/composite_primary_keys/attribute_methods/write.rb +35 -35
- data/lib/composite_primary_keys/attribute_methods.rb +21 -9
- data/lib/composite_primary_keys/autosave_association.rb +60 -60
- data/lib/composite_primary_keys/base.rb +141 -141
- data/lib/composite_primary_keys/composite_arrays.rb +86 -86
- data/lib/composite_primary_keys/composite_predicates.rb +71 -69
- data/lib/composite_primary_keys/composite_relation.rb +29 -29
- data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +37 -37
- data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +10 -10
- data/lib/composite_primary_keys/connection_adapters/postgresql/database_statements.rb +26 -26
- data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +44 -44
- data/lib/composite_primary_keys/core.rb +48 -48
- data/lib/composite_primary_keys/counter_cache.rb +15 -15
- data/lib/composite_primary_keys/fixtures.rb +21 -21
- data/lib/composite_primary_keys/nested_attributes.rb +1 -1
- data/lib/composite_primary_keys/persistence.rb +96 -81
- data/lib/composite_primary_keys/reflection.rb +91 -29
- data/lib/composite_primary_keys/relation/batches.rb +15 -7
- data/lib/composite_primary_keys/relation/calculations.rb +110 -81
- data/lib/composite_primary_keys/relation/finder_methods.rb +235 -235
- data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +39 -20
- data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
- data/lib/composite_primary_keys/relation/where_clause.rb +18 -23
- data/lib/composite_primary_keys/relation.rb +197 -193
- data/lib/composite_primary_keys/sanitization.rb +42 -42
- data/lib/composite_primary_keys/table_metadata.rb +11 -0
- data/lib/composite_primary_keys/transactions.rb +34 -34
- data/lib/composite_primary_keys/validations/uniqueness.rb +31 -31
- data/lib/composite_primary_keys/version.rb +8 -8
- data/lib/composite_primary_keys.rb +119 -117
- data/scripts/console.rb +48 -48
- data/scripts/txt2html +76 -76
- data/scripts/txt2js +65 -65
- data/tasks/databases/mysql.rake +40 -40
- data/tasks/databases/oracle.rake +41 -41
- data/tasks/databases/postgresql.rake +38 -38
- data/tasks/databases/sqlite.rake +25 -25
- data/tasks/databases/sqlserver.rake +43 -43
- data/tasks/website.rake +18 -18
- data/test/README_tests.rdoc +56 -56
- data/test/abstract_unit.rb +118 -114
- data/test/connections/connection_spec.rb +27 -27
- data/test/connections/databases.ci.yml +22 -22
- data/test/connections/databases.example.yml +40 -40
- data/test/connections/databases.yml +40 -39
- data/test/fixtures/article.rb +10 -10
- data/test/fixtures/articles.yml +7 -7
- data/test/fixtures/capitol.rb +3 -3
- data/test/fixtures/capitols.yml +16 -16
- data/test/fixtures/comment.rb +5 -5
- data/test/fixtures/comments.yml +17 -17
- data/test/fixtures/db_definitions/db2-create-tables.sql +112 -112
- data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -16
- data/test/fixtures/db_definitions/mysql.sql +180 -180
- data/test/fixtures/db_definitions/oracle.drop.sql +41 -41
- data/test/fixtures/db_definitions/oracle.sql +199 -199
- data/test/fixtures/db_definitions/postgresql.sql +182 -182
- data/test/fixtures/db_definitions/sqlite.sql +169 -169
- data/test/fixtures/db_definitions/sqlserver.sql +176 -176
- data/test/fixtures/department.rb +16 -16
- data/test/fixtures/departments.yml +19 -15
- data/test/fixtures/dorm.rb +2 -2
- data/test/fixtures/dorms.yml +4 -4
- data/test/fixtures/employee.rb +5 -5
- data/test/fixtures/employees.yml +33 -28
- data/test/fixtures/group.rb +2 -2
- data/test/fixtures/groups.yml +6 -6
- data/test/fixtures/membership.rb +8 -6
- data/test/fixtures/membership_status.rb +2 -2
- data/test/fixtures/membership_statuses.yml +16 -16
- data/test/fixtures/memberships.yml +10 -10
- data/test/fixtures/product.rb +9 -9
- data/test/fixtures/product_tariff.rb +5 -5
- data/test/fixtures/product_tariffs.yml +14 -14
- data/test/fixtures/products.yml +11 -11
- data/test/fixtures/reading.rb +4 -4
- data/test/fixtures/readings.yml +10 -10
- data/test/fixtures/reference_code.rb +7 -7
- data/test/fixtures/reference_codes.yml +28 -28
- data/test/fixtures/reference_type.rb +12 -12
- data/test/fixtures/reference_types.yml +9 -9
- data/test/fixtures/restaurant.rb +9 -9
- data/test/fixtures/restaurants.yml +14 -14
- data/test/fixtures/restaurants_suburb.rb +2 -2
- data/test/fixtures/restaurants_suburbs.yml +10 -10
- data/test/fixtures/room.rb +11 -11
- data/test/fixtures/room_assignment.rb +13 -13
- data/test/fixtures/room_assignments.yml +24 -24
- data/test/fixtures/room_attribute.rb +2 -2
- data/test/fixtures/room_attribute_assignment.rb +4 -4
- data/test/fixtures/room_attribute_assignments.yml +4 -4
- data/test/fixtures/room_attributes.yml +2 -2
- data/test/fixtures/rooms.yml +12 -12
- data/test/fixtures/street.rb +2 -2
- data/test/fixtures/streets.yml +16 -16
- data/test/fixtures/student.rb +3 -3
- data/test/fixtures/students.yml +15 -15
- data/test/fixtures/suburb.rb +5 -5
- data/test/fixtures/suburbs.yml +14 -14
- data/test/fixtures/tariff.rb +5 -5
- data/test/fixtures/tariffs.yml +14 -14
- data/test/fixtures/topic_sources.yml +3 -3
- data/test/fixtures/topics.yml +8 -8
- data/test/fixtures/user.rb +11 -11
- data/test/fixtures/users.yml +10 -10
- data/test/plugins/pagination.rb +405 -405
- data/test/plugins/pagination_helper.rb +135 -135
- data/test/test_associations.rb +372 -358
- data/test/test_attribute_methods.rb +63 -63
- data/test/test_attributes.rb +75 -60
- data/test/test_calculations.rb +49 -42
- data/test/test_callbacks.rb +99 -99
- data/test/test_composite_arrays.rb +38 -38
- data/test/test_counter_cache.rb +30 -30
- data/test/test_create.rb +218 -206
- data/test/test_delete.rb +188 -179
- data/test/test_dumpable.rb +15 -15
- data/test/test_dup.rb +37 -37
- data/test/test_equal.rb +26 -26
- data/test/test_exists.rb +39 -39
- data/test/test_find.rb +170 -164
- data/test/test_habtm.rb +141 -141
- data/test/test_ids.rb +112 -112
- data/test/test_miscellaneous.rb +32 -32
- data/test/test_nested_attributes.rb +67 -67
- data/test/test_optimistic.rb +18 -18
- data/test/test_pagination.rb +35 -35
- data/test/test_polymorphic.rb +43 -43
- data/test/test_predicates.rb +59 -59
- data/test/test_preload.rb +102 -102
- data/test/test_santiago.rb +23 -23
- data/test/test_touch.rb +23 -23
- data/test/test_tutorial_example.rb +25 -25
- data/test/test_update.rb +102 -96
- data/test/test_validations.rb +13 -13
- metadata +7 -6
@@ -1,117 +1,119 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2006-2016 Nic Williams and Charlie Savage
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
unless defined?(ActiveRecord)
|
25
|
-
require 'rubygems'
|
26
|
-
gem 'activerecord', '~>
|
27
|
-
require 'active_record'
|
28
|
-
end
|
29
|
-
|
30
|
-
# ActiveModel files we override
|
31
|
-
# _write_attribute
|
32
|
-
require 'active_model/attribute_assignment'
|
33
|
-
|
34
|
-
# ActiveRecord files we override
|
35
|
-
require 'active_record/attribute_methods'
|
36
|
-
require 'active_record/autosave_association'
|
37
|
-
require 'active_record/counter_cache'
|
38
|
-
require 'active_record/fixtures'
|
39
|
-
require 'active_record/model_schema'
|
40
|
-
require 'active_record/persistence'
|
41
|
-
require 'active_record/reflection'
|
42
|
-
require 'active_record/relation'
|
43
|
-
require 'active_record/sanitization'
|
44
|
-
require 'active_record/transactions'
|
45
|
-
|
46
|
-
require 'active_record/associations/association'
|
47
|
-
require 'active_record/associations/association_scope'
|
48
|
-
require 'active_record/associations/foreign_association'
|
49
|
-
require 'active_record/associations/has_many_association'
|
50
|
-
require 'active_record/associations/has_many_through_association'
|
51
|
-
require 'active_record/associations/join_dependency'
|
52
|
-
require 'active_record/associations/preloader/association'
|
53
|
-
require 'active_record/associations/singular_association'
|
54
|
-
require 'active_record/associations/collection_association'
|
55
|
-
require 'active_record/associations/through_association'
|
56
|
-
|
57
|
-
require 'active_record/attribute_methods/primary_key'
|
58
|
-
require 'active_record/attribute_methods/read'
|
59
|
-
require 'active_record/attribute_methods/write'
|
60
|
-
require 'active_record/nested_attributes'
|
61
|
-
|
62
|
-
require 'active_record/connection_adapters/abstract/database_statements'
|
63
|
-
require 'active_record/connection_adapters/abstract_adapter'
|
64
|
-
require 'active_record/connection_adapters/postgresql/database_statements'
|
65
|
-
|
66
|
-
require 'active_record/relation/where_clause'
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
require_relative 'composite_primary_keys/
|
71
|
-
require_relative 'composite_primary_keys/
|
72
|
-
require_relative 'composite_primary_keys/
|
73
|
-
require_relative 'composite_primary_keys/
|
74
|
-
require_relative 'composite_primary_keys/
|
75
|
-
require_relative 'composite_primary_keys/
|
76
|
-
require_relative 'composite_primary_keys/
|
77
|
-
require_relative 'composite_primary_keys/
|
78
|
-
require_relative 'composite_primary_keys/
|
79
|
-
require_relative 'composite_primary_keys/
|
80
|
-
require_relative 'composite_primary_keys/
|
81
|
-
require_relative 'composite_primary_keys/
|
82
|
-
require_relative 'composite_primary_keys/
|
83
|
-
require_relative 'composite_primary_keys/
|
84
|
-
|
85
|
-
|
86
|
-
require_relative 'composite_primary_keys/associations/
|
87
|
-
require_relative 'composite_primary_keys/associations/
|
88
|
-
require_relative 'composite_primary_keys/associations/
|
89
|
-
require_relative 'composite_primary_keys/associations/
|
90
|
-
require_relative 'composite_primary_keys/associations/
|
91
|
-
require_relative 'composite_primary_keys/associations/
|
92
|
-
require_relative 'composite_primary_keys/associations/
|
93
|
-
require_relative 'composite_primary_keys/associations/
|
94
|
-
|
95
|
-
|
96
|
-
require_relative 'composite_primary_keys/attribute_methods/
|
97
|
-
require_relative 'composite_primary_keys/attribute_methods/
|
98
|
-
require_relative 'composite_primary_keys/
|
99
|
-
|
100
|
-
|
101
|
-
require_relative 'composite_primary_keys/connection_adapters/
|
102
|
-
require_relative 'composite_primary_keys/connection_adapters/
|
103
|
-
require_relative 'composite_primary_keys/connection_adapters/
|
104
|
-
|
105
|
-
|
106
|
-
require_relative 'composite_primary_keys/relation/
|
107
|
-
require_relative 'composite_primary_keys/relation/
|
108
|
-
require_relative 'composite_primary_keys/relation/
|
109
|
-
require_relative 'composite_primary_keys/relation/
|
110
|
-
require_relative 'composite_primary_keys/relation/
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
require_relative 'composite_primary_keys/arel/
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2006-2016 Nic Williams and Charlie Savage
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
unless defined?(ActiveRecord)
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'activerecord', '~>7.0.0', '>= 7.0.1'
|
27
|
+
require 'active_record'
|
28
|
+
end
|
29
|
+
|
30
|
+
# ActiveModel files we override
|
31
|
+
# _write_attribute
|
32
|
+
require 'active_model/attribute_assignment'
|
33
|
+
|
34
|
+
# ActiveRecord files we override
|
35
|
+
require 'active_record/attribute_methods'
|
36
|
+
require 'active_record/autosave_association'
|
37
|
+
require 'active_record/counter_cache'
|
38
|
+
require 'active_record/fixtures'
|
39
|
+
require 'active_record/model_schema'
|
40
|
+
require 'active_record/persistence'
|
41
|
+
require 'active_record/reflection'
|
42
|
+
require 'active_record/relation'
|
43
|
+
require 'active_record/sanitization'
|
44
|
+
require 'active_record/transactions'
|
45
|
+
|
46
|
+
require 'active_record/associations/association'
|
47
|
+
require 'active_record/associations/association_scope'
|
48
|
+
require 'active_record/associations/foreign_association'
|
49
|
+
require 'active_record/associations/has_many_association'
|
50
|
+
require 'active_record/associations/has_many_through_association'
|
51
|
+
require 'active_record/associations/join_dependency'
|
52
|
+
require 'active_record/associations/preloader/association'
|
53
|
+
require 'active_record/associations/singular_association'
|
54
|
+
require 'active_record/associations/collection_association'
|
55
|
+
require 'active_record/associations/through_association'
|
56
|
+
|
57
|
+
require 'active_record/attribute_methods/primary_key'
|
58
|
+
require 'active_record/attribute_methods/read'
|
59
|
+
require 'active_record/attribute_methods/write'
|
60
|
+
require 'active_record/nested_attributes'
|
61
|
+
|
62
|
+
require 'active_record/connection_adapters/abstract/database_statements'
|
63
|
+
require 'active_record/connection_adapters/abstract_adapter'
|
64
|
+
require 'active_record/connection_adapters/postgresql/database_statements'
|
65
|
+
|
66
|
+
require 'active_record/relation/where_clause'
|
67
|
+
require 'active_record/table_metadata'
|
68
|
+
|
69
|
+
# CPK overrides
|
70
|
+
require_relative 'composite_primary_keys/active_model/attribute_assignment'
|
71
|
+
require_relative 'composite_primary_keys/attribute_methods'
|
72
|
+
require_relative 'composite_primary_keys/autosave_association'
|
73
|
+
require_relative 'composite_primary_keys/persistence'
|
74
|
+
require_relative 'composite_primary_keys/base'
|
75
|
+
require_relative 'composite_primary_keys/core'
|
76
|
+
require_relative 'composite_primary_keys/composite_arrays'
|
77
|
+
require_relative 'composite_primary_keys/composite_predicates'
|
78
|
+
require_relative 'composite_primary_keys/counter_cache'
|
79
|
+
require_relative 'composite_primary_keys/fixtures'
|
80
|
+
require_relative 'composite_primary_keys/reflection'
|
81
|
+
require_relative 'composite_primary_keys/relation'
|
82
|
+
require_relative 'composite_primary_keys/sanitization'
|
83
|
+
require_relative 'composite_primary_keys/transactions'
|
84
|
+
require_relative 'composite_primary_keys/version'
|
85
|
+
|
86
|
+
require_relative 'composite_primary_keys/associations/association'
|
87
|
+
require_relative 'composite_primary_keys/associations/association_scope'
|
88
|
+
require_relative 'composite_primary_keys/associations/foreign_association'
|
89
|
+
require_relative 'composite_primary_keys/associations/has_many_association'
|
90
|
+
require_relative 'composite_primary_keys/associations/has_many_through_association'
|
91
|
+
require_relative 'composite_primary_keys/associations/join_dependency'
|
92
|
+
require_relative 'composite_primary_keys/associations/preloader/association'
|
93
|
+
require_relative 'composite_primary_keys/associations/collection_association'
|
94
|
+
require_relative 'composite_primary_keys/associations/through_association'
|
95
|
+
|
96
|
+
require_relative 'composite_primary_keys/attribute_methods/primary_key'
|
97
|
+
require_relative 'composite_primary_keys/attribute_methods/read'
|
98
|
+
require_relative 'composite_primary_keys/attribute_methods/write'
|
99
|
+
require_relative 'composite_primary_keys/nested_attributes'
|
100
|
+
|
101
|
+
require_relative 'composite_primary_keys/connection_adapters/abstract/database_statements'
|
102
|
+
require_relative 'composite_primary_keys/connection_adapters/abstract_adapter'
|
103
|
+
require_relative 'composite_primary_keys/connection_adapters/postgresql/database_statements'
|
104
|
+
require_relative 'composite_primary_keys/connection_adapters/sqlserver/database_statements'
|
105
|
+
|
106
|
+
require_relative 'composite_primary_keys/relation/batches'
|
107
|
+
require_relative 'composite_primary_keys/relation/where_clause'
|
108
|
+
require_relative 'composite_primary_keys/relation/calculations'
|
109
|
+
require_relative 'composite_primary_keys/relation/finder_methods'
|
110
|
+
require_relative 'composite_primary_keys/relation/predicate_builder/association_query_value'
|
111
|
+
require_relative 'composite_primary_keys/relation/query_methods'
|
112
|
+
|
113
|
+
require_relative 'composite_primary_keys/validations/uniqueness'
|
114
|
+
|
115
|
+
require_relative 'composite_primary_keys/composite_relation'
|
116
|
+
|
117
|
+
require_relative 'composite_primary_keys/arel/to_sql'
|
118
|
+
require_relative 'composite_primary_keys/arel/sqlserver'
|
119
|
+
require_relative 'composite_primary_keys/table_metadata'
|
data/scripts/console.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
#
|
4
|
-
# if run as script, load the file as library while starting irb
|
5
|
-
#
|
6
|
-
if __FILE__ == $0
|
7
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
8
|
-
ENV['ADAPTER'] = ARGV[0]
|
9
|
-
exec "#{irb} -f -r #{$0} --simple-prompt"
|
10
|
-
end
|
11
|
-
|
12
|
-
#
|
13
|
-
# check if the given adapter is supported (default: mysql)
|
14
|
-
#
|
15
|
-
adapters = %w[mysql sqlite oracle oracle_enhanced postgresql ibm_db]
|
16
|
-
adapter = ENV['ADAPTER'] || 'mysql'
|
17
|
-
unless adapters.include? adapter
|
18
|
-
puts "Usage: #{__FILE__} <adapter>"
|
19
|
-
puts ''
|
20
|
-
puts 'Adapters: '
|
21
|
-
puts adapters.map{ |adapter| " #{adapter}" }.join("\n")
|
22
|
-
exit 1
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# load all necessary libraries
|
27
|
-
#
|
28
|
-
require 'rubygems'
|
29
|
-
require 'local/database_connections'
|
30
|
-
|
31
|
-
$LOAD_PATH.unshift 'lib'
|
32
|
-
|
33
|
-
begin
|
34
|
-
require 'local/paths'
|
35
|
-
$LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/active_record/lib" if ENV['EDGE_RAILS_DIR']
|
36
|
-
$LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/activesupport/lib" if ENV['EDGE_RAILS_DIR']
|
37
|
-
rescue
|
38
|
-
end
|
39
|
-
|
40
|
-
require 'active_support'
|
41
|
-
require 'active_record'
|
42
|
-
|
43
|
-
require "test/connections/native_#{adapter}/connection"
|
44
|
-
require 'composite_primary_keys'
|
45
|
-
|
46
|
-
PROJECT_ROOT = File.join(File.dirname(__FILE__), '..')
|
47
|
-
Dir[File.join(PROJECT_ROOT,'test/fixtures/*.rb')].each { |model| require model }
|
48
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# if run as script, load the file as library while starting irb
|
5
|
+
#
|
6
|
+
if __FILE__ == $0
|
7
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
8
|
+
ENV['ADAPTER'] = ARGV[0]
|
9
|
+
exec "#{irb} -f -r #{$0} --simple-prompt"
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# check if the given adapter is supported (default: mysql)
|
14
|
+
#
|
15
|
+
adapters = %w[mysql sqlite oracle oracle_enhanced postgresql ibm_db]
|
16
|
+
adapter = ENV['ADAPTER'] || 'mysql'
|
17
|
+
unless adapters.include? adapter
|
18
|
+
puts "Usage: #{__FILE__} <adapter>"
|
19
|
+
puts ''
|
20
|
+
puts 'Adapters: '
|
21
|
+
puts adapters.map{ |adapter| " #{adapter}" }.join("\n")
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# load all necessary libraries
|
27
|
+
#
|
28
|
+
require 'rubygems'
|
29
|
+
require 'local/database_connections'
|
30
|
+
|
31
|
+
$LOAD_PATH.unshift 'lib'
|
32
|
+
|
33
|
+
begin
|
34
|
+
require 'local/paths'
|
35
|
+
$LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/active_record/lib" if ENV['EDGE_RAILS_DIR']
|
36
|
+
$LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/activesupport/lib" if ENV['EDGE_RAILS_DIR']
|
37
|
+
rescue
|
38
|
+
end
|
39
|
+
|
40
|
+
require 'active_support'
|
41
|
+
require 'active_record'
|
42
|
+
|
43
|
+
require "test/connections/native_#{adapter}/connection"
|
44
|
+
require 'composite_primary_keys'
|
45
|
+
|
46
|
+
PROJECT_ROOT = File.join(File.dirname(__FILE__), '..')
|
47
|
+
Dir[File.join(PROJECT_ROOT,'test/fixtures/*.rb')].each { |model| require model }
|
48
|
+
|
data/scripts/txt2html
CHANGED
@@ -1,76 +1,76 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
gem 'RedCloth'
|
5
|
-
gem 'syntax'
|
6
|
-
|
7
|
-
require 'redcloth'
|
8
|
-
require 'syntax/convertors/html'
|
9
|
-
require 'erb'
|
10
|
-
|
11
|
-
version_path = File.join(File.dirname(__FILE__), '..', 'lib', 'composite_primary_keys', 'version.rb')
|
12
|
-
require File.expand_path(version_path)
|
13
|
-
|
14
|
-
version = CompositePrimaryKeys::VERSION::STRING
|
15
|
-
download = 'http://rubygems.org/gems/composite_primary_keys'
|
16
|
-
|
17
|
-
class Fixnum
|
18
|
-
def ordinal
|
19
|
-
# teens
|
20
|
-
return 'th' if (10..19).include?(self % 100)
|
21
|
-
# others
|
22
|
-
case self % 10
|
23
|
-
when 1
|
24
|
-
return 'st'
|
25
|
-
when 2
|
26
|
-
return 'nd'
|
27
|
-
when 3
|
28
|
-
return 'rd'
|
29
|
-
else
|
30
|
-
return 'th'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Time
|
36
|
-
def pretty
|
37
|
-
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def convert_syntax(syntax, source)
|
42
|
-
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
43
|
-
end
|
44
|
-
|
45
|
-
if ARGV.length >= 1
|
46
|
-
src, template = ARGV
|
47
|
-
template ||= File.dirname(__FILE__) + '/../website/template.rhtml'
|
48
|
-
|
49
|
-
else
|
50
|
-
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
51
|
-
exit!
|
52
|
-
end
|
53
|
-
|
54
|
-
template = ERB.new(File.open(template).read)
|
55
|
-
|
56
|
-
title = nil
|
57
|
-
body = nil
|
58
|
-
File.open(src) do |fsrc|
|
59
|
-
title_text = fsrc.readline
|
60
|
-
body_text = fsrc.read
|
61
|
-
syntax_items = []
|
62
|
-
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
63
|
-
ident = syntax_items.length
|
64
|
-
element, syntax, source = $1, $2, $3
|
65
|
-
syntax_items << "<#{element} class=\"syntax\">#{convert_syntax(syntax, source)}</#{element}>"
|
66
|
-
"syntax-temp-#{ident}"
|
67
|
-
}
|
68
|
-
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
69
|
-
body = RedCloth.new(body_text).to_html
|
70
|
-
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
71
|
-
end
|
72
|
-
stat = File.stat(src)
|
73
|
-
created = stat.ctime
|
74
|
-
modified = stat.mtime
|
75
|
-
|
76
|
-
$stdout << template.result(binding)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'RedCloth'
|
5
|
+
gem 'syntax'
|
6
|
+
|
7
|
+
require 'redcloth'
|
8
|
+
require 'syntax/convertors/html'
|
9
|
+
require 'erb'
|
10
|
+
|
11
|
+
version_path = File.join(File.dirname(__FILE__), '..', 'lib', 'composite_primary_keys', 'version.rb')
|
12
|
+
require File.expand_path(version_path)
|
13
|
+
|
14
|
+
version = CompositePrimaryKeys::VERSION::STRING
|
15
|
+
download = 'http://rubygems.org/gems/composite_primary_keys'
|
16
|
+
|
17
|
+
class Fixnum
|
18
|
+
def ordinal
|
19
|
+
# teens
|
20
|
+
return 'th' if (10..19).include?(self % 100)
|
21
|
+
# others
|
22
|
+
case self % 10
|
23
|
+
when 1
|
24
|
+
return 'st'
|
25
|
+
when 2
|
26
|
+
return 'nd'
|
27
|
+
when 3
|
28
|
+
return 'rd'
|
29
|
+
else
|
30
|
+
return 'th'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Time
|
36
|
+
def pretty
|
37
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def convert_syntax(syntax, source)
|
42
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
43
|
+
end
|
44
|
+
|
45
|
+
if ARGV.length >= 1
|
46
|
+
src, template = ARGV
|
47
|
+
template ||= File.dirname(__FILE__) + '/../website/template.rhtml'
|
48
|
+
|
49
|
+
else
|
50
|
+
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
51
|
+
exit!
|
52
|
+
end
|
53
|
+
|
54
|
+
template = ERB.new(File.open(template).read)
|
55
|
+
|
56
|
+
title = nil
|
57
|
+
body = nil
|
58
|
+
File.open(src) do |fsrc|
|
59
|
+
title_text = fsrc.readline
|
60
|
+
body_text = fsrc.read
|
61
|
+
syntax_items = []
|
62
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
63
|
+
ident = syntax_items.length
|
64
|
+
element, syntax, source = $1, $2, $3
|
65
|
+
syntax_items << "<#{element} class=\"syntax\">#{convert_syntax(syntax, source)}</#{element}>"
|
66
|
+
"syntax-temp-#{ident}"
|
67
|
+
}
|
68
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
69
|
+
body = RedCloth.new(body_text).to_html
|
70
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
71
|
+
end
|
72
|
+
stat = File.stat(src)
|
73
|
+
created = stat.ctime
|
74
|
+
modified = stat.mtime
|
75
|
+
|
76
|
+
$stdout << template.result(binding)
|
data/scripts/txt2js
CHANGED
@@ -1,65 +1,65 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'redcloth'
|
5
|
-
require 'syntax/convertors/html'
|
6
|
-
require 'erb'
|
7
|
-
require 'active_support'
|
8
|
-
|
9
|
-
version_path = File.join(File.dirname(__FILE__), '..', 'lib', 'composite_primary_keys', 'version.rb')
|
10
|
-
require File.expand_path(version_path)
|
11
|
-
|
12
|
-
version = CompositePrimaryKeys::VERSION::STRING
|
13
|
-
download = 'http://rubygems.org/gems/composite_primary_keys'
|
14
|
-
|
15
|
-
class Fixnum
|
16
|
-
def ordinal
|
17
|
-
# teens
|
18
|
-
return 'th' if (10..19).include?(self % 100)
|
19
|
-
# others
|
20
|
-
case self % 10
|
21
|
-
when 1
|
22
|
-
return 'st'
|
23
|
-
when 2
|
24
|
-
return 'nd'
|
25
|
-
when 3
|
26
|
-
return 'rd'
|
27
|
-
else
|
28
|
-
return 'th'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class Time
|
34
|
-
def pretty
|
35
|
-
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def convert_syntax(syntax, source)
|
40
|
-
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
41
|
-
end
|
42
|
-
|
43
|
-
if ARGV.length >= 1
|
44
|
-
src, template = ARGV
|
45
|
-
template ||= File.dirname(__FILE__) + '/../website/template.js'
|
46
|
-
else
|
47
|
-
puts("Usage: #{File.split($0).last} source.txt [template.js] > output.html")
|
48
|
-
exit!
|
49
|
-
end
|
50
|
-
|
51
|
-
template = ERB.new(File.open(template).read)
|
52
|
-
|
53
|
-
title = nil
|
54
|
-
body = nil
|
55
|
-
File.open(src) do |fsrc|
|
56
|
-
title_text = fsrc.readline
|
57
|
-
body_text = fsrc.read
|
58
|
-
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
59
|
-
body = RedCloth.new(body_text)
|
60
|
-
end
|
61
|
-
stat = File.stat(src)
|
62
|
-
created = stat.ctime
|
63
|
-
modified = stat.mtime
|
64
|
-
|
65
|
-
$stdout << template.result(binding)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'redcloth'
|
5
|
+
require 'syntax/convertors/html'
|
6
|
+
require 'erb'
|
7
|
+
require 'active_support'
|
8
|
+
|
9
|
+
version_path = File.join(File.dirname(__FILE__), '..', 'lib', 'composite_primary_keys', 'version.rb')
|
10
|
+
require File.expand_path(version_path)
|
11
|
+
|
12
|
+
version = CompositePrimaryKeys::VERSION::STRING
|
13
|
+
download = 'http://rubygems.org/gems/composite_primary_keys'
|
14
|
+
|
15
|
+
class Fixnum
|
16
|
+
def ordinal
|
17
|
+
# teens
|
18
|
+
return 'th' if (10..19).include?(self % 100)
|
19
|
+
# others
|
20
|
+
case self % 10
|
21
|
+
when 1
|
22
|
+
return 'st'
|
23
|
+
when 2
|
24
|
+
return 'nd'
|
25
|
+
when 3
|
26
|
+
return 'rd'
|
27
|
+
else
|
28
|
+
return 'th'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Time
|
34
|
+
def pretty
|
35
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def convert_syntax(syntax, source)
|
40
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
41
|
+
end
|
42
|
+
|
43
|
+
if ARGV.length >= 1
|
44
|
+
src, template = ARGV
|
45
|
+
template ||= File.dirname(__FILE__) + '/../website/template.js'
|
46
|
+
else
|
47
|
+
puts("Usage: #{File.split($0).last} source.txt [template.js] > output.html")
|
48
|
+
exit!
|
49
|
+
end
|
50
|
+
|
51
|
+
template = ERB.new(File.open(template).read)
|
52
|
+
|
53
|
+
title = nil
|
54
|
+
body = nil
|
55
|
+
File.open(src) do |fsrc|
|
56
|
+
title_text = fsrc.readline
|
57
|
+
body_text = fsrc.read
|
58
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
59
|
+
body = RedCloth.new(body_text)
|
60
|
+
end
|
61
|
+
stat = File.stat(src)
|
62
|
+
created = stat.ctime
|
63
|
+
modified = stat.mtime
|
64
|
+
|
65
|
+
$stdout << template.result(binding)
|