Sha256: 4c990ec927de2bbfea3faa981d70e7c11c26dfa572ae5fb57947b987f244548c

Contents?: true

Size: 1.78 KB

Versions: 43

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

require 'eac_cli/core_ext'

module Avm
  module EacRedmineBase0
    module Instances
      module Runners
        class Project
          class WikiPage
            class Write
              runner_with :help, :confirmation, :input do
                bool_opt '-f', '--force'
              end
              delegate :force?, to: :parsed

              def run
                start_banner
                if write?
                  run_write
                else
                  success 'Content unchanged, no further action will be taken'
                end
              end

              def start_banner
                infov 'Content'
                infov '  * Current', current_content
                infov '  * New', new_content
                infov '  * Changed?', content_changed?
              end

              # @return [Boolean]
              def content_changed?
                new_content != current_content
              end

              def run_write
                if confirm?('Write?')
                  infom 'Writing...'
                  runner_context.call(:wiki_page).write(new_content)
                  success('Writed!')
                else
                  success('Unconfirmed, no further action will be taken')
                end
              end

              # @return [Boolean]
              def write?
                parsed.force? || content_changed?
              end

              private

              # @return [String]
              def current_content_uncached
                runner_context.call(:wiki_page_content)
              end

              # @return [String]
              def new_content_uncached
                input_content
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
avm-eac_redmine_base0-0.22.3 lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.91.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
avm-eac_redmine_base0-0.22.2 lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.87.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
avm-eac_redmine_base0-0.22.1 lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.86.11 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.83.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.82.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.81.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
avm-eac_redmine_base0-0.22.0 lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.80.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
avm-eac_redmine_base0-0.21.2 lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.79.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
avm-eac_redmine_base0-0.21.1 lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.78.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.77.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.77.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.76.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
avm-eac_redmine_base0-0.21.0 lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb
eac_tools-0.76.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/project/wiki_page/write.rb