Module: Fig::Command::Action::Role::Publish

Included in:
Publish, PublishLocal
Defined in:
lib/fig/command/action/role/publish.rb

Instance Method Summary collapse

Instance Method Details

#allow_both_descriptor_and_file?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/fig/command/action/role/publish.rb', line 16

def allow_both_descriptor_and_file?()
  # Actually, publishing requires a descriptor and another source of the base
  # package.
  return true
end

#apply_base_config?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/fig/command/action/role/publish.rb', line 46

def apply_base_config?()
  return nil # don't care
end

#apply_config?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fig/command/action/role/publish.rb', line 42

def apply_config?()
  return true
end

#base_package_can_come_from_descriptor?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/fig/command/action/role/publish.rb', line 34

def base_package_can_come_from_descriptor?()
  return false
end

#cares_about_package_content_options?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/fig/command/action/role/publish.rb', line 22

def cares_about_package_content_options?()
  return true
end

#configure(options) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/fig/command/action/role/publish.rb', line 50

def configure(options)
  @descriptor                   = options.descriptor
  @environment_statements       = options.environment_statements
  @package_contents_statements  = options.package_contents_statements
  @force                        = options.force?

  return
end

#derive_publish_statements_from_environment_statementsObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/fig/command/action/role/publish.rb', line 88

def derive_publish_statements_from_environment_statements
  if @execution_context.package_source_description
    message = 'Cannot publish based upon both a package definition file ('
    message << @execution_context.package_source_description
    message << ') and --set/--append options.'

    if @execution_context.package_source_description ==
      Fig::Command::PackageLoader::DEFAULT_FIG_FILE

      message << "\n\n"
      message << 'You can avoid loading '
      message << Fig::Command::PackageLoader::DEFAULT_FIG_FILE
      message << ' by using the --no-file option.'
    end

    raise Fig::UserInputError.new(message)
  end

  @publish_statements =
    @package_contents_statements +
    [
      Fig::Statement::Configuration.new(
        nil,
        nil,
        Fig::Package::DEFAULT_CONFIG,
        @environment_statements
      )
    ]

  return
end

#descriptor_requirementObject



12
13
14
# File 'lib/fig/command/action/role/publish.rb', line 12

def descriptor_requirement()
  return :required
end

#load_base_package?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/fig/command/action/role/publish.rb', line 30

def load_base_package?()
  return true
end

#modifies_repository?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/fig/command/action/role/publish.rb', line 26

def modifies_repository?()
  return true
end

#publish_preflightObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/fig/command/action/role/publish.rb', line 59

def publish_preflight()
  if @descriptor.name.nil? || @descriptor.version.nil?
    raise Fig::UserInputError.new(
      'Please specify a package name and a version name.'
    )
  end
  if @descriptor.name == '_meta'
    raise Fig::UserInputError.new(
      %q<Due to implementation issues, cannot create a package named "_meta".>
    )
  end

  if not @environment_statements.empty?
    derive_publish_statements_from_environment_statements
  elsif not @package_contents_statements.empty?
    raise Fig::UserInputError.new(
      '--resource/--archive options were specified, but no --set/--append option was given. Will not publish.'
    )
  else
    if not @execution_context.base_package.statements.empty?
      @publish_statements = @execution_context.base_package.statements
    else
      raise Fig::UserInputError.new('Nothing to publish.')
    end
  end

  return
end

#register_base_package?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/fig/command/action/role/publish.rb', line 38

def register_base_package?()
  return false
end