ompload 1.0.1 → 1.0.2

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.
Files changed (5) hide show
  1. data/CHANGELOG.md +12 -4
  2. data/LICENSE +3 -1
  3. data/bin/ompload +7 -1
  4. data/lib/ompload.rb +22 -11
  5. metadata +18 -28
@@ -1,6 +1,14 @@
1
+ # 1.0.2
2
+ - c4cfe0f Bump version.
3
+ - 40a6c36 Add version flag.
4
+ - 07e9166 Add copyright.
5
+ - 6e27854 Decrease max file size to 1GiB.
6
+ - 88feafc Correct stdin size limitation.
7
+
1
8
  # 1.0.1
2
- pick bffc337 Version bump.
3
- pick 9e0d8d6 Better README and usage.
4
- pick 06ff5d3 Update github username.
9
+ - bffc337 Version bump.
10
+ - 9e0d8d6 Better README and usage.
11
+ - 06ff5d3 Update github username.
12
+
5
13
  # 1.0.0
6
- Initial release.
14
+ - Initial release.
data/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (C) 2011 Murilo Pereira <murilo@murilopereira.com>
1
+ Copyright (C) 2007-2012 David Shakaryan <omp@gentoo.org>
2
+ Copyright (C) 2007-2012 Brenden Matthews <brenden@diddyinc.com>
3
+ Copyright (C) 2010-2012 Murilo Pereira <murilo@murilopereira.com>
2
4
 
3
5
  This program is free software: you can redistribute it and/or modify
4
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Copyright 2010-2011 Murilo Pereira <murilo@murilopereira.com>
3
+ # Copyright 2007-2012 David Shakaryan <omp@gentoo.org>
4
+ # Copyright 2007-2012 Brenden Matthews <brenden@diddyinc.com>
5
+ # Copyright 2010-2012 Murilo Pereira <murilo@murilopereira.com>
6
+ #
4
7
  # Distributed under the terms of the GNU General Public License v3
5
8
  #
6
9
 
@@ -11,6 +14,7 @@ opts = GetoptLong.new(['--help', '-h', GetoptLong::NO_ARGUMENT],
11
14
  ['--filename', '-f', GetoptLong::REQUIRED_ARGUMENT],
12
15
  ['--quiet', '-q', GetoptLong::NO_ARGUMENT],
13
16
  ['--url', '-u', GetoptLong::NO_ARGUMENT],
17
+ ['--version', '-v', GetoptLong::NO_ARGUMENT],
14
18
  ['--no-clip', '-n', GetoptLong::NO_ARGUMENT])
15
19
 
16
20
  options = { :clip => true }
@@ -27,6 +31,8 @@ opts.each do |opt, arg|
27
31
  options[:url] = true
28
32
  when '--no-clip'
29
33
  options[:clip] = false
34
+ when '--version'
35
+ options[:version] = true
30
36
  end
31
37
  end
32
38
 
@@ -55,8 +55,8 @@ module Omploader
55
55
  end
56
56
 
57
57
  module Ompload
58
- VERSION = '1.0.1'
59
- MAX_FILE_SIZE = 2**32
58
+ VERSION = '1.0.2'
59
+ MAX_FILE_SIZE = 2**20
60
60
 
61
61
  USAGE = <<-USAGE.gsub(/^ /, '')
62
62
  Usage: ompload [-h|--help] [options] [file(s)]
@@ -64,6 +64,7 @@ module Ompload
64
64
  -u, --url Only output URLs
65
65
  -f, --filename File name on omploader for when piping data via stdin
66
66
  -n, --no-clip Disable copying of the URL to the clipboard
67
+ -v, --version Show version
67
68
 
68
69
  You can supply a list of files or data via stdin (or both)
69
70
  USAGE
@@ -94,9 +95,9 @@ module Ompload
94
95
  "error: '#{file_path}' does not exist or is not a regular file"
95
96
  end
96
97
 
97
- def file_too_big(file_path)
98
+ def payload_too_big(file_path, file_size)
98
99
  "error: '#{file_path}' exceeds #{MAX_FILE_SIZE} bytes " <<
