readonce 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/readonce +42 -0
- data/bin/setup +7 -0
- data/fixtures/vcr_cassettes/create-file.yml +44 -0
- data/fixtures/vcr_cassettes/key-does-not-exist.yml +44 -0
- data/fixtures/vcr_cassettes/key-exists.yml +44 -0
- data/lib/readonce/version.rb +3 -0
- data/lib/readonce.rb +38 -0
- data/readonce.gemspec +29 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 00699973a8a36e6611b8b3ee1370a2dce4c6d9c0
|
4
|
+
data.tar.gz: ec5ba588479252584f3f41e41ea1ea2a3839b734
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2cdd4c7c2d487aacad5e5bc3630a9541ee7f2ca7069f58ab377ec3f2ab1657e69807adb0029dfe8e909ede5a1a89623b96d8b7e772c87aa92ad6ebef464510a
|
7
|
+
data.tar.gz: 67452cf4b7dd77bed05132d04fd2dfc45573748672cfa4ab853ef1a0470b7a794f3b21536c2a7bd6c68402f0025497aed1fe53c39cb337c93f45b7cd6727e46b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Robby Grossman
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Readonce
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/readonce`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'readonce'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install readonce
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/readonce.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "readonce"
|
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/readonce
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.setup
|
6
|
+
require 'readonce'
|
7
|
+
|
8
|
+
# No arguments: we stash a file, nothing else.
|
9
|
+
if ARGV.count == 0
|
10
|
+
data = $stdin.read
|
11
|
+
obj = ReadOnce.from_data(data)
|
12
|
+
puts obj.read_url
|
13
|
+
elsif ARGV.count == 1 && (ARGV[0] == '-h' || ARGV[0] == '--help')
|
14
|
+
puts 'readonce -- provides a unique, one-time-use URL to share private data with someone.'
|
15
|
+
puts 'Common uses:'
|
16
|
+
puts ' readonce < myfile.txt # Share a file'
|
17
|
+
puts ' echo "The password is foo" | readonce # Share a line of text'
|
18
|
+
puts ' readonce -w < myfile.txt # Share a file, wait to exit until it is accessed'
|
19
|
+
puts ' readonce -w <key> # Wait to exit until file with specified key is accessed'
|
20
|
+
puts ' readonce -s <key> # Check the status of a file with specified key'
|
21
|
+
elsif ARGV.count == 1 && ARGV[0] == '-w' # Stash file, block until gone.
|
22
|
+
data = $stdin.read
|
23
|
+
obj = ReadOnce.from_data(data)
|
24
|
+
puts obj.read_url
|
25
|
+
puts 'Waiting for file to be accessed...'
|
26
|
+
obj.block_while_exists
|
27
|
+
puts "File accessed at #{Time.zone.now} (local time)."
|
28
|
+
elsif ARGV.count == 2 && ARGV[0] == '-w' # Block until gone.
|
29
|
+
obj = ReadOnce.from_key(ARGV[1])
|
30
|
+
puts 'Waiting for file to be accessed...'
|
31
|
+
obj.block_while_exists
|
32
|
+
puts "File accessed at #{Time.zone.now} (local time)."
|
33
|
+
elsif ARGV.count == 2 && ARGV[0] == '-s' # Get status of file
|
34
|
+
obj = ReadOnce.from_key(ARGV[1])
|
35
|
+
if obj.exists?
|
36
|
+
puts 'File has not been accessed.'
|
37
|
+
else
|
38
|
+
puts 'File does not exist (or has been accessed).'
|
39
|
+
end
|
40
|
+
else
|
41
|
+
puts 'Invalid options. See readonce --help for details.'
|
42
|
+
end
|
data/bin/setup
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://readonce-production.herokuapp.com/create
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: dummydata
|
9
|
+
headers:
|
10
|
+
accept-encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
accept:
|
13
|
+
- "*/*"
|
14
|
+
user-agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: 'OK '
|
20
|
+
headers:
|
21
|
+
connection:
|
22
|
+
- close
|
23
|
+
content-type:
|
24
|
+
- text/html;charset=utf-8
|
25
|
+
content-length:
|
26
|
+
- '32'
|
27
|
+
x-xss-protection:
|
28
|
+
- 1; mode=block
|
29
|
+
x-content-type-options:
|
30
|
+
- nosniff
|
31
|
+
x-frame-options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
server:
|
34
|
+
- WEBrick/1.3.1 (Ruby/2.2.4/2015-12-16)
|
35
|
+
date:
|
36
|
+
- Sun, 01 May 2016 04:25:41 GMT
|
37
|
+
via:
|
38
|
+
- 1.1 vegur
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: 3a84c711bcb5ff2afaa23e212f60bb04
|
42
|
+
http_version: '1.1'
|
43
|
+
recorded_at: Sun, 01 May 2016 04:25:40 GMT
|
44
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://readonce-production.herokuapp.com/status/a2b7385319449527d87468a3833365c4
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
accept-encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
accept:
|
13
|
+
- "*/*"
|
14
|
+
user-agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 404
|
19
|
+
message: 'Not Found '
|
20
|
+
headers:
|
21
|
+
connection:
|
22
|
+
- close
|
23
|
+
content-type:
|
24
|
+
- text/html;charset=utf-8
|
25
|
+
content-length:
|
26
|
+
- '9'
|
27
|
+
x-xss-protection:
|
28
|
+
- 1; mode=block
|
29
|
+
x-content-type-options:
|
30
|
+
- nosniff
|
31
|
+
x-frame-options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
server:
|
34
|
+
- WEBrick/1.3.1 (Ruby/2.2.4/2015-12-16)
|
35
|
+
date:
|
36
|
+
- Sun, 01 May 2016 04:51:20 GMT
|
37
|
+
via:
|
38
|
+
- 1.1 vegur
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: Not found
|
42
|
+
http_version: '1.1'
|
43
|
+
recorded_at: Sun, 01 May 2016 04:51:19 GMT
|
44
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://readonce-production.herokuapp.com/status/63d2e85319449527d87468a3833365c4
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
accept-encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
accept:
|
13
|
+
- "*/*"
|
14
|
+
user-agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: 'OK '
|
20
|
+
headers:
|
21
|
+
connection:
|
22
|
+
- close
|
23
|
+
content-type:
|
24
|
+
- text/html;charset=utf-8
|
25
|
+
content-length:
|
26
|
+
- '5'
|
27
|
+
x-xss-protection:
|
28
|
+
- 1; mode=block
|
29
|
+
x-content-type-options:
|
30
|
+
- nosniff
|
31
|
+
x-frame-options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
server:
|
34
|
+
- WEBrick/1.3.1 (Ruby/2.2.4/2015-12-16)
|
35
|
+
date:
|
36
|
+
- Sun, 01 May 2016 04:51:20 GMT
|
37
|
+
via:
|
38
|
+
- 1.1 vegur
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: Found
|
42
|
+
http_version: '1.1'
|
43
|
+
recorded_at: Sun, 01 May 2016 04:51:19 GMT
|
44
|
+
recorded_with: VCR 3.0.1
|
data/lib/readonce.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'readonce/version'
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
|
5
|
+
class ReadOnce
|
6
|
+
BASE_URI = 'http://readonce-production.herokuapp.com'
|
7
|
+
|
8
|
+
def self.from_key(key)
|
9
|
+
r = ReadOnce.new
|
10
|
+
r.instance_variable_set(:@key, key)
|
11
|
+
r
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.from_data(data)
|
15
|
+
response = HTTParty.post "#{BASE_URI}/create", body: data
|
16
|
+
r = ReadOnce.new
|
17
|
+
r.instance_variable_set(:@key, response.body)
|
18
|
+
r
|
19
|
+
end
|
20
|
+
|
21
|
+
def read_url
|
22
|
+
"#{BASE_URI}/#{key}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def exists?
|
26
|
+
response = HTTParty.get "#{BASE_URI}/status/#{key}"
|
27
|
+
response.code == 200 ? true : false
|
28
|
+
end
|
29
|
+
|
30
|
+
def block_while_exists
|
31
|
+
while exists? do
|
32
|
+
sleep 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
attr_accessor :key
|
38
|
+
end
|
data/readonce.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'readonce/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "readonce"
|
8
|
+
spec.version = Readonce::VERSION
|
9
|
+
spec.authors = ["Robby Grossman"]
|
10
|
+
spec.email = ["robby@freerobby.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Creates readonce entries.}
|
13
|
+
spec.description = %q{Creates readonce entries and provides a token URL.}
|
14
|
+
spec.homepage = "http://readonce-production.heroku.com."
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency 'httparty', '~> 0'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
25
|
+
spec.add_development_dependency 'fakeweb', '~> 1'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
28
|
+
spec.add_development_dependency 'vcr', '~> 3'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: readonce
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robby Grossman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fakeweb
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3'
|
97
|
+
description: Creates readonce entries and provides a token URL.
|
98
|
+
email:
|
99
|
+
- robby@freerobby.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/readonce
|
113
|
+
- bin/setup
|
114
|
+
- fixtures/vcr_cassettes/create-file.yml
|
115
|
+
- fixtures/vcr_cassettes/key-does-not-exist.yml
|
116
|
+
- fixtures/vcr_cassettes/key-exists.yml
|
117
|
+
- lib/readonce.rb
|
118
|
+
- lib/readonce/version.rb
|
119
|
+
- readonce.gemspec
|
120
|
+
homepage: http://readonce-production.heroku.com.
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.4.8
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Creates readonce entries.
|
144
|
+
test_files: []
|
145
|
+
has_rdoc:
|