fileio 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11f0e3ae9674e1b662b9da75201d80902d3b8536
4
+ data.tar.gz: 9e5864d0be4185d300bdb7d456c9cdf5c2cbfc72
5
+ SHA512:
6
+ metadata.gz: 6706b3f31f28167eb98b7cbbde9b0c1332fc281ac59464202173ab7a7e2ff0d1b8ba53de7dbd74102f2776c72fbfe1d5e8614313fcc9be0f59f9910131f67ac8
7
+ data.tar.gz: 66b9e9fbc8525be4bae8fe8f16e25d34b481d32fa8bd0c812ae06abfe170395373263bfb35ca4824d42c3bee452cf131ad4dd092bb80a0cd55432b291ee41ee8
@@ -0,0 +1,41 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.2.8
11
+
12
+ # Specify service dependencies here if necessary
13
+ # CircleCI maintains a library of pre-built images
14
+ # documented at https://circleci.com/docs/2.0/circleci-images/
15
+ # - image: circleci/postgres:9.4
16
+
17
+ working_directory: ~/repo
18
+
19
+ steps:
20
+ - checkout
21
+
22
+ # Download and cache dependencies
23
+ - restore_cache:
24
+ keys:
25
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
26
+ # fallback to using the latest cache if no exact match is found
27
+ - v1-dependencies-
28
+
29
+ - run:
30
+ name: install dependencies
31
+ command: |
32
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
33
+
34
+ - save_cache:
35
+ paths:
36
+ - ./vendor/bundle
37
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
38
+
39
+ - run:
40
+ name: run tests
41
+ command: bundle exec rspec spec/
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.5
5
+ before_install: gem install bundler -v 1.12.3
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fileio.gemspec
4
+ gemspec
5
+ gem 'webmock'
6
+ gem 'vcr'
7
+ gem 'byebug'
@@ -0,0 +1,31 @@
1
+ # Fileio
2
+
3
+ Fileio upload your file to file.io
4
+
5
+ All you need is: `Fileio.upload(path)`
6
+
7
+ If you need to control when the file will expire:
8
+ ```
9
+ Fileio.upload(path, expires: '3d')
10
+ ```
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'fileio'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install fileio
27
+
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/phuongnd08/fileio.
31
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -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 'fileio/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fileio"
8
+ spec.version = Fileio::VERSION
9
+ spec.authors = ["Phuong Nguyen"]
10
+ spec.email = ["phuongnd08@gmail.com"]
11
+
12
+ spec.summary = %q{Quickly upload to file.io}
13
+ spec.description = %q{Quickly upload to file.io}
14
+ spec.homepage = "https://github.com/phuongnd08/fileio-ruby"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "bin"
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.12"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ end
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://file.io/?expires=3d
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
+ Host:
17
+ - file.io
18
+ Content-Type:
19
+ - multipart/form-data
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 15 Feb 2019 06:29:18 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '81'
31
+ Connection:
32
+ - keep-alive
33
+ X-Powered-By:
34
+ - Express
35
+ X-Ratelimit-Limit:
36
+ - '5'
37
+ X-Ratelimit-Remaining:
38
+ - '2'
39
+ Access-Control-Allow-Origin:
40
+ - "*"
41
+ Access-Control-Allow-Headers:
42
+ - Cache-Control,X-reqed-With,x-requested-with
43
+ Etag:
44
+ - W/"51-zE9nUHWKQ22Vce9BHxZLsH4JOWk"
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"success":true,"key":"7GpnJB","link":"https://file.io/7GpnJB","expiry":"3
48
+ days"}'
49
+ http_version:
50
+ recorded_at: Fri, 15 Feb 2019 06:29:18 GMT
51
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://file.io/
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
+ Host:
17
+ - file.io
18
+ Content-Type:
19
+ - multipart/form-data
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 15 Feb 2019 06:29:16 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '82'
31
+ Connection:
32
+ - keep-alive
33
+ X-Powered-By:
34
+ - Express
35
+ X-Ratelimit-Limit:
36
+ - '5'
37
+ X-Ratelimit-Remaining:
38
+ - '4'
39
+ Access-Control-Allow-Origin:
40
+ - "*"
41
+ Access-Control-Allow-Headers:
42
+ - Cache-Control,X-reqed-With,x-requested-with
43
+ Etag:
44
+ - W/"52-JLbd0Pjc7xCyO0ZE/FoZkdXhM1g"
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"success":true,"key":"7Y9ivE","link":"https://file.io/7Y9ivE","expiry":"14
48
+ days"}'
49
+ http_version:
50
+ recorded_at: Fri, 15 Feb 2019 06:29:16 GMT
51
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,26 @@
1
+ require 'fileio/version'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require 'json'
5
+
6
+ module Fileio
7
+ def self.upload(path, expires: nil)
8
+ url = "https://file.io"
9
+ if expires
10
+ url += "?expires=#{expires}"
11
+ end
12
+
13
+ uri = URI.parse(url)
14
+ request = Net::HTTP::Post.new(uri)
15
+ form_data = [['file', File.open(path, "rb")]] # or File.open() in case of local file
16
+
17
+ request.set_form form_data, 'multipart/form-data'
18
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| # pay attention to use_ssl if you need it
19
+ http.request(request)
20
+ end
21
+
22
+ JSON.parse(response.body).tap do |result|
23
+ puts result["link"]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Fileio
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fileio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Phuong Nguyen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-15 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Quickly upload to file.io
56
+ email:
57
+ - phuongnd08@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".circleci/config.yml"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - README.md
68
+ - Rakefile
69
+ - fileio.gemspec
70
+ - fixtures/vcr_cassettes/Fileio/_upload/with_expiration_time/returns_json_of_upload.yml
71
+ - fixtures/vcr_cassettes/Fileio/_upload/without_expiration_time/returns_json_of_upload.yml
72
+ - lib/fileio.rb
73
+ - lib/fileio/version.rb
74
+ homepage: https://github.com/phuongnd08/fileio-ruby
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.5.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Quickly upload to file.io
97
+ test_files: []