Class: Exportation::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/exportation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Export

Returns a new instance of Export.



23
24
25
26
27
28
29
30
31
32
# File 'lib/exportation.rb', line 23

def initialize(options)
  @path = options[:path]
  @filename = options[:filename]
  @name = options[:name]
  @password = options[:password]

  @path = './' if Exportation.is_empty?(@path)
  @filename = 'exported' if Exportation.is_empty?(@filename)
  @password = '' if Exportation.is_empty?(@password)
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



21
22
23
# File 'lib/exportation.rb', line 21

def filename
  @filename
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/exportation.rb', line 21

def name
  @name
end

#passwordObject

Returns the value of attribute password.



21
22
23
# File 'lib/exportation.rb', line 21

def password
  @password
end

#pathObject

Returns the value of attribute path.



21
22
23
# File 'lib/exportation.rb', line 21

def path
  @path
end

Instance Method Details

#runObject



34
35
36
37
38
# File 'lib/exportation.rb', line 34

def run
  bash = run_command
  puts "Running: #{bash}"
  `#{bash}`
end

#run_commandObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/exportation.rb', line 40

def run_command
  raise "name is required" if Exportation.is_empty?(@name)

  abs_path = File.expand_path path
  abs_path += '/' unless abs_path.end_with? '/'

  bash = "osascript #{Exportation.applescript_path} " +
    "\"#{abs_path}\" " +
    "\"#{filename}\" " +
    "\"#{name}\" " +
    "\"#{password}\""
end