99
- "(size is #{File.size(file_path)})."
100
+ "(size is #{file_size})."
100
101
  end
101
102
  end
102
103
 
@@ -119,7 +120,7 @@ module Ompload
119
120
  STDERR.puts Message.invalid_file(file_path)
120
121
  ErrorCounter.instance.increment!
121
122
  elsif File.size(file_path) > MAX_FILE_SIZE
122
- STDERR.puts Message.file_too_big(file_path)
123
+ STDERR.puts Message.payload_too_big(file_path,File.size(file_path))
123
124
  ErrorCounter.instance.increment!
124
125
  else
125
126
  handle_file(file_path, options)
@@ -129,11 +130,16 @@ module Ompload
129
130
 
130
131
  def handle_data(data, options = {})
131
132
  file_name = options[:file_name] || 'piped data'
132
- puts Message.progress(file_name) if !options[:quiet] && !options[:url]
133
- response = upload_with_curl({ :data => data,
134
- :file_name => file_name,
135
- :silent => options[:quiet] || options[:url] })
136
- handle_response!(response, file_name, options)
133
+ if data.bytesize > MAX_FILE_SIZE
134
+ STDERR.puts Message.payload_too_big(file_name, data.bytesize)
135
+ ErrorCounter.instance.increment!
136
+ else
137
+ puts Message.progress(file_name) if !options[:quiet] && !options[:url]
138
+ response = upload_with_curl({ :data => data,
139
+ :file_name => file_name,
140
+ :silent => options[:quiet] || options[:url] })
141
+ handle_response!(response, file_name, options)
142
+ end
137
143
  rescue ThrottledError
138
144
  STDERR.puts Message.throttled(file_name)
139
145
  sleep(60) and retry
@@ -181,10 +187,15 @@ module Ompload
181
187
  abort('error: curl missing or not in path. Cannot continue.')
182
188
  end
183
189
 
190
+ if options[:version]
191
+ puts VERSION
192
+ exit
193
+ end
194
+
184
195
  abort(USAGE) if ARGV.size < 1 && !piped_data_given? || options[:help]
185
196
 
186
197
  UploadsHandler.handle_files(ARGV, options)
187
- UploadsHandler.handle_data(STDIN.read(4096), options) if piped_data_given?
198
+ UploadsHandler.handle_data(STDIN.read(), options) if piped_data_given?
188
199
 
189
200
  if xclip_installed? && options[:clip] && !XclipBuffer.instance.content.empty?
190
201
  IO.popen('xclip', 'w+').puts XclipBuffer.instance.content
metadata CHANGED
@@ -1,28 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ompload
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
4
5
  prerelease:
5
- version: 1.0.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Murilo Pereira
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-26 00:00:00 -03:00
14
- default_executable:
12
+ date: 2012-12-27 00:00:00.000000000 Z
15
13
  dependencies: []
16
-
17
14
  description:
18
15
  email: murilo@murilopereira.com
19
- executables:
16
+ executables:
20
17
  - ompload
21
18
  extensions: []
22
-
23
19
  extra_rdoc_files: []
24
-
25
- files:
20
+ files:
26
21
  - .gitignore
27
22
  - CHANGELOG.md
28
23
  - LICENSE
@@ -30,33 +25,28 @@ files:
30
25
  - bin/ompload
31
26
  - lib/ompload.rb
32
27
  - ompload.gemspec
33
- has_rdoc: true
34
28
  homepage: https://github.com/mpereira/ompload
35
29
  licenses: []
36
-
37
30
  post_install_message:
38
31
  rdoc_options: []
39
-
40
- require_paths:
32
+ require_paths:
41
33
  - .
42
- required_ruby_version: !ruby/object:Gem::Requirement
34
+ required_ruby_version: !ruby/object:Gem::Requirement
43
35
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
48
- required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
41
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
53
45
  version: 1.3.6
54
46
  requirements: []
55
-
56
47
  rubyforge_project:
57
- rubygems_version: 1.6.2
48
+ rubygems_version: 1.8.24
58
49
  signing_key:
59
50
  specification_version: 3
60
51
  summary: Upload files to omploader.
61
52
  test_files: []
62
-