push pages command (WIP)
did
committed May 09, 2015
commit 0c2d0093483fda28fda09067eb545780f68ff2ef
Showing 5
changed files with
60 additions
and 4 deletions
Gemfile
+2
-2
| @@ | @@ -15,11 +15,11 @@ gem 'therubyracer' |
| # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'b2de77e', require: false | |
| # gem 'locomotivecms_coal', github: 'locomotivecms/coal', ref: '32b2844', require: false | |
| - | gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '3046b79893', require: false |
| + | # gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '3046b79893', require: false |
| gem 'locomotivecms_coal', path: '../in_progress/coal', require: false | |
| gem 'locomotivecms_steam', path: '../in_progress/steam', require: false | |
| - | # gem 'locomotivecms_common', path: '../in_progress/common', require: false |
| + | gem 'locomotivecms_common', path: '../in_progress/common', require: false |
| group :test do | |
| gem 'rspec', '~> 3.2.0' | |
locomotive/wagon/commands/push_command.rb b/lib/locomotive/wagon/commands/push_command.rb
+2
-1
| @@ | @@ -11,7 +11,8 @@ module Locomotive::Wagon |
| class PushCommand < Struct.new(:env, :path, :options) | |
| - | RESOURCES = %w(content_types content_entries snippets theme_assets translations).freeze |
| + | # RESOURCES = %w(content_types content_entries snippets theme_assets translations).freeze |
| + | RESOURCES = %w(pages).freeze |
| RESOURCES_WITH_CONTENT = %w(content_entries translations).freeze | |
locomotive/wagon/commands/push_sub_commands/push_pages_command.rb b/lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb
+25
-0
| @@ | @@ -0,0 +1,25 @@ |
| + | module Locomotive::Wagon |
| + | |
| + | class PushPagesCommand < PushBaseCommand |
| + | |
| + | def entities |
| + | repositories.page.all |
| + | end |
| + | |
| + | def decorate(entity) |
| + | # puts entity.inspect |
| + | PageDecorator.new(entity, locale, default_locale) |
| + | end |
| + | |
| + | def persist(decorated_entity) |
| + | # puts decorated_entity.to_hash |
| + | # api_client.snippets.update(decorated_entity.slug, decorated_entity.to_hash) |
| + | end |
| + | |
| + | def label_for(decorated_entity) |
| + | decorated_entity.fullpath |
| + | end |
| + | |
| + | end |
| + | |
| + | end |
locomotive/wagon/decorators/page_decorator.rb b/lib/locomotive/wagon/decorators/page_decorator.rb
+29
-0
| @@ | @@ -0,0 +1,29 @@ |
| + | module Locomotive |
| + | module Wagon |
| + | |
| + | class PageDecorator < Locomotive::Steam::Decorators::TemplateDecorator |
| + | |
| + | include ToHashConcern |
| + | |
| + | # def id |
| + | # slug |
| + | # end |
| + | |
| + | # def template |
| + | # {}.tap do |translations| |
| + | # __getobj__.template_path.translations.each do |locale, _| |
| + | # __with_locale__(locale) do |
| + | # translations[locale] = self.liquid_source |
| + | # end |
| + | # end |
| + | # end |
| + | # end |
| + | |
| + | def __attributes__ |
| + | %i(title) |
| + | end |
| + | |
| + | end |
| + | |
| + | end |
| + | end |
spec/integration/commands/push_command_spec.rb
+2
-1
| @@ | @@ -37,7 +37,8 @@ describe Locomotive::Wagon::PushCommand do |
| resources << payload[:name] | |
| end | |
| is_expected.not_to eq nil | |
| - | expect(resources).to eq %w(content_types content_entries snippets theme_assets translations) |
| + | # expect(resources).to eq %w(content_types content_entries snippets theme_assets translations) |
| + | expect(resources).to eq %w(pages) |
| end | |
| context 'no previous authentication' do | |