Module: SipoMailer::Installer
- Defined in:
- lib/sipo_mailer/utils/installer.rb
Constant Summary collapse
- DEFAULT_DIR =
'sipo_mailer'.freeze
- CONFIG_FILE =
'config.yml'
Class Method Summary collapse
- .book_example ⇒ Object
- .config ⇒ Object
- .config_dir ⇒ Object
- .config_example ⇒ Object
- .copy_file(src, dest) ⇒ Object
- .copy_files ⇒ Object
- .create_dir ⇒ Object
- .install ⇒ Object
- .os ⇒ Object
Class Method Details
.book_example ⇒ Object
37 38 39 40 |
# File 'lib/sipo_mailer/utils/installer.rb', line 37 def book_example example_path = Gem.bin_path('sipo_mailer', 'mailer').split('/')[0..-3] [example_path, 'config', 'adresar.csv.example'].join('/') end |
.config ⇒ Object
42 43 44 |
# File 'lib/sipo_mailer/utils/installer.rb', line 42 def config [config_dir, CONFIG_FILE].join('/') end |
.config_dir ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/sipo_mailer/utils/installer.rb', line 46 def config_dir case os when :windows [ENV['HOME'], DEFAULT_DIR].join('/') else [ENV['USERPROFILE'], DEFAULT_DIR].join('/') end end |
.config_example ⇒ Object
32 33 34 35 |
# File 'lib/sipo_mailer/utils/installer.rb', line 32 def config_example example_path = Gem.bin_path('sipo_mailer', 'mailer').split('/')[0..-3] [example_path, 'config', "#{CONFIG_FILE}.example"].join('/') end |
.copy_file(src, dest) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/sipo_mailer/utils/installer.rb', line 22 def copy_file(src, dest) return false if File.exist? dest File.open("#{config_dir}/#{dest}", 'w') do |file| source = File.open(src) file.write(source.readlines.join('')) source.close end true end |
.copy_files ⇒ Object
17 18 19 20 |
# File 'lib/sipo_mailer/utils/installer.rb', line 17 def copy_files copy_file(config_example, CONFIG_FILE) copy_file(book_example, 'adresar.csv') end |
.create_dir ⇒ Object
12 13 14 15 |
# File 'lib/sipo_mailer/utils/installer.rb', line 12 def create_dir result = Dir.mkdir(config_dir) unless Dir.exist?(config_dir) result == 0 end |
.install ⇒ Object
7 8 9 10 |
# File 'lib/sipo_mailer/utils/installer.rb', line 7 def install create_dir copy_files end |
.os ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/sipo_mailer/utils/installer.rb', line 55 def os host_os = RbConfig::CONFIG['host_os'] case host_os when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ :windows when /darwin|mac os/ :macosx when /linux/ :linux when /solaris|bsd/ :unix else raise Error::WebDriverError, "unknown os: #{host_os.inspect}" end end |