Class: RestFtpDaemon::Location
- Inherits:
-
Object
- Object
- RestFtpDaemon::Location
- Includes:
- CommonHelpers
- Defined in:
- lib/rest-ftp-daemon/location.rb
Instance Attribute Summary collapse
-
#aws_bucket ⇒ Object
readonly
Returns the value of attribute aws_bucket.
-
#aws_id ⇒ Object
readonly
Returns the value of attribute aws_id.
-
#aws_region ⇒ Object
readonly
Returns the value of attribute aws_region.
-
#aws_secret ⇒ Object
readonly
Returns the value of attribute aws_secret.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#name ⇒ Object
Accessors.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #dir_fs ⇒ Object
- #generate_temp_name! ⇒ Object
-
#initialize(url) ⇒ Location
constructor
A new instance of Location.
- #is?(kind) ⇒ Boolean
- #local_files ⇒ Object
- #path ⇒ Object
- #path_fs ⇒ Object
- #size ⇒ Object
Methods included from CommonHelpers
#dashboard_url, #exception_to_error, #format_bytes, #identifier, #underscore
Constructor Details
#initialize(url) ⇒ Location
Returns a new instance of Location.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rest-ftp-daemon/location.rb', line 26 def initialize url # Check parameters # unless url.is_a? String # raise RestFtpDaemon::AssertionFailed, "location/init/string: #{url.inspect}" # end debug nil @url = url.clone debug :url, url @tokens = [] # Detect tokens in string @tokens = detect_tokens(url) debug :tokens, @tokens.inspect # First resolve tokens resolve_tokens! url # Build URI from parameters build_uri url # Extract dir and name build_dir_name # Specific initializations case @uri when URI::S3 then init_aws # Match AWS URL with BUCKET.s3.amazonaws.com end end |
Instance Attribute Details
#aws_bucket ⇒ Object (readonly)
Returns the value of attribute aws_bucket.
18 19 20 |
# File 'lib/rest-ftp-daemon/location.rb', line 18 def aws_bucket @aws_bucket end |
#aws_id ⇒ Object (readonly)
Returns the value of attribute aws_id.
19 20 21 |
# File 'lib/rest-ftp-daemon/location.rb', line 19 def aws_id @aws_id end |
#aws_region ⇒ Object (readonly)
Returns the value of attribute aws_region.
17 18 19 |
# File 'lib/rest-ftp-daemon/location.rb', line 17 def aws_region @aws_region end |
#aws_secret ⇒ Object (readonly)
Returns the value of attribute aws_secret.
20 21 22 |
# File 'lib/rest-ftp-daemon/location.rb', line 20 def aws_secret @aws_secret end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
15 16 17 |
# File 'lib/rest-ftp-daemon/location.rb', line 15 def dir @dir end |
#name ⇒ Object
Accessors
9 10 11 |
# File 'lib/rest-ftp-daemon/location.rb', line 9 def name @name end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
14 15 16 |
# File 'lib/rest-ftp-daemon/location.rb', line 14 def scheme @scheme end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
13 14 15 |
# File 'lib/rest-ftp-daemon/location.rb', line 13 def tokens @tokens end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
12 13 14 |
# File 'lib/rest-ftp-daemon/location.rb', line 12 def uri @uri end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
11 12 13 |
# File 'lib/rest-ftp-daemon/location.rb', line 11 def url @url end |
Instance Method Details
#dir_fs ⇒ Object
67 68 69 |
# File 'lib/rest-ftp-daemon/location.rb', line 67 def dir_fs '/' + @dir end |
#generate_temp_name! ⇒ Object
88 89 90 |
# File 'lib/rest-ftp-daemon/location.rb', line 88 def generate_temp_name! @name = "#{@name}.temp-#{identifier(JOB_TEMPFILE_LEN)}" end |
#is?(kind) ⇒ Boolean
56 57 58 |
# File 'lib/rest-ftp-daemon/location.rb', line 56 def is? kind @uri.is_a? kind end |
#local_files ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/rest-ftp-daemon/location.rb', line 71 def local_files Dir.glob("/#{path}").collect do |file| next unless File.readable? file next unless File.file? file # Create a new location object self.class.new(file) end end |
#path ⇒ Object
60 61 62 |
# File 'lib/rest-ftp-daemon/location.rb', line 60 def path File.join(@dir.to_s, name.to_s) end |
#path_fs ⇒ Object
64 65 66 |
# File 'lib/rest-ftp-daemon/location.rb', line 64 def path_fs '/' + path end |