0.0
Low commit activity in last 3 years
No release in over a year
Rails engine to treat external resources as if they were local
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Local Resource

Gem Version CircleCI Coverage Status

Rails engine to treat external resources as if they were local.

Installation

Add to your Gemfile:

gem "local_resource"
bundle install

Usage

Using Instance

instance = LocalResource::Instance.new("http://lorempixel.com/400/200", "my-photo.jpeg")
instance.file # it downloads the photo from lorempixel.com to the tmp file.
instance.file_path # it shows the local path of your downloaded image.
instance.destroy # it removes the photo from the /tmp directory.

Using as_local_resource

LocalResource.as_local_resource("http://lorempixel.com/400/200", "my-photo.jpeg") do |tmp_file_path|
  # some code needing the local file.
end

The previous code...

  • It downloads the photo from lorempixel.com to the tmp file.
  • It executes custom code that needs the local file.
  • It removes the tmp file from tmp.

Testing

To run the specs you need to execute, in the root path of the gem, the following command:

bundle exec guard

You need to put all your tests in the /local_resource/spec/dummy/spec/ directory.

Publishing

On master/main branch...

  1. Change VERSION in lib/local_resource/version.rb.
  2. Change Unreleased title to current version in CHANGELOG.md.
  3. Commit new release. For example: Releasing v0.1.0.
  4. Create tag. For example: git tag v0.1.0.
  5. Push tag. For example: git push origin v0.1.0.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Credits

Thank you contributors!

Platanus

Local Resource is maintained by platanus.

License

Local Resource is © 2018 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.