carrierwave-nightcrawler-swift 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88a8c0f03cf1d3e03b7221b539e1040981270278
4
+ data.tar.gz: 080020d7849b2ccde4c053b8e510870b1bb6f74e
5
+ SHA512:
6
+ metadata.gz: 5a31702afc3bc2f3ea76c92f15f82fff4ad1d10b563731d4949d1e11203dd11d75134fce06d84171f5a7b83761ea61736e6a828566928cd682f55fae226a8ede
7
+ data.tar.gz: b0ed6bcd952ac2eabb088ae31d9c2232f9dabf4f3e0838048489fdfd2a4a42584cbabf862f073e2ad8126f764026b09974be3c0a5bf6b5f24546da8099f8d34e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in carrierwave-nightcrawler-swift.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Carrierwave Nightcrawler Swift
2
+
3
+ This gem is a [Carrierwave](https://github.com/jnicklas/carrierwave/) store for Swift. This library uses [nightcrawler_swift](https://github.com/tulios/nightcrawler_swift) for swift operations.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'carrierwave-nightcrawler-swift'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install carrierwave-nightcrawler-swift
20
+
21
+ ## Usage
22
+
23
+ You should configure the client.
24
+
25
+ ```
26
+ NightcrawlerSwift.configure({
27
+ :bucket=>"container-name",
28
+ :tenant_name=>"tenant-name",
29
+ :username=>"user",
30
+ :password=>"some-secret-password",
31
+ :auth_url=>"https://your-swift-server.com/v2.0/tokens",
32
+ :verify_ssl=>false
33
+ })
34
+ ```
35
+
36
+ Set the storage to be __storage Carrierwave::Nightcrawler::Swift::Storage__. .
37
+
38
+ ``` ruby
39
+ class AvatarUploader < CarrierWave::Uploader::Base
40
+ :storage => Carrierwave::Nightcrawler::Swift::Storage
41
+ end
42
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "carrierwave/nightcrawler/swift"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'carrierwave/nightcrawler/swift/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "carrierwave-nightcrawler-swift"
8
+ spec.version = Carrierwave::Nightcrawler::Swift::VERSION
9
+ spec.authors = ["Wandenberg"]
10
+ spec.email = ["wandenberg@gmail.com"]
11
+
12
+ spec.summary = 'Carrierwave store for swift using NightcrawlerSwift client for authenication, list and store operations'
13
+ spec.description = 'A store for carrierwave that uses swift. NightcrawlerSwift client is used for authenication, list and store operations.'
14
+ spec.homepage = "https://github.com/wandenberg/#{spec.name}"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_dependency "nightcrawler_swift"
24
+ end
@@ -0,0 +1,9 @@
1
+ require "carrierwave/nightcrawler/swift/version"
2
+ require "carrierwave/nightcrawler/swift/storage"
3
+
4
+ module Carrierwave
5
+ module Nightcrawler
6
+ module Swift
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,42 @@
1
+ module Carrierwave
2
+ module Nightcrawler
3
+ module Swift
4
+ class Storage < CarrierWave::Storage::Abstract
5
+ def initialize(uploader)
6
+ super(uploader)
7
+
8
+ @swift_list = NightcrawlerSwift::List.new
9
+ @swift_upload = NightcrawlerSwift::Upload.new
10
+ end
11
+
12
+ def store!(file)
13
+ @swift_upload.execute @uploader.filename, ::File.new(file.file)
14
+ end
15
+
16
+ def retrieve!(identifier)
17
+ list = @swift_list.execute(prefix: identifier)
18
+ SwiftFile.new(list[0]) if (list.is_a?(Array) && (list.count > 0))
19
+ end
20
+
21
+ class SwiftFile
22
+ def initialize(attrs)
23
+ @attrs = attrs
24
+ end
25
+
26
+ def path
27
+ @attrs["name"]
28
+ end
29
+
30
+ def url(options = {})
31
+ "#{NightcrawlerSwift.connection.public_url}/#{NightcrawlerSwift.options.bucket}/#{@attrs["name"]}"
32
+ end
33
+
34
+ def delete
35
+ delete = NightcrawlerSwift::Delete.new
36
+ delete.execute path
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ module Carrierwave
2
+ module Nightcrawler
3
+ module Swift
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carrierwave-nightcrawler-swift
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wandenberg
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nightcrawler_swift
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A store for carrierwave that uses swift. NightcrawlerSwift client is
56
+ used for authenication, list and store operations.
57
+ email:
58
+ - wandenberg@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - carrierwave-nightcrawler-swift.gemspec
70
+ - lib/carrierwave/nightcrawler/swift.rb
71
+ - lib/carrierwave/nightcrawler/swift/storage.rb
72
+ - lib/carrierwave/nightcrawler/swift/version.rb
73
+ homepage: https://github.com/wandenberg/carrierwave-nightcrawler-swift
74
+ licenses: []
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Carrierwave store for swift using NightcrawlerSwift client for authenication,
96
+ list and store operations
97
+ test_files: []