Class: Sftp::Sync::Config
- Inherits:
-
Object
- Object
- Sftp::Sync::Config
- Defined in:
- lib/sftp/sync/config.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #filter ⇒ Object
- #filter? ⇒ Boolean
- #host ⇒ Object
-
#initialize(_options = {}) ⇒ Config
constructor
A new instance of Config.
- #output_dir ⇒ Object
- #password ⇒ Object
- #port ⇒ Object
- #remove_local? ⇒ Boolean
- #sftp_opts ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(_options = {}) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sftp/sync/config.rb', line 8 def initialize( = {}) = ActiveSupport::HashWithIndifferentAccess.new() #required [:host] = ENV["SFTP_SYNC_HOST"] unless [:host].present? raise "missing host. Set SFTP_SYNC_HOST env." unless [:host].present? [:username] = ENV["SFTP_SYNC_USERNAME"] unless [:username].present? raise "missing username. Set SFTP_SYNC_USERNAME env." unless [:username].present? #optional [:port] = ENV["SFTP_SYNC_PORT"] unless [:port].present? [:password] = ENV["SFTP_SYNC_PASSWORD"] unless [:password].present? end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/sftp/sync/config.rb', line 7 def end |
Instance Method Details
#filter ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/sftp/sync/config.rb', line 56 def filter if [:filter].present? [:filter] elsif File.exist?(".gitignore") && [:gitignore] ".gitignore" else nil end end |
#filter? ⇒ Boolean
52 53 54 |
# File 'lib/sftp/sync/config.rb', line 52 def filter? filter.present? end |
#host ⇒ Object
29 30 31 |
# File 'lib/sftp/sync/config.rb', line 29 def host [:host] end |
#output_dir ⇒ Object
66 67 68 |
# File 'lib/sftp/sync/config.rb', line 66 def output_dir [:output_dir] || "" end |
#password ⇒ Object
37 38 39 |
# File 'lib/sftp/sync/config.rb', line 37 def password [:password] end |
#port ⇒ Object
41 42 43 |
# File 'lib/sftp/sync/config.rb', line 41 def port [:port] end |
#remove_local? ⇒ Boolean
70 71 72 |
# File 'lib/sftp/sync/config.rb', line 70 def remove_local? [:remove_local] end |
#sftp_opts ⇒ Object
45 46 47 48 49 50 |
# File 'lib/sftp/sync/config.rb', line 45 def sftp_opts {}.tap do |opts| opts[:password] = password unless password.nil? opts[:port] = port unless port.nil? end end |
#username ⇒ Object
33 34 35 |
# File 'lib/sftp/sync/config.rb', line 33 def username [:username] end |