Class: Star::Configuration
- Inherits:
-
Object
- Object
- Star::Configuration
- Defined in:
- lib/star/configuration.rb
Overview
Provides an object to store global configuration settings.
This class is typically not used directly, but by calling Star.configure, which creates and updates a single instance of Configuration.
An alternative way to set global configuration settings is by storing them in the following environment variables:
-
AWS_ACCESS_KEY_ID
to store the ACCESS KEY ID -
AWS_SECRET_ACCESS_KEY
to store the Client Secret for web/device apps -
AWS_BUCKET
to set the name of the S3 bucket -
STAR_LOCATION
to set the path for where to upload the file to -
STAR_DURATION
to set the time (in seconds) for the URL to exist for -
STAR_REMOTE
to store file in the local filesystem and not remotely
In case both methods are used together, Star.configure takes precedence.
Instance Attribute Summary collapse
-
#access_key_id ⇒ String
The S3 access key ID.
-
#bucket ⇒ String
The name of the S3 bucket.
-
#duration ⇒ Integer
The number of seconds during which the URL returned by calling #url on a remote file is publicly available.
-
#location ⇒ String
The path where remote files are uploaded to.
-
#remote ⇒ Booelan
Whether to store files remotely or locally.
-
#secret_access_key ⇒ String
The S3 secret access key.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Initialize the global configuration settings, using the values of the specified following environment variables by default.
Constructor Details
#initialize ⇒ Configuration
Initialize the global configuration settings, using the values of the specified following environment variables by default.
54 55 56 57 58 59 60 61 |
# File 'lib/star/configuration.rb', line 54 def initialize @access_key_id = ENV['AWS_ACCESS_KEY_ID'] @secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'] @bucket = ENV['AWS_BUCKET'] @location = ENV.fetch('STAR_LOCATION', '/') @duration = ENV.fetch('STAR_DURATION', '30').to_i @remote = %w(1 t T true TRUE).include? ENV.fetch('STAR_REMOTE', 't') end |
Instance Attribute Details
#access_key_id ⇒ String
Returns the S3 access key ID.
34 35 36 |
# File 'lib/star/configuration.rb', line 34 def access_key_id @access_key_id end |
#bucket ⇒ String
Returns the name of the S3 bucket.
40 41 42 |
# File 'lib/star/configuration.rb', line 40 def bucket @bucket end |
#duration ⇒ Integer
Returns the number of seconds during which the URL returned by calling #url on a remote file is publicly available.
47 48 49 |
# File 'lib/star/configuration.rb', line 47 def duration @duration end |
#location ⇒ String
Returns the path where remote files are uploaded to.
43 44 45 |
# File 'lib/star/configuration.rb', line 43 def location @location end |
#remote ⇒ Booelan
Returns whether to store files remotely or locally.
50 51 52 |
# File 'lib/star/configuration.rb', line 50 def remote @remote end |
#secret_access_key ⇒ String
Returns the S3 secret access key.
37 38 39 |
# File 'lib/star/configuration.rb', line 37 def secret_access_key @secret_access_key end |