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)


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

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)


48
49
50
# File 'lib/fig/command/action/role/publish.rb', line 48

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

#apply_config?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/fig/command/action/role/publish.rb', line 44

def apply_config?()
  return true
end

#base_package_can_come_from_descriptor?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/fig/command/action/role/publish.rb', line 36

def base_package_can_come_from_descriptor?()
  return false
end

#cares_about_asset_options?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/fig/command/action/role/publish.rb', line 24

def cares_about_asset_options?()
  return true
end

#configure(options) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/fig/command/action/role/publish.rb', line 57

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

  return
end

#derive_publish_statements_from_environment_statementsObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/fig/command/action/role/publish.rb', line 95

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

    if @execution_context.package_source_description ==
      Fig::Command::PackageLoader::DEFAULT_PACKAGE_FILE ||
      @execution_context.package_source_description ==
      Fig::Command::PackageLoader::DEFAULT_APPLICATION_FILE ||

      message << "\n\n"
      message << 'You can avoid loading '
      message << @execution_context.package_source_description
      message << ' by using the --no-file option.'
    end

    raise Fig::UserInputError.new(message)
  end

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

  return
end

#descriptor_requirementObject



14
15
16
# File 'lib/fig/command/action/role/publish.rb', line 14

def descriptor_requirement()
  return :required
end

#load_base_package?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/fig/command/action/role/publish.rb', line 32

def load_base_package?()
  return true
end

#modifies_repository?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/fig/command/action/role/publish.rb', line 28

def modifies_repository?()
  return true
end

#publish?Boolean

Is this a publish action?

Returns:

  • (Boolean)


53
54
55
# File 'lib/fig/command/action/role/publish.rb', line 53

def publish?()
  return true
end

#publish_preflightObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/fig/command/action/role/publish.rb', line 66

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 @asset_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)


40
41
42
# File 'lib/fig/command/action/role/publish.rb', line 40

def register_base_package?()
  return false
end