caboose-cms 0.2.94 → 0.2.95
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/models/caboose/page_bar_generator.rb +7 -1
- data/lib/caboose/engine.rb +39 -16
- data/lib/caboose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTk4NzgwZDZiMDIyOGM5ZDhlMDY3YmMwYTE1MjIxZGQ0ZDA3ODA0NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODcwMTk0ZWZkOWUyNDRmOTM2YzRlYmY2MDYxMjA0YzE3ZDAxNzdhZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWJkMGQ0ZjkyMTljM2NjZTA2M2MxYTgwYjRhNjZkYmNjMTk0MjEwOGY5Mzc1
|
10
|
+
ZGVhMzQ3NjRlNDhkZTQwMWMwMTI4ZmU4ZmFkZDE3OTg3MjQ4MjAyOTdmNjVi
|
11
|
+
NGEzMTQzNWY1MWNkY2U2NGFkYjM2ZGEyMjNkMTVjYzNiOGQ3Yjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGQ1NDkxYzE4NTIzMDM1ZWMwYzU2YzFkZTZlMTc0NTJmYTU3NmI5NzE0YzNh
|
14
|
+
M2U3YTZiM2YwNzcwNTkyZTM4YzI2MmZlN2U3M2NiZDY3ZTNkODIxNzVjY2Iy
|
15
|
+
MjdkY2VkZDU3N2I5YjA5YTNmODI3OTcxMmUwNTA1YTRmMjQ3MDU=
|
@@ -132,7 +132,13 @@ module Caboose
|
|
132
132
|
def get_vars()
|
133
133
|
vars = []
|
134
134
|
@params.each do |k,v|
|
135
|
-
|
135
|
+
if v.kind_of?(Array)
|
136
|
+
v.each do |v2|
|
137
|
+
vars.push("#{k}[]=#{v2}") if !v2.nil? && v2.length > 0
|
138
|
+
end
|
139
|
+
else
|
140
|
+
vars.push("#{k}=#{v}") if !v.nil? && v.length > 0
|
141
|
+
end
|
136
142
|
end
|
137
143
|
return URI.escape(vars.join('&'))
|
138
144
|
end
|
data/lib/caboose/engine.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
|
2
2
|
require 'tinymce-rails'
|
3
3
|
require 'jquery-ui-rails'
|
4
|
-
#require 'modeljs'
|
5
4
|
require 'colorbox-rails'
|
6
5
|
require 'paperclip'
|
7
6
|
|
@@ -49,29 +48,53 @@ module Caboose
|
|
49
48
|
return obj.to_json
|
50
49
|
end
|
51
50
|
|
52
|
-
|
51
|
+
# Verifies (non-destructively) that the given schema exists in the database.
|
52
|
+
def Caboose.create_schema(schema)
|
53
53
|
c = ActiveRecord::Base.connection
|
54
|
-
|
55
|
-
|
56
|
-
c.create_table
|
57
|
-
columns.each do |col|
|
54
|
+
schema.each do |model, columns|
|
55
|
+
tbl = model.table_name
|
56
|
+
c.create_table tbl if !c.table_exists?(tbl)
|
57
|
+
columns.each do |col|
|
58
58
|
|
59
59
|
# Skip if the column exists with the proper data type
|
60
|
-
next if c.column_exists?(
|
60
|
+
next if c.column_exists?(tbl, col[0], col[1])
|
61
61
|
|
62
|
-
# If the column exists,
|
63
|
-
if c.column_exists?(
|
62
|
+
# If the column doesn't exists, add it
|
63
|
+
if !c.column_exists?(tbl, col[0])
|
64
64
|
if col.count > 2
|
65
|
-
c.
|
65
|
+
c.add_column tbl, col[0], col[1], col[2]
|
66
66
|
else
|
67
|
-
c.
|
67
|
+
c.add_column tbl, col[0], col[1]
|
68
68
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
|
70
|
+
# Column exists, but not with the correct data type, try to change it
|
71
|
+
else
|
72
|
+
|
73
|
+
# Add a temp column
|
74
|
+
if col.count > 2
|
75
|
+
c.add_column tbl, "#{col[0]}_temp", col[1], col[2]
|
76
|
+
else
|
77
|
+
c.add_column tbl, "#{col[0]}_temp", col[1]
|
74
78
|
end
|
79
|
+
|
80
|
+
# Copy the old column and cast with correct data type to the new column
|
81
|
+
model.all.each do |m|
|
82
|
+
m["#{col[0]}_temp"] = case col[1]
|
83
|
+
when :integer then m[col[0]].to_i
|
84
|
+
when :string then m[col[0]].to_s
|
85
|
+
when :text then m[col[0]].to_s
|
86
|
+
when :numeric then m[col[0]].to_f
|
87
|
+
when :datetime then DateTime.parse(m[col[0]])
|
88
|
+
when :boolean then m[col[0]].to_i == 1
|
89
|
+
else nil
|
90
|
+
end
|
91
|
+
m.save
|
92
|
+
end
|
93
|
+
|
94
|
+
# Remove the old column and rename the new one
|
95
|
+
c.remove_column tbl, col[0]
|
96
|
+
c.rename_column tbl, "#{col[0]}_temp", col[0]
|
97
|
+
|
75
98
|
end
|
76
99
|
end
|
77
100
|
end
|
data/lib/caboose/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.95
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|