Class: RedmineInstaller::PackageConfig

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/redmine-installer/package_config.rb

Constant Summary collapse

CONFIG_DIR =
'_package'

Constants included from Utils

Utils::PROGRESSBAR_FORMAT

Instance Method Summary collapse

Methods included from Utils

#class_name, #create_dir, #env_user, #error, #logger, #ok, #pastel, #print_title, #prompt, #run_command

Constructor Details

#initialize(redmine) ⇒ PackageConfig

Returns a new instance of PackageConfig.



7
8
9
# File 'lib/redmine-installer/package_config.rb', line 7

def initialize(redmine)
  @redmine = redmine
end

Instance Method Details

#check_versionObject



57
58
59
60
61
# File 'lib/redmine-installer/package_config.rb', line 57

def check_version
  if min_version && Gem::Version.new(min_version) > Gem::Version.new(RedmineInstaller::VERSION)
    error "You are using an old version of installer. Min version is #{min_version} (current: #{RedmineInstaller::VERSION}). Please run `gem install redmine-installer`."
  end
end

#dump_attached?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/redmine-installer/package_config.rb', line 23

def dump_attached?
  File.exist?(dump_file)
end

#dump_compatible?(database) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/redmine-installer/package_config.rb', line 49

def dump_compatible?(database)
  database.adapter_name.start_with?(dump_type.to_s)
end

#dump_fileObject



19
20
21
# File 'lib/redmine-installer/package_config.rb', line 19

def dump_file
  File.join(@redmine.root, CONFIG_DIR, options['dump_file'].to_s)
end

#dump_typeObject



15
16
17
# File 'lib/redmine-installer/package_config.rb', line 15

def dump_type
  options['dump_type']
end

#min_versionObject



11
12
13
# File 'lib/redmine-installer/package_config.rb', line 11

def min_version
  options['min_version']
end

#optionsObject



53
54
55
# File 'lib/redmine-installer/package_config.rb', line 53

def options
  @options ||= _options
end

#sql_dump_fileObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/redmine-installer/package_config.rb', line 27

def sql_dump_file
  if defined?(@sql_dump_file)
    return @sql_dump_file
  end

  if !dump_attached?
    @sql_dump_file = nil
  end

  if dump_file.end_with?('.gz')
    @sql_dump_file = File.join(@redmine.root, CONFIG_DIR, 'dump.sql')

    Zlib::GzipReader.open(dump_file) { |gz|
      File.binwrite(@sql_dump_file, gz.read)
    }
  else
    @sql_dump_file = dump_file
  end

  @sql_dump_file
end