comfortable_mexican_sofa 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/comfortable_mexican_sofa.gemspec +2 -2
- data/lib/tasks/comfortable_mexican_sofa.rake +121 -19
- data/test/integration/rake_tasks_test.rb +12 -6
- metadata +4 -4
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.20
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{comfortable_mexican_sofa}
|
|
8
|
-
s.version = "1.0.
|
|
8
|
+
s.version = "1.0.20"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Oleg Khabarov", "The Working Group Inc"]
|
|
12
|
-
s.date = %q{2010-11-
|
|
12
|
+
s.date = %q{2010-11-12}
|
|
13
13
|
s.description = %q{}
|
|
14
14
|
s.email = %q{oleg@theworkinggroup.ca}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
namespace :comfortable_mexican_sofa do
|
|
2
2
|
|
|
3
|
+
# Example use:
|
|
4
|
+
# rake comfortable_mexican_sofa:import:all FROM=mysite.local TO=mysite.com PATH=/path/to/seed_data
|
|
3
5
|
namespace :import do
|
|
4
6
|
|
|
5
7
|
task :check_for_requirements => :environment do |task, args|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
@from = args[:from].present?? args[:from] : nil
|
|
9
|
+
@site = args[:to].present?? args[:to] : nil
|
|
10
|
+
@seed_path = (args[:seeds].present?? args[:seeds] : nil) || ComfortableMexicanSofa.config.seed_data_path
|
|
11
|
+
|
|
12
|
+
if !@seed_path
|
|
13
|
+
abort 'PATH is not set. Please define where cms fixtures are located.'
|
|
14
|
+
end
|
|
15
|
+
unless File.exists?((@from && @seed_path = "#{@seed_path}/#{@from}").to_s)
|
|
16
|
+
abort "FROM is not properly set. Cannot find fixtures in '#{@seed_path}'"
|
|
8
17
|
end
|
|
9
|
-
if !(@site = CmsSite.find_by_hostname(args[:
|
|
10
|
-
abort
|
|
18
|
+
if !(@site = CmsSite.find_by_hostname(args[:to]))
|
|
19
|
+
abort "TO is not properly set. Cannot find site with hostname '#{args[:to]}'"
|
|
11
20
|
end
|
|
12
|
-
puts "Starting import into #{@site.label} (#{@site.hostname})
|
|
21
|
+
puts "Starting import into #{@site.label} (#{@site.hostname}) from '#{@seed_path}'"
|
|
13
22
|
end
|
|
14
23
|
|
|
15
24
|
desc 'Import layouts into database'
|
|
16
25
|
task :layouts => [:environment, :check_for_requirements] do |task, args|
|
|
17
|
-
puts 'Importing Layouts
|
|
18
|
-
|
|
26
|
+
puts 'Importing Layouts'
|
|
27
|
+
puts '-----------------'
|
|
28
|
+
layouts = Dir.glob(File.expand_path('layouts/*.yml', @seed_path)).collect do |layout_file_path|
|
|
19
29
|
attributes = YAML.load_file(layout_file_path).symbolize_keys!
|
|
20
30
|
@site.cms_layouts.load_for_slug!(@site, attributes[:slug])
|
|
21
31
|
end
|
|
@@ -39,8 +49,8 @@ namespace :comfortable_mexican_sofa do
|
|
|
39
49
|
existing_layout.attributes = layout.attributes.slice('label', 'content', 'css', 'js')
|
|
40
50
|
layout = existing_layout
|
|
41
51
|
end
|
|
52
|
+
puts "Saving layout: #{layout.label} (#{layout.slug})"
|
|
42
53
|
layout.save!
|
|
43
|
-
puts "Saved layout: #{layout.label} (#{layout.slug})"
|
|
44
54
|
else
|
|
45
55
|
puts "Skipping layout: #{layout.label} (#{layout.slug})"
|
|
46
56
|
end
|
|
@@ -53,8 +63,9 @@ namespace :comfortable_mexican_sofa do
|
|
|
53
63
|
|
|
54
64
|
desc 'Import pages into database'
|
|
55
65
|
task :pages => [:environment, :check_for_requirements] do |task, args|
|
|
56
|
-
puts 'Importing Pages
|
|
57
|
-
|
|
66
|
+
puts 'Importing Pages'
|
|
67
|
+
puts '---------------'
|
|
68
|
+
pages = Dir.glob(File.expand_path('pages/**/*.yml', @seed_path)).collect do |page_file_path|
|
|
58
69
|
attributes = YAML.load_file(page_file_path).symbolize_keys!
|
|
59
70
|
@site.cms_pages.load_for_full_path!(@site, attributes[:full_path])
|
|
60
71
|
end
|
|
@@ -87,10 +98,10 @@ namespace :comfortable_mexican_sofa do
|
|
|
87
98
|
existing_page.cms_blocks_attributes = attrs
|
|
88
99
|
page = existing_page
|
|
89
100
|
end
|
|
101
|
+
puts "... Saving page: #{page.label} (#{page.full_path})"
|
|
90
102
|
page.save!
|
|
91
|
-
puts "Saved page: #{page.label} (#{page.full_path})"
|
|
92
103
|
else
|
|
93
|
-
puts "Skipping page: #{page.label} (#{page.full_path})"
|
|
104
|
+
puts "... Skipping page: #{page.label} (#{page.full_path})"
|
|
94
105
|
end
|
|
95
106
|
else
|
|
96
107
|
pages.push page
|
|
@@ -101,8 +112,9 @@ namespace :comfortable_mexican_sofa do
|
|
|
101
112
|
|
|
102
113
|
desc 'Import snippets into database'
|
|
103
114
|
task :snippets => [:environment, :check_for_requirements] do |task, args|
|
|
104
|
-
puts 'Importing Snippets
|
|
105
|
-
|
|
115
|
+
puts 'Importing Snippets'
|
|
116
|
+
puts '------------------'
|
|
117
|
+
snippets = Dir.glob(File.expand_path('snippets/*.yml', @seed_path)).collect do |snippet_file_path|
|
|
106
118
|
attributes = YAML.load_file(snippet_file_path).symbolize_keys!
|
|
107
119
|
@site.cms_snippets.load_for_slug!(@site, attributes[:slug])
|
|
108
120
|
end
|
|
@@ -119,10 +131,10 @@ namespace :comfortable_mexican_sofa do
|
|
|
119
131
|
existing_snippet.attributes = snippet.attributes.slice('label', 'content')
|
|
120
132
|
snippet = existing_snippet
|
|
121
133
|
end
|
|
134
|
+
puts "... Saving snippet: #{snippet.label} (#{snippet.slug})"
|
|
122
135
|
snippet.save!
|
|
123
|
-
puts "Saved snippet: #{snippet.label} (#{snippet.slug})"
|
|
124
136
|
else
|
|
125
|
-
puts "Skipping snippet: #{snippet.label} (#{snippet.slug})"
|
|
137
|
+
puts "... Skipping snippet: #{snippet.label} (#{snippet.slug})"
|
|
126
138
|
end
|
|
127
139
|
end
|
|
128
140
|
end
|
|
@@ -133,21 +145,111 @@ namespace :comfortable_mexican_sofa do
|
|
|
133
145
|
|
|
134
146
|
end
|
|
135
147
|
|
|
148
|
+
# Example use:
|
|
149
|
+
# rake comfortable_mexican_sofa:import:all FROM=mysite.com TO=mysite.local PATH=/path/to/seed_data
|
|
136
150
|
namespace :export do
|
|
137
151
|
|
|
152
|
+
task :check_for_requirements => :environment do |task, args|
|
|
153
|
+
@site = args[:from].present?? args[:from] : nil
|
|
154
|
+
@to = args[:to].present?? args[:to] : nil
|
|
155
|
+
@seed_path = (args[:seeds].present?? args[:seeds] : nil) || ComfortableMexicanSofa.config.seed_data_path
|
|
156
|
+
|
|
157
|
+
if !@seed_path
|
|
158
|
+
abort 'PATH is not set. Please define where cms fixtures are located.'
|
|
159
|
+
end
|
|
160
|
+
if !(@site = CmsSite.find_by_hostname(args[:from]))
|
|
161
|
+
abort "FROM is not properly set. Cannot find site with hostname '#{args[:from]}'"
|
|
162
|
+
end
|
|
163
|
+
unless @to && @seed_path = "#{@seed_path}/#{@to}"
|
|
164
|
+
abort "TO is not properly set. What's the target hostname?"
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
FileUtils.mkdir_p @seed_path
|
|
168
|
+
FileUtils.mkdir_p "#{@seed_path}/layouts"
|
|
169
|
+
FileUtils.mkdir_p "#{@seed_path}/pages"
|
|
170
|
+
FileUtils.mkdir_p "#{@seed_path}/snippets"
|
|
171
|
+
|
|
172
|
+
puts "Starting export from #{@site.label} (#{@site.hostname}) to '#{@seed_path}'"
|
|
173
|
+
end
|
|
174
|
+
|
|
138
175
|
desc 'Export layouts to yaml files'
|
|
139
176
|
task :layouts => [:environment, :check_for_requirements] do |task, args|
|
|
140
|
-
|
|
177
|
+
puts 'Exporting Layouts'
|
|
178
|
+
puts '-----------------'
|
|
179
|
+
CmsLayout.all.each do |layout|
|
|
180
|
+
should_write = true
|
|
181
|
+
file_path = File.join(@seed_path, 'layouts', "#{layout.slug}.yml")
|
|
182
|
+
if File.exists?(file_path)
|
|
183
|
+
print "Found layout fixture: #{file_path} Overwrite? (yN): "
|
|
184
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
|
185
|
+
end
|
|
186
|
+
if should_write
|
|
187
|
+
attributes = layout.attributes.slice('label', 'slug', 'content', 'css', 'js')
|
|
188
|
+
attributes['parent'] = layout.parent.slug if layout.parent
|
|
189
|
+
open(file_path, 'w') do |f|
|
|
190
|
+
f.write(attributes.to_yaml)
|
|
191
|
+
end
|
|
192
|
+
puts "... Saving layout: #{layout.label} (#{layout.slug})"
|
|
193
|
+
else
|
|
194
|
+
puts "... Skipping layout: #{layout.label} (#{layout.slug})"
|
|
195
|
+
end
|
|
196
|
+
end
|
|
141
197
|
end
|
|
142
198
|
|
|
143
199
|
desc 'Export pages to yaml files'
|
|
144
200
|
task :pages => [:environment, :check_for_requirements] do |task, args|
|
|
145
|
-
|
|
201
|
+
puts 'Exporting Pages'
|
|
202
|
+
puts '---------------'
|
|
203
|
+
CmsPage.all.each do |page|
|
|
204
|
+
should_write = true
|
|
205
|
+
page_name = page.full_path.split('/').last || 'index'
|
|
206
|
+
page_path = (p = page.full_path.split('/')) && p.pop && p.join('/')
|
|
207
|
+
|
|
208
|
+
FileUtils.mkdir_p "#{@seed_path}/pages/#{page_path}"
|
|
209
|
+
file_path = File.join(@seed_path, 'pages', "#{page_path}/#{page_name}.yml")
|
|
210
|
+
|
|
211
|
+
if File.exists?(file_path)
|
|
212
|
+
print "Found page fixture: #{file_path} Overwrite? (yN): "
|
|
213
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
|
214
|
+
end
|
|
215
|
+
if should_write
|
|
216
|
+
|
|
217
|
+
attributes = page.attributes.slice('label', 'slug', 'full_path')
|
|
218
|
+
attributes['parent'] = page.parent.full_path if page.parent
|
|
219
|
+
attributes['cms_layout'] = page.cms_layout.slug
|
|
220
|
+
attributes['cms_blocks_attributes'] = page.cms_blocks_attributes.collect{|b| b.delete(:id) && b.stringify_keys}
|
|
221
|
+
|
|
222
|
+
open(file_path, 'w') do |f|
|
|
223
|
+
f.write(attributes.to_yaml)
|
|
224
|
+
end
|
|
225
|
+
puts "... Saving page: #{page.label} (#{page.full_path})"
|
|
226
|
+
else
|
|
227
|
+
puts "... Skipping page: #{page.label} (#{page.full_path})"
|
|
228
|
+
end
|
|
229
|
+
end
|
|
146
230
|
end
|
|
147
231
|
|
|
148
232
|
desc 'Export snippets to yaml files'
|
|
149
233
|
task :snippets => [:environment, :check_for_requirements] do |task, args|
|
|
150
|
-
|
|
234
|
+
puts 'Exporting Snippets'
|
|
235
|
+
puts '------------------'
|
|
236
|
+
CmsSnippet.all.each do |snippet|
|
|
237
|
+
should_write = true
|
|
238
|
+
file_path = File.join(@seed_path, 'snippets', "#{snippet.slug}.yml")
|
|
239
|
+
if File.exists?(file_path)
|
|
240
|
+
print "Found snippet fixture: #{file_path} Overwrite? (yN): "
|
|
241
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
|
242
|
+
end
|
|
243
|
+
if should_write
|
|
244
|
+
attributes = snippet.attributes.slice('label', 'slug', 'content')
|
|
245
|
+
open(file_path, 'w') do |f|
|
|
246
|
+
f.write(attributes.to_yaml)
|
|
247
|
+
end
|
|
248
|
+
puts "... Saving snippet: #{snippet.label} (#{snippet.slug})"
|
|
249
|
+
else
|
|
250
|
+
puts "... Skipping snippet: #{snippet.label} (#{snippet.slug})"
|
|
251
|
+
end
|
|
252
|
+
end
|
|
151
253
|
end
|
|
152
254
|
|
|
153
255
|
desc 'Export layouts, pages and snippets all in one go'
|
|
@@ -14,8 +14,10 @@ class RakeTasksTest < ActionDispatch::IntegrationTest
|
|
|
14
14
|
|
|
15
15
|
assert_difference 'CmsLayout.count', 2 do
|
|
16
16
|
capture_rake_output{
|
|
17
|
-
Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute(
|
|
18
|
-
|
|
17
|
+
Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute(
|
|
18
|
+
:from => 'test.host', :to => 'test.host' )
|
|
19
|
+
Rake.application['comfortable_mexican_sofa:import:layouts'].execute(
|
|
20
|
+
:from => 'test.host', :to => 'test.host' )
|
|
19
21
|
}
|
|
20
22
|
end
|
|
21
23
|
end
|
|
@@ -26,8 +28,10 @@ class RakeTasksTest < ActionDispatch::IntegrationTest
|
|
|
26
28
|
|
|
27
29
|
assert_difference ['CmsPage.count', 'CmsBlock.count'], 3 do
|
|
28
30
|
capture_rake_output{
|
|
29
|
-
Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute(
|
|
30
|
-
|
|
31
|
+
Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute(
|
|
32
|
+
:from => 'test.host', :to => 'test.host' )
|
|
33
|
+
Rake.application['comfortable_mexican_sofa:import:pages'].execute(
|
|
34
|
+
:from => 'test.host', :to => 'test.host' )
|
|
31
35
|
}
|
|
32
36
|
end
|
|
33
37
|
end
|
|
@@ -38,8 +42,10 @@ class RakeTasksTest < ActionDispatch::IntegrationTest
|
|
|
38
42
|
|
|
39
43
|
assert_difference 'CmsSnippet.count', 1 do
|
|
40
44
|
capture_rake_output{
|
|
41
|
-
Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute(
|
|
42
|
-
|
|
45
|
+
Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute(
|
|
46
|
+
:from => 'test.host', :to => 'test.host' )
|
|
47
|
+
Rake.application['comfortable_mexican_sofa:import:snippets'].execute(
|
|
48
|
+
:from => 'test.host', :to => 'test.host' )
|
|
43
49
|
}
|
|
44
50
|
end
|
|
45
51
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: comfortable_mexican_sofa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 63
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 1.0.
|
|
9
|
+
- 20
|
|
10
|
+
version: 1.0.20
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Oleg Khabarov
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2010-11-
|
|
19
|
+
date: 2010-11-12 00:00:00 -05:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|