README.md in nightcrawler_swift-0.1.1 vs README.md in nightcrawler_swift-0.2.0
- old
+ new
@@ -1,8 +1,8 @@
# Nightcrawler Swift
-Like the X-Men nightcrawler it teleports your assets to a OpenStack Swift bucket/container
+Like the X-Men nightcrawler this gem teleports your assets to a OpenStack Swift bucket/container. It was designed to sync your assets with OpenStack Swift and allow some operations with your buckets/containers.
## Installation
Add this line to your application's Gemfile:
@@ -17,75 +17,98 @@
$ gem install nightcrawler_swift
## Usage
### With Rails
-#### 1) You will need to configure your swift credentials
+#### 1) Configure your swift credentials
+_In config/application.rb_ or _config/environments/*.rb_
+
```ruby
-NightcrawlerSwift.configure({
- bucket: "rogue",
- tenant_name: "nightcrawler"
- username: "my_username1",
- password: "my_password1",
- auth_url: "https://auth.url.com:123/v2.0/tokens"
-})
+config.nightcrawler_swift.bucket = "rogue"
+config.nightcrawler_swift.tenent_name = "nightcrawler"
+config.nightcrawler_swift.username = "my_username1"
+config.nightcrawler_swift.password = "my_password1"
+config.nightcrawler_swift.auth_url = "https://auth.url.com:123/v2.0/tokens"
```
-You could create an initializer with this code.
+By default it will use ```Rails.logger``` as logger, to change that use a different logger in configurations, like:
-#### 2) Load rake tasks into your Rakefile
-
```ruby
-require 'nightcrawler_swift'
-load 'nightcrawler_swift/tasks/asset_sync.rake'
+config.nightcrawler_swift.logger = Logger.new(STDOU)
```
-#### 3) Profit!
+#### 2) Profit!
```sh
rake nightcrawler_swift:rails:asset_sync
```
It will invoke ```rake assets:precompile``` and will copy your public directory to swift bucket/container.
### Programatically
-#### 1) Configure
+#### 1) Configure your swift credentials
-Repeat the first step of Rails guide
+```ruby
+NightcrawlerSwift.configure({
+ bucket: "rogue",
+ tenant_name: "nightcrawler"
+ username: "my_username1",
+ password: "my_password1",
+ auth_url: "https://auth.url.com:123/v2.0/tokens"
+})
+```
-#### 2) Call method sync with the desired directory
+By default it will use ```Logger.new(STDOUT)``` as logger, to change that use:
```ruby
+NightcrawlerSwift.logger = Logger.new(StringIO.new)
+```
+
+#### 2) Use method sync with the desired directory
+
+```ruby
NightcrawlerSwift.sync File.expand_path("./my-dir")
```
## Commands
-NightcrawlerSwift packs some useful commands. All commands requires that the gem has already been configured and the connection established.
+NightcrawlerSwift has some useful built-in commands. All commands require the configuration and a established connection.
-To Establish the connection, call:
+To Establish the connection, use:
```ruby
NightcrawlerSwift.connection.connect!
```
-To check if the connection is still valid, call:
+To check if the connection is still valid, use:
```ruby
NightcrawlerSwift.connection.connected?
```
-To reconnect just call ```NightcrawlerSwift.connection.connect!``` again.
+To reconnect just use ```NightcrawlerSwift.connection.connect!``` again.
### Upload
```ruby
upload = NightcrawlerSwift::Upload.new
upload.execute "my_file_path.txt", File.open("../my_file_fullpath.txt", "r")
# true / false
```
+
+_This upload command was not designed to send very large files_
+
+### Download
+
+```ruby
+download = NightcrawlerSwift::Download.new
+download.execute "my_file_path.txt"
+# File content
+```
+
+_This download command was not designed to retrieve very large files_
### List
```ruby
list = NightcrawlerSwift::List.new