a9s_swift 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7314d1dbf676d2c79519f3043de2a5d6ff50686d
4
- data.tar.gz: 736352afb90e6fc30c4653fe74852d9ba738bf0a
3
+ metadata.gz: 159c003cd8be577850f303edba533d675aced635
4
+ data.tar.gz: 4606240725e7e0e9549eeea56f49e981b04b89b4
5
5
  SHA512:
6
- metadata.gz: 43595415ec80a9e7084ddd30461e525390c9ee31730ff5d7edd7a9e35ddbc0c0fa6ac1e1432c602cdc42dc7cd31f750a218fe3abdedd0b98960244bc99ee79fb
7
- data.tar.gz: 96c96b5dbd310a1ff23706fe42177b7ed6308ad6b6198f2b61324a9776460a61625d571d1e44ab69a3dfb9c35166c9e14ac000d3ef371653dd563d3ddb08051f
6
+ metadata.gz: a7c5759be960afd8ad5418449f1ee5eaf3f2b2884bf70df5ef3cd945dacd4f0b0ae1971d4309fcb6a05c65613eb9adce797ab53e0d8d41b2fcdc6d8945876e59
7
+ data.tar.gz: 44367b251e3e8fcca22922ff8358318e50fbf0904613d821597a62905849a565a86a7bc6f550eeb80c6c35e14e18ae2f0b53ff6ff67800705a4df289d13e3f77
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- = a9s_swift
1
+ # a9s_swift
2
2
 
3
3
  a9s_swift is a small utility gem to ease up the usage of the anyines.com swift service within your applications.
4
4
  It enables a one-line configuration of the following libraries:
@@ -7,13 +7,13 @@ It enables a one-line configuration of the following libraries:
7
7
  * carrierwave
8
8
  * fog
9
9
 
10
- == Dependencies
10
+ ## Dependencies
11
11
 
12
12
  * fog gem : https://github.com/fog/fog
13
13
  * paperclip (optional: if you would like to use the paperclip configuration feature)
14
14
  * carrierwave (optional: if you would like to use the carrierwave configuration feature)
15
15
 
16
- == Installation
16
+ ## Installation
17
17
  gem install a9s_swift
18
18
 
19
19
  or
@@ -21,26 +21,26 @@ It enables a one-line configuration of the following libraries:
21
21
  gem 'a9s_swift' -> Gemfile
22
22
  bundle
23
23
 
24
- == Usage
24
+ ## Usage
25
25
 
26
- === rails applications with carrierwave or paperclip
26
+ ### rails applications with carrierwave or paperclip
27
27
 
28
28
  Some example initializers are provided in the examples directory. Just copy the according file over to your rails application's app/config/initializers directory and start using the anynines swift service within your live applications.
29
29
 
30
30
  Please make sure to bind a swift service instance to your application to enable access to the swift credentials.
31
31
 
32
- === fog
32
+ ### fog
33
33
  con = Anynines::Swift::Utility.fog_connection # returns a fog connection to the a9s swift service
34
34
  con.directories
35
35
 
36
- === paperclip configuration featue
36
+ ### paperclip configuration featue
37
37
  Anynines::Swift::Utility.configure_paperclip("image_bucket") # create bucket, configure paperclip with a9s swift service
38
38
 
39
- === carrierwave configuration feature
39
+ ### carrierwave configuration feature
40
40
  Anynines::Swift::Utility.configure_carrierwave("image_bucket") # create bucket, configure carrierwave with a9s swift service
41
41
 
42
42
 
43
- == Contributing to a9s_swift
43
+ ## Contributing to a9s_swift
44
44
 
45
45
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
46
46
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -50,8 +50,7 @@ Please make sure to bind a swift service instance to your application to enable
50
50
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
51
51
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
52
52
 
53
- == Copyright
54
-
55
- Copyright (c) 2014 Julian Weber. See LICENSE.txt for
56
- further details.
53
+ # Copyright
57
54
 
55
+ Copyright (c) 2014 Julian Weber, Anynines.com . See LICENSE.txt for
56
+ further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: a9s_swift 0.1.4 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "a9s_swift"
8
- s.version = "0.1.3"
9
+ s.version = "0.1.4"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Julian Weber"]
12
- s.date = "2014-04-11"
14
+ s.date = "2014-07-14"
13
15
  s.description = "anynines.com swift service utility library for simplifying app acces to the a9s swift service."
14
16
  s.email = "jweber@anynines.com"
15
17
  s.extra_rdoc_files = [
@@ -34,8 +36,7 @@ Gem::Specification.new do |s|
34
36
  ]
35
37
  s.homepage = "http://github.com/anynines/a9s_swift"
