wgif 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +4 -1
- data/Rakefile +2 -2
- data/lib/wgif.rb +1 -0
- data/lib/wgif/argument_parser.rb +5 -0
- data/lib/wgif/cli.rb +6 -0
- data/lib/wgif/info_displayer.rb +28 -0
- data/lib/wgif/version.rb +1 -1
- data/spec/regression/empty_image_list_spec.rb +1 -1
- data/spec/regression/frame_order_spec.rb +1 -1
- data/spec/unit/wgif/argument_parser_spec.rb +11 -1
- data/spec/unit/wgif/info_displayer_spec.rb +24 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ed2ac4b217c2e89a5cb10457bfe034cf33bd2e2
|
4
|
+
data.tar.gz: 5be6c8d1d554a480c5b8e9608b92ed4c2b045b9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11830559415baf6c9055d632eac62ac170d238f2c875c526360479c762af7cb41b42b051574fdaaf9c94c8987eddb5a4ee5a637ed8b01ba812879a23a4ae9321
|
7
|
+
data.tar.gz: c274785b222bbaafd5da24ddfb7160ddc25a004a71b442de1ca3b0304ed399f6e1a658ede4ee5d1cb421879d94abb19a68e4cc953342846993c1e0877aea7746
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -14,11 +14,12 @@ Usage: wgif [YouTube URL] [output file] [options]
|
|
14
14
|
-w, --width pixels Width of the gif in pixels. (Default 480px)
|
15
15
|
-u, --upload Upload finished gif to Imgur
|
16
16
|
-p, --preview Preview finished gif with Quick Look
|
17
|
+
-i, --info Displays info about finished gif (currently just file size)
|
17
18
|
-h, --help Print help information.
|
18
19
|
|
19
20
|
Example:
|
20
21
|
|
21
|
-
$ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif -s 00:03:30 -d 2 -w 400 --upload
|
22
|
+
$ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif -s 00:03:30 -d 2 -w 400 -i --upload
|
22
23
|
```
|
23
24
|
|
24
25
|
## Installation (Mac OS X)
|
@@ -113,11 +114,13 @@ And here it is:
|
|
113
114
|
### "You shouldn't let poets lie to you."
|
114
115
|
|
115
116
|
## Changes
|
117
|
+
- v0.3.1, 2014/5/10: Fixes frame order for gifs with more than 100 frames. ([Issue #14](https://github.com/ecmendenhall/wgif/issues/14))
|
116
118
|
- v0.3.0, 2014/4/20: Add Quick Look preview with `--preview` flag.
|
117
119
|
- v0.2.0, 2014/4/11: Add automatic upload to Imgur with `--upload` flag.
|
118
120
|
|
119
121
|
## Contributors
|
120
122
|
Thanks to [arlandism](https://github.com/arlandism) and [ellie007](https://github.com/ellie007) for pairing on Imgur uploads.
|
123
|
+
Thanks to [justalisteningman](https://github.com/justalisteningman) for adding file size info.
|
121
124
|
|
122
125
|
## Contributions
|
123
126
|
Are welcome via pull request.
|
data/Rakefile
CHANGED
@@ -2,8 +2,8 @@ require 'bundler/gem_tasks'
|
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec, :tag) do |t, task_args|
|
5
|
-
unless task_args[:tag] == '
|
6
|
-
t.rspec_opts = "--tag ~
|
5
|
+
unless task_args[:tag] == 'regression'
|
6
|
+
t.rspec_opts = "--tag ~regression"
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
data/lib/wgif.rb
CHANGED
data/lib/wgif/argument_parser.rb
CHANGED
@@ -40,6 +40,11 @@ module WGif
|
|
40
40
|
'Upload finished gif to Imgur') {
|
41
41
|
|u| @options[:upload] = u
|
42
42
|
}
|
43
|
+
opts.on('-i',
|
44
|
+
'--info',
|
45
|
+
'Displays info about finished gif (currently just file size)') {
|
46
|
+
|i| @options[:info] = i
|
47
|
+
}
|
43
48
|
opts.on('-p',
|
44
49
|
'--preview',
|
45
50
|
'Preview finished gif with Quick Look') {
|
data/lib/wgif/cli.rb
CHANGED
@@ -18,6 +18,7 @@ module WGif
|
|
18
18
|
args = @argument_parser.parse(cli_args)
|
19
19
|
frames = convert_video(args)
|
20
20
|
GifMaker.new.make_gif(frames, args[:output], args[:dimensions])
|
21
|
+
display_info(args) if args[:info]
|
21
22
|
upload(args) if args[:upload]
|
22
23
|
preview(args) if args[:preview]
|
23
24
|
end
|
@@ -25,6 +26,10 @@ module WGif
|
|
25
26
|
|
26
27
|
private
|
27
28
|
|
29
|
+
def display_info(args)
|
30
|
+
InfoDisplayer.new.display(args[:output])
|
31
|
+
end
|
32
|
+
|
28
33
|
def preview(args)
|
29
34
|
Kernel.system "qlmanage -p #{args[:output]} &>/dev/null"
|
30
35
|
end
|
@@ -42,6 +47,7 @@ module WGif
|
|
42
47
|
|
43
48
|
def load_dependencies
|
44
49
|
require 'wgif/downloader'
|
50
|
+
require 'wgif/info_displayer'
|
45
51
|
require 'wgif/gif_maker'
|
46
52
|
require 'wgif/uploader'
|
47
53
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module WGif
|
2
|
+
class InfoDisplayer
|
3
|
+
|
4
|
+
GIGA_SIZE = 1073741824.0
|
5
|
+
MEGA_SIZE = 1048576.0
|
6
|
+
KILO_SIZE = 1024.0
|
7
|
+
|
8
|
+
def display(file_name)
|
9
|
+
file_size = readable_file_size(File.size("#{file_name}").to_f)
|
10
|
+
puts "#{file_name} is #{file_size}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def readable_file_size(size)
|
14
|
+
|
15
|
+
if size < KILO_SIZE
|
16
|
+
abb, div = "Bytes", 1
|
17
|
+
elsif size < MEGA_SIZE
|
18
|
+
abb, div = "KB", KILO_SIZE
|
19
|
+
elsif size < GIGA_SIZE
|
20
|
+
abb, div = "MB", MEGA_SIZE
|
21
|
+
else
|
22
|
+
abb, div = "GB", GIGA_SIZE
|
23
|
+
end
|
24
|
+
|
25
|
+
"%.3f #{abb}" % (size / div)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/wgif/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'wgif/cli'
|
3
3
|
|
4
|
-
describe 'empty image list bug',
|
4
|
+
describe 'empty image list bug', regression: true do
|
5
5
|
it 'throws an empty image list error' do
|
6
6
|
args = ['https://www.youtube.com/watch?v=deFDlB8RiNg',
|
7
7
|
'fish_grease.gif',
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'wgif/cli'
|
3
3
|
|
4
|
-
describe 'frame order bug',
|
4
|
+
describe 'frame order bug', regression: true do
|
5
5
|
it 'does not create frames out of order' do
|
6
6
|
args = ['https://www.youtube.com/watch?v=piWCBOsJr-w',
|
7
7
|
'banana-shoot.gif',
|
@@ -79,6 +79,16 @@ describe WGif::ArgumentParser do
|
|
79
79
|
expect(options[:preview]).to eq(true)
|
80
80
|
end
|
81
81
|
|
82
|
+
it 'parses the short output option' do
|
83
|
+
options = parser.parse_options ['-i']
|
84
|
+
expect(options[:info]).to eq(true)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'parses the long output option' do
|
88
|
+
options = parser.parse_options ['--info']
|
89
|
+
expect(options[:info]).to eq(true)
|
90
|
+
end
|
91
|
+
|
82
92
|
it 'handles args in wacky order' do
|
83
93
|
args = parser.parse_args([
|
84
94
|
'-d',
|
@@ -150,4 +160,4 @@ describe WGif::ArgumentParser do
|
|
150
160
|
trim_from: '00:00:00',
|
151
161
|
url: 'http://lol.wut'})
|
152
162
|
end
|
153
|
-
end
|
163
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'wgif/info_displayer'
|
3
|
+
|
4
|
+
describe WGif::InfoDisplayer do
|
5
|
+
|
6
|
+
let(:cache) { described_class.new }
|
7
|
+
|
8
|
+
before do
|
9
|
+
@mock_stdout = StringIO.new
|
10
|
+
@real_stdout, $stdout = $stdout, @mock_stdout
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
$stdout = @real_stdout
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'prints out a file size to the command line' do
|
18
|
+
file_name = "fake_file_name.rb"
|
19
|
+
File.stub(:size).with(file_name).and_return("1048576")
|
20
|
+
cache.display(file_name)
|
21
|
+
expect(@mock_stdout.string).to match(/1.000 MB/)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wgif
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connor Mendenhall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- lib/wgif/downloader.rb
|
189
189
|
- lib/wgif/exceptions.rb
|
190
190
|
- lib/wgif/gif_maker.rb
|
191
|
+
- lib/wgif/info_displayer.rb
|
191
192
|
- lib/wgif/installer.rb
|
192
193
|
- lib/wgif/uploader.rb
|
193
194
|
- lib/wgif/version.rb
|
@@ -201,6 +202,7 @@ files:
|
|
201
202
|
- spec/unit/wgif/download_bar_spec.rb
|
202
203
|
- spec/unit/wgif/downloader_spec.rb
|
203
204
|
- spec/unit/wgif/gif_maker_spec.rb
|
205
|
+
- spec/unit/wgif/info_displayer_spec.rb
|
204
206
|
- spec/unit/wgif/installer_spec.rb
|
205
207
|
- spec/unit/wgif/uploader_spec.rb
|
206
208
|
- spec/unit/wgif/video_cache_spec.rb
|
@@ -240,6 +242,7 @@ test_files:
|
|
240
242
|
- spec/unit/wgif/download_bar_spec.rb
|
241
243
|
- spec/unit/wgif/downloader_spec.rb
|
242
244
|
- spec/unit/wgif/gif_maker_spec.rb
|
245
|
+
- spec/unit/wgif/info_displayer_spec.rb
|
243
246
|
- spec/unit/wgif/installer_spec.rb
|
244
247
|
- spec/unit/wgif/uploader_spec.rb
|
245
248
|
- spec/unit/wgif/video_cache_spec.rb
|