caboose-cms 0.3.98 → 0.3.99
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +39 -9
- metadata +2 -3
- data/lib/tasks/sequences.rake +0 -27
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODE5YzA0ZjBiY2RmYjhhNGZhMDhjMGM5YTFjOTIxOGZhM2NmZGJmOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjE4Mzc0MmM2ZmVlNjk1ZGNmNzc5ZWIyMjNiOGJjY2NjOTY2Y2Q5Ng==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTVlMmM0MTU0ZGFlZGY5MjRhNjlmMWViNjc3MWUxMmZhYjc1OTM4MTQ4MjU5
|
10
|
+
ZmE1YzQwMWQxMzJlNzZmODYxMzExMjA4NWY0Mzk3OGViMTg5ODdjMWQyZjZk
|
11
|
+
OThkZTVjYmYxNTAxZmFiMjAzMDM5MWE2MWNmOTAzMDY0YjBlODk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWU2YjZkZjcwMDVhOTJkZWY5MDRhNDU1Y2FlMjFiMzZiZGYwYTFmM2ZjYjYw
|
14
|
+
ZmY3MTQ0YzUzZjAzMGY5ZDA1OGM0YTY4NGJiNWYzYzcxYzJkMjBjOTg5M2Zh
|
15
|
+
MjU3OTk0NDg1NDRmYTZhOGM3NjNjZmI4MzVmYjhiMzllMzY3N2M=
|
data/lib/caboose/version.rb
CHANGED
data/lib/tasks/caboose.rake
CHANGED
@@ -11,6 +11,7 @@ namespace :caboose do
|
|
11
11
|
Schema.create_schema
|
12
12
|
Schema.load_data
|
13
13
|
end
|
14
|
+
caboose_correct_sequences
|
14
15
|
end
|
15
16
|
|
16
17
|
desc "Creates all caboose tables"
|
@@ -18,16 +19,12 @@ namespace :caboose do
|
|
18
19
|
|
19
20
|
desc "Loads data into caboose tables"
|
20
21
|
task :load_data => :environment do Caboose::Schema.load_data end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
klass = Module.const_get(class_name)
|
26
|
-
return klass.is_a?(Class)
|
27
|
-
rescue NameError
|
28
|
-
return false
|
22
|
+
|
23
|
+
desc "Corrects any sequences in tables"
|
24
|
+
task :correct_sequences => :environment do
|
25
|
+
caboose_correct_sequences
|
29
26
|
end
|
30
|
-
|
27
|
+
|
31
28
|
desc "Resets the admin password to 'caboose'"
|
32
29
|
task :reset_admin_pass => :environment do
|
33
30
|
admin_user = Caboose::User.where(username: 'admin').first
|
@@ -87,6 +84,39 @@ namespace :caboose do
|
|
87
84
|
end
|
88
85
|
end
|
89
86
|
|
87
|
+
#=============================================================================
|
88
|
+
|
89
|
+
def class_exists?(class_name)
|
90
|
+
klass = Module.const_get(class_name)
|
91
|
+
return klass.is_a?(Class)
|
92
|
+
rescue NameError
|
93
|
+
return false
|
94
|
+
end
|
95
|
+
|
96
|
+
# Corrects any sequences in tables
|
97
|
+
def caboose_correct_sequences
|
98
|
+
c = ActiveRecord::Base.connection
|
99
|
+
c.tables.each do |tbl|
|
100
|
+
next if !c.column_exists? tbl, :id
|
101
|
+
|
102
|
+
rows = c.execute("select max(id) from #{tbl}")
|
103
|
+
max = rows[0]['max']
|
104
|
+
max = max.to_i if !max.nil?
|
105
|
+
|
106
|
+
rows = c.execute("select nextval('#{tbl}_id_seq')")
|
107
|
+
nextval = rows[0]['nextval']
|
108
|
+
nextval = nextval.to_i if !nextval.nil?
|
109
|
+
|
110
|
+
next if max.nil? || nextval.nil?
|
111
|
+
next if nextval >= max
|
112
|
+
|
113
|
+
# If nextval is lower than the max id, then fix it.
|
114
|
+
puts "Correcting sequence for #{tbl}..."
|
115
|
+
c.execute("select setval('#{tbl}_id_seq', (select max(id) from #{tbl}))")
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
90
120
|
end
|
91
121
|
|
92
122
|
namespace :assets do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.99
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -397,7 +397,6 @@ files:
|
|
397
397
|
- lib/sample_files/timezone_abbreviations.csv
|
398
398
|
- lib/sample_files/tinymce.yml
|
399
399
|
- lib/tasks/caboose.rake
|
400
|
-
- lib/tasks/sequences.rake
|
401
400
|
- MIT-LICENSE
|
402
401
|
- Rakefile
|
403
402
|
- README.md
|
data/lib/tasks/sequences.rake
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
namespace :caboose do
|
3
|
-
desc "Corrects any sequences in tables"
|
4
|
-
task :correct_sequences => :environment do
|
5
|
-
|
6
|
-
c = ActiveRecord::Base.connection
|
7
|
-
c.tables.each do |tbl|
|
8
|
-
next if !c.column_exists? tbl, :id
|
9
|
-
|
10
|
-
rows = c.execute("select max(id) from #{tbl}")
|
11
|
-
max = rows[0]['max']
|
12
|
-
max = max.to_i if !max.nil?
|
13
|
-
|
14
|
-
rows = c.execute("select nextval('#{tbl}_id_seq')")
|
15
|
-
nextval = rows[0]['nextval']
|
16
|
-
nextval = nextval.to_i if !nextval.nil?
|
17
|
-
|
18
|
-
next if max.nil? || nextval.nil?
|
19
|
-
next if nextval >= max
|
20
|
-
|
21
|
-
# If nextval is lower than the max id, then fix it.
|
22
|
-
puts "Correcting sequence for #{tbl}..."
|
23
|
-
c.execute("select setval('#{tbl}_id_seq', (select max(id) from #{tbl}))")
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|