wgif 0.0.1.pre → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29562cbe754b572ffd1fc5e20a397b96405a703b
4
- data.tar.gz: 3c7307a0a239c7867d2d6a205c14153e8b7c44f3
3
+ metadata.gz: d808e6c96d0dfe1070dbcdc750412e5b4f84c862
4
+ data.tar.gz: 242b7baf97aa7968e7e082af1de2ea6c933a24d7
5
5
  SHA512:
6
- metadata.gz: 5953cef31a710c37e9d99e229673005c4737f20952150b398a678088b45ee67b61835d5311a1271a0aaae454b9299de2e3c1253efd135bdcc3b9ed65c22024b1
7
- data.tar.gz: bfb4c0a042e3baefaca3f35621787041e0870f4c98a2cfba4cac5cb4e4cb0ec939a6b8ee941d1752588268cc3b748a8ac8fb38ea4b9c110363179e72e50f2ee5
6
+ metadata.gz: b0e44313b6eb58f5c8adae849d3466eed79131707d9a107494e6ec3cf425bc9cd774ea5fdd7f34c5c2101d836e537cc8bcafe85349afef2b12f0bff5788c0455
7
+ data.tar.gz: 8241d6bb255012480ffb84b79f6bea5adf6b4182eb8d0d680f7c971859bd5fd03a4b28500c9ec51fe310240c5c73d10a8a17c013bc01a6761aa02346db968505
@@ -1,7 +1,5 @@
1
1
  require 'optparse'
2
2
  require 'wgif/exceptions'
3
- require 'wgif/downloader'
4
- require 'wgif/gif_maker'
5
3
  require 'wgif/installer'
6
4
 
7
5
  module WGif
@@ -65,6 +63,8 @@ module WGif
65
63
 
66
64
  def make_gif(cli_args)
67
65
  WGif::Installer.new.run if cli_args[0] == 'install'
66
+ require 'wgif/downloader'
67
+ require 'wgif/gif_maker'
68
68
  rescue_errors do
69
69
  args = parse_args cli_args
70
70
  validate_args(args)
@@ -1,17 +1,27 @@
1
1
  module WGif
2
2
  class Installer
3
3
 
4
- DEPENDENCIES = [['ffmpeg', 'ffmpeg'], ['imagemagick', 'convert']]
4
+ DEPENDENCIES = [['ffmpeg', 'ffmpeg'],
5
+ ['imagemagick', 'convert']]
5
6
 
6
7
  def run
8
+ if dependencies_installed?
9
+ puts "All dependencies are installed. Go make a GIF."
10
+ Kernel.exit 0
11
+ end
7
12
  if homebrew_installed?
8
13
  DEPENDENCIES.each do |dependency, binary|
9
14
  install(dependency, binary)
10
15
  end
11
16
  else
12
17
  puts "WGif can't find Homebrew. Visit http://brew.sh/ to get it."
13
- Kernel.exit 0
18
+ Kernel.exit 1
14
19
  end
20
+ Kernel.exit 0
21
+ end
22
+
23
+ def dependencies_installed?
24
+ DEPENDENCIES.map {|_, binary| installed?(binary)}.inject(:&)
15
25
  end
16
26
 
17
27
  def homebrew_installed?
@@ -21,7 +31,7 @@ module WGif
21
31
  def install(dependency, binary)
22
32
  unless installed?(binary)
23
33
  puts "Installing #{dependency}..."
24
- Kernel.system "brew install #{dependency} > /dev/null"
34
+ Kernel.system "brew install #{dependency}"
25
35
  puts "Successfully installed #{dependency}."
26
36
  end
27
37
  end
@@ -1,3 +1,3 @@
1
1
  module WGif
2
- VERSION = "0.0.1.pre"
2
+ VERSION = "0.0.1"
3
3
  end
@@ -29,19 +29,39 @@ describe WGif::Installer do
29
29
 
30
30
  end
31
31
 
32
+ context 'checking for dependencies' do
33
+
34
+ it 'returns true if dependencies are installed' do
35
+ expect(Kernel).to receive(:system).with('which ffmpeg > /dev/null').
36
+ and_return(true)
37
+ expect(Kernel).to receive(:system).with('which convert > /dev/null').
38
+ and_return(true)
39
+ expect(installer.dependencies_installed?).to eq(true)
40
+ end
41
+
42
+ it 'returns false if dependencies are not installed' do
43
+ expect(Kernel).to receive(:system).with('which ffmpeg > /dev/null').
44
+ and_return(true)
45
+ expect(Kernel).to receive(:system).with('which convert > /dev/null').
46
+ and_return(false)
47
+ expect(installer.dependencies_installed?).to eq(false)
48
+ end
49
+
50
+ end
51
+
32
52
  context 'installing dependencies' do
33
53
 
34
54
  it 'does not install dependencies if they are found' do
35
55
  expect(Kernel).to receive(:system).with('which ffmpeg > /dev/null').
36
56
  and_return(true)
37
- expect(Kernel).not_to receive(:system).with('brew install ffmpeg > /dev/null')
57
+ expect(Kernel).not_to receive(:system).with('brew install ffmpeg')
38
58
  installer.install('ffmpeg', 'ffmpeg')
39
59
  end
40
60
 
41
61
  it 'installs dependencies' do
42
62
  expect(Kernel).to receive(:system).with('which ffmpeg > /dev/null').
43
63
  and_return(false)
44
- expect(Kernel).to receive(:system).with('brew install ffmpeg > /dev/null')
64
+ expect(Kernel).to receive(:system).with('brew install ffmpeg')
45
65
  installer.install('ffmpeg', 'ffmpeg')
46
66
  end
47
67
 
@@ -63,15 +83,19 @@ describe WGif::Installer do
63
83
  it 'installs all dependencies' do
64
84
  expect(Kernel).to receive(:system).with('brew info > /dev/null').
65
85
  and_return(true)
66
- expect(Kernel).to receive(:system).with('which ffmpeg > /dev/null').
86
+ expect(Kernel).to receive(:system).with('which ffmpeg > /dev/null').twice.
67
87
  and_return(true)
68
- expect(Kernel).to receive(:system).with('which convert > /dev/null').
88
+ expect(Kernel).to receive(:system).with('which convert > /dev/null').twice.
69
89
  and_return(false)
70
- expect(Kernel).to receive(:system).with('brew install imagemagick > /dev/null')
71
- installer.run
90
+ expect(Kernel).to receive(:system).with('brew install imagemagick')
91
+ expect{ installer.run }.to raise_error(SystemExit)
72
92
  end
73
93
 
74
94
  it 'prints a helpful error if homebrew is not found' do
95
+ expect(Kernel).to receive(:system).with('which ffmpeg > /dev/null').
96
+ and_return(true)
97
+ expect(Kernel).to receive(:system).with('which convert > /dev/null').
98
+ and_return(false)
75
99
  expect(Kernel).to receive(:system).with('brew info > /dev/null').
76
100
  and_return(false)
77
101
  expect{ installer.run }.to raise_error(SystemExit)
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.0.1.pre
4
+ version: 0.0.1
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-02-28 00:00:00.000000000 Z
11
+ date: 2014-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
@@ -201,9 +201,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  requirements:
204
- - - '>'
204
+ - - '>='
205
205
  - !ruby/object:Gem::Version
206
- version: 1.3.1
206
+ version: '0'
207
207
  requirements: []
208
208
  rubyforge_project:
209
209
  rubygems_version: 2.0.3