dead_drop 0.4.0.0 → 0.4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fe2ec6af9c3b6f5834ea8c80551d02fa6e6fa0d
4
- data.tar.gz: b217a9ec5663be952b14df2c1aff055574a2264d
3
+ metadata.gz: f61d0d3417d6a25aa211c401001a57644add9278
4
+ data.tar.gz: 53c387d6e9d87a8fe63c9c6d20fae643b6c89147
5
5
  SHA512:
6
- metadata.gz: c03e940f6e11a6765ad8b38848a14307a9a0111a5a121010b0ecdb4a33a39ba8a00be0c63d29db7dcfdda45a67d7a7a30ada4a6d25e582c23c15b7216d5c76ab
7
- data.tar.gz: 355950eed287eef995cd7d716de1158b9b31bdba14fd3f6400338ddfedea67c3caa58d7315150dbb6bfb922755bce68dd1ac7ca1392a641217651afa53ae1d2d
6
+ metadata.gz: efae49dd9f1f12f21563f3b60432bf884a6ee1fe5e6d841b315fe269f472f6aab4ca8570a1a9759216502b123ccaa5d6a403fca5b1bf78a8063fcab9f968ee01
7
+ data.tar.gz: dae89bf7cb59479969b43c030540d632a232195e4ee9e7c23d0daf1c5be01328a6b814db86f60b3fb19929b8d688ea208ea463b752a44ec2be2a5c88a5403e1f
@@ -0,0 +1,110 @@
1
+ DeadDrop [![Gem Version](https://badge.fury.io/rb/dead_drop.svg)](http://badge.fury.io/rb/dead_drop)
2
+ ========
3
+
4
+ DeadDrop is a Rails::Engine that allows you to drop content in an anonymous locker only accessible with a randomly generated token.
5
+
6
+ You can configure when the content should expire and limit the number of total accesses to the content.
7
+
8
+ DeadDrop can use any Cache::Store that supports the decrement method. This gem has been tested with :file_store, :memory_store, :mem_cache_store and :dalli_store.
9
+
10
+
11
+ Supported Ruby implementations
12
+ ------------------------------
13
+
14
+ DeadDrop should work on:
15
+
16
+ * JRuby
17
+ * Ruby
18
+ * Rubinius
19
+
20
+ If you have problems, please enter an issue.
21
+
22
+ Installation and Configuration
23
+ ------------------------------
24
+
25
+ Add `gem 'dead_drop'` to your Gemfile.
26
+
27
+ If you want to use the Controller option described below add this to your `routes.rb`:
28
+ ```ruby
29
+ mount DeadDrop::Engine, at: "/dead_drop" # Or any mount point you like
30
+ ```
31
+
32
+ You can configure this gem in `initializers/dead_drop.rb`. Here is an example with the default values:
33
+ ```ruby
34
+ DeadDrop.setup do |config|
35
+ config.cache_store = :file_store, 'tmp/cache', { # Just configure any Cache::Store as you'd normally do.
36
+ namespace: 'ddrop',
37
+ compress: true,
38
+ compress_threshold: 2*1024 # 2K
39
+ }
40
+ config.default_access_limit = nil # How many accesses do you want to allow by default? (nil: no limit)
41
+ config.default_expiration = 24.hours # When should content expire by default? (nil: no limit)
42
+ config.token_length = 32
43
+ config.default_salt = '' # Optionally salt tokens before computing the SHA256 when creating the cache key.
44
+ config.cache_key_creation = :base64digest # When generating the key from the salt+token (SHA256), use this representation.
45
+ # When using :file_store on Windows it is recommended to use :hexdigest
46
+ # representation in order to avoid collisions due to the case insensitive FS.
47
+ end
48
+ ```
49
+
50
+ If you want to use the same Cache::Store instance than the rest of your Rails app, just:
51
+ ```ruby
52
+ DeadDrop.setup do |config|
53
+ config.cache_store = Rails.cache
54
+ end
55
+ ```
56
+
57
+
58
+ Usage
59
+ -----
60
+
61
+ **Dropping**
62
+ ```ruby
63
+ csv_content = "col1, col2\n 1.012, John\n 4.332, Mary"
64
+ token = DeadDrop.drop(csv_content, filename: "data.csv", expiration: 5.minutes, limit: 1)
65
+ ```
66
+ *csv_content* has been saved in Cache::Store and a url friendly token has been returned.
67
+ This token can be used later to access programatically the resource or a url can be generated:
68
+ ```ruby
69
+ url = dead_drop.pick_url(token) # The resource will be rendered when accessed unless it was dropped with
70
+ # the 'filename' option (useful for storing static html pages, for instance)
71
+ url = dead_drop.download_url(token, 'file.dat') # The resource will always be downloaded
72
+ ```
73
+ This url is only useful if you have activated the custom controller in your `routes.rb` (described in installation section)
74
+
75
+
76
+ **Accessing Using Controller**
77
+
78
+ Just access to the url generated by above helpers which will show the content in the browser or download a file depending on the options you chose.
79
+
80
+ The url should look similar to `http://domain.com/dead_drop/3vTCwxjRC1oASZgY4MHwbWmQdL9l8Bwb`
81
+
82
+
83
+ **Accessing Programmatically**
84
+ ```ruby
85
+ content = DeadDrop.pick(token)
86
+ ```
87
+ If the token is still valid this hash will be returned: `{:resource=>content, :filename=>name, :mime_type=>mime}`. Else `nil` is returned.
88
+
89
+ If you just want to check the validity of the token without actually loading the resource:
90
+ ```ruby
91
+ DeadDrop.exists?(token)
92
+ ```
93
+
94
+
95
+ Helping Out
96
+ -----------
97
+
98
+ If you have a fix you wish to provide, please send a pull request on github.
99
+
100
+
101
+ Author
102
+ ------
103
+
104
+ Miguel Canton Cortes, [GitHub](http://github.com/miwelc)
105
+
106
+
107
+ Copyright
108
+ ---------
109
+
110
+ MIT Licensed
@@ -7,6 +7,7 @@ module DeadDrop
7
7
  mattr_accessor :default_access_limit
8
8
  mattr_accessor :default_expiration
9
9
  mattr_accessor :default_salt
10
+ mattr_accessor :token_length
10
11
  mattr_accessor :cache_key_creation
11
12
  mattr_accessor :cache
12
13
 
@@ -18,6 +19,7 @@ module DeadDrop
18
19
  self.default_salt = ''
19
20
  self.default_access_limit = nil
20
21
  self.default_expiration = 24.hours
22
+ self.token_length = 32
21
23
  self.cache_key_creation = :base64digest
22
24
  end
23
25
 
@@ -40,7 +42,7 @@ module DeadDrop
40
42
 
41
43
  token = ""
42
44
  loop do
43
- token = SecureRandom.urlsafe_base64(24)
45
+ token = SecureRandom.urlsafe_base64((DeadDrop.token_length*3)/4)
44
46
  break unless DeadDrop.exists?(token, salt: options[:salt])
45
47
  end
46
48
 
@@ -1,3 +1,3 @@
1
1
  module DeadDrop
2
- VERSION = "0.4.0.0"
2
+ VERSION = "0.4.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dead_drop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.0
4
+ version: 0.4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Canton Cortes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-28 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +60,7 @@ files:
60
60
  - lib/tasks/dead_drop_tasks.rake
61
61
  - MIT-LICENSE
62
62
  - Rakefile
63
+ - README.md
63
64
  - test/dead_drop_test.rb
64
65
  - test/test_helper.rb
65
66
  - test/dummy/config.ru