Class: SolrMakr::Commands::WriteYaml Private

Inherits:
ActiveInteraction::Base
  • Object
show all
Includes:
AbstractCommand
Defined in:
lib/solr_makr/commands/write_yaml.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

STDOUT_OUTPUTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[?-, nil, 'stdout']

Constants included from Utility

Utility::REQUIRED_SOLR_NODES

Instance Attribute Summary collapse

Attributes included from BufferInteraction

#buffer

Instance Method Summary collapse

Methods included from AbstractCommand

#expect_success!, #fetch_configset, #local_configuration

Methods included from Utility

default_table, default_table_options!, hash_to_table, looks_like_a_valid_configset?, path_to_configset

Methods included from BufferInteraction

#build_buffer, #compose_buffer

Instance Attribute Details

#sunspot_configurationSolrMakr::SunspotConfiguration (readonly)



35
36
37
# File 'lib/solr_makr/commands/write_yaml.rb', line 35

attr_lazy_reader :sunspot_configuration do
  SolrMakr::SunspotConfiguration.new collection: name, environment: environment, log_level: log_level
end

Instance Method Details

#executeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/solr_makr/commands/write_yaml.rb', line 13

def execute
  if output_to_stdout?
    buffer.write sunspot_configuration.to_yaml
  else
    File.open(output, 'w') do |f|
      YAML.dump sunspot_configuration, f
    end

    buffer.ok "Wrote configuration to #{output}"
  end
end

#output_to_stdout?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/solr_makr/commands/write_yaml.rb', line 25

def output_to_stdout?
  if given?(:output)
    output.in?(STDOUT_OUTPUTS)
  else
    true
  end
end