Class: Jackfs::FileAdapter
- Inherits:
-
Object
- Object
- Jackfs::FileAdapter
- Defined in:
- lib/jackfs/adapters/file_adapter.rb
Instance Attribute Summary collapse
-
#app_env ⇒ Object
Returns the value of attribute app_env.
-
#app_root ⇒ Object
Returns the value of attribute app_root.
-
#location ⇒ Object
Returns the value of attribute location.
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#initialize(app_root, app_env) ⇒ FileAdapter
constructor
A new instance of FileAdapter.
- #store(this_file, name) ⇒ Object
Constructor Details
#initialize(app_root, app_env) ⇒ FileAdapter
Returns a new instance of FileAdapter.
5 6 7 8 9 10 11 12 13 |
# File 'lib/jackfs/adapters/file_adapter.rb', line 5 def initialize(app_root, app_env) @app_root = app_root @app_env = app_env begin @location = YAML.load_file(File.join(@app_root, Jackfs::FileStore::CONFIG_FILE))[@app_env.to_s]["location"] rescue raise InvalidFileStore end end |
Instance Attribute Details
#app_env ⇒ Object
Returns the value of attribute app_env.
3 4 5 |
# File 'lib/jackfs/adapters/file_adapter.rb', line 3 def app_env @app_env end |
#app_root ⇒ Object
Returns the value of attribute app_root.
3 4 5 |
# File 'lib/jackfs/adapters/file_adapter.rb', line 3 def app_root @app_root end |
#location ⇒ Object
Returns the value of attribute location.
3 4 5 |
# File 'lib/jackfs/adapters/file_adapter.rb', line 3 def location @location end |
Instance Method Details
#get(name) ⇒ Object
20 21 22 |
# File 'lib/jackfs/adapters/file_adapter.rb', line 20 def get(name) File.open(File.join(app_root, @location, name), 'r') end |
#store(this_file, name) ⇒ Object
15 16 17 18 |
# File 'lib/jackfs/adapters/file_adapter.rb', line 15 def store(this_file, name) File.open(File.join(@app_root, @location, name), 'w') { |file| file.write this_file.read } name end |