36
38
  s.licenses = ["MIT"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = "2.0.6"
39
+ s.rubygems_version = "2.2.2"
39
40
  s.summary = "anynines.com swift service utility library for simplifying app acces to the a9s swift service."
40
41
 
41
42
  if s.respond_to? :specification_version then
@@ -3,55 +3,45 @@ require 'json'
3
3
 
4
4
  class Anynines::Swift::Utility
5
5
  SWIFT_HOST = "https://swift.hydranodes.de"
6
-
6
+
7
7
  # Returns a fog storage connection to the swift service
8
8
  # @return [Fog::Storage] a fog storage connection
9
9
  def self.fog_connection
10
10
  Fog::Storage.new fog_credentials_hash
11
11
  end
12
-
12
+
13
13
  # Sets up paperclip for the usage with the anynines service.
14
14
  # Creates a bucket with the given name if not already present.
15
15
  # @param image_bucket_name [String] the bucket name to use
16
16
  # @param options [Hash] a hash of additional options
17
17
  def self.configure_paperclip(image_bucket_name, options = {})
18
18
  raise "Paperclip wasn't found in your environment! Please verify that paperclip is included within your Gemfile and loaded correctly." if defined?(Paperclip).nil?
19
-
19
+
20
20
  opts = initialize_options options
21
21
  create_new_bucket(image_bucket_name, opts[:fog_public])
22
-
23
- fog_hash = fog_credentials_hash
24
- # configure paperclip to use the credentials provided by the anynines environment
25
-
22
+
23
+ # configure paperclip to use the credentials provided by the anynines environment
26
24
  Paperclip::Attachment.default_options.update(
27
25
  {
28
26
  :path => ":class/:id/:attachment/:style/img_:fingerprint",
29
27
  :storage => :fog,
30
- :fog_credentials => {
31
- :provider => fog_hash[:provider],
32
- :hp_access_key => fog_hash[:hp_access_key],
33
- :hp_secret_key => fog_hash[:hp_secret_key],
34
- :hp_tenant_id => fog_hash[:hp_tenant_id],
35
- :hp_auth_uri => fog_hash[:hp_auth_uri],
36
- :hp_use_upass_auth_style => true,
37
- :hp_avl_zone => fog_hash[:hp_avl_zone]
38
- },
28
+ :fog_credentials => self.fog_credentials_hash,
39
29
  :fog_directory => image_bucket_name,
40
30
  :fog_public => opts[:fog_public],
41
31
  :fog_host => "#{SWIFT_HOST}/v1/AUTH_#{fog_hash[:hp_tenant_id]}/#{image_bucket_name}"
42
32
  })
43
33
  end
44
-
34
+
45
35
  # Sets up carrierwave for the usage with the anynines service.
46
36
  # Creates a bucket with the given name if not already present.
47
37
  # @param image_bucket_name [String] the bucket name to use
48
38
  # @param options [Hash] a hash of additional options
49
39
  def self.configure_carrierwave(image_bucket_name, options = {})
50
40
  raise "CarrierWave wasn't found in your environment! Please verify that carrierwave is included within your Gemfile and loaded correctly." if defined?(CarrierWave).nil?
51
-
41
+
52
42
  opts = initialize_options options
53
43
  create_new_bucket(image_bucket_name, opts[:fog_public])
54
-
44
+
55
45
  CarrierWave.configure do |config|
56
46
  config.fog_credentials = fog_credentials_hash
57
47
 
@@ -60,15 +50,15 @@ class Anynines::Swift::Utility
60
50
  config.fog_public = opts[:fog_public] # optional, defaults to true
61
51
  end
62
52
  end
63
-
53
+
64
54
  # Returns a fog compatible credentials hash for the swift service
65
55
  def self.fog_credentials_hash
66
56
  # parse the VCAP_SERVICES environment variable
67
- services = JSON.parse(ENV["VCAP_SERVICES"])
57
+ services = JSON.parse(ENV["VCAP_SERVICES"])
68
58
  raise "Couldn't find the VCAP_SERVICE env variable! Are you running within an anynines environment?" if services.nil?
69
59
  raise "Couldn't access the a9s swift service credentials from env! Have you bound a swift service instance to the application?" if services["swift-1.0"].nil?
70
60
  swift_service = services["swift-1.0"].first
71
-
61
+
72
62
  return {
73
63
  :provider => 'HP',
74
64
  :hp_access_key => swift_service["credentials"]["user_name"],
@@ -76,10 +66,11 @@ class Anynines::Swift::Utility
76
66
  :hp_tenant_id => swift_service["credentials"]["tenant_id"],
77
67
  :hp_auth_uri => swift_service["credentials"]["authentication_uri"],
78
68
  :hp_use_upass_auth_style => true,
79
- :hp_avl_zone => swift_service["credentials"]["availability_zone"]
69
+ :hp_avl_zone => swift_service["credentials"]["availability_zone"],
70
+ :os_account_meta_temp_url_key => swift_service["credentials"]["account_meta_key"]
80
71
  }
81
72
  end
82
-
73
+
83
74
  # Creates a new bucket with the given name if not already present
84
75
  # @param bucket_name [String] a name for the bucket
85
76
  # @param public_access [Boolean] should the bucket be publicly accessible?
@@ -87,7 +78,7 @@ class Anynines::Swift::Utility
87
78
  connection = fog_connection
88
79
  if connection.directories.get(bucket_name).nil?
89
80
  puts "The bucket with key=#{bucket_name} wasn't found. Creating bucket with key=#{bucket_name} ."
90
- bucket = connection.directories.create key: bucket_name
81
+ bucket = connection.directories.create key: bucket_name
91
82
 
92
83
  # set the directory to be public
93
84
  bucket.public = public_access
@@ -100,12 +91,12 @@ class Anynines::Swift::Utility
100
91
  return false
101
92
  end
102
93
  end
103
-
104
- private
105
-
94
+
95
+ private
96
+
106
97
  def self.initialize_options(options)
107
98
  # set fog_public to true if not defined within the options
108
99
  options[:fog_public] = true if options[:fog_public].nil?
109
100
  return options
110
101
  end
111
- end
102
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a9s_swift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Weber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.0.6
126
+ rubygems_version: 2.2.2
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: anynines.com swift service utility library for simplifying app acces to the