eff 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.simplecov +3 -0
- data/.travis.yml +17 -0
- data/Gemfile +4 -0
- data/Guardfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/bin/eff +3 -0
- data/eff.gemspec +34 -0
- data/lib/eff.rb +5 -0
- data/lib/eff/downloader.rb +47 -0
- data/lib/eff/package.rb +55 -0
- data/lib/eff/package/semantic_version.rb +29 -0
- data/lib/eff/template.rb +54 -0
- data/lib/eff/verifier.rb +10 -0
- data/lib/eff/version.rb +3 -0
- data/spec/downloader_spec.rb +130 -0
- data/spec/eff_spec.rb +7 -0
- data/spec/package_semantic_version_spec.rb +34 -0
- data/spec/package_spec.rb +58 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/support/static_file_for_digesting.txt +7 -0
- data/spec/template_spec.rb +29 -0
- data/spec/verifier_spec.rb +20 -0
- metadata +248 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 64373ef4d04e08aa57e86223ecdfcdc894c42284
|
4
|
+
data.tar.gz: caf6cb5718cd8f233544c6677f49986bca2a4918
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b64d1437efd27bbc7658343800eaf61861578639eb048e154131cdff4abfd583d5e83eae59d99057fcd91250e016aede19cd6128ebef267ed5721c8d1f2b06c
|
7
|
+
data.tar.gz: 7d050694d14e74b32595793f48b9926ce1e0e99d3bb8651d78291083e551d4c946ecac25e67f8e7ce0a178ccbfdc046c223aacd4e38f8e5cf9859dacb30dbee2
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --profile --format p
|
data/.simplecov
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- jruby-19mode
|
6
|
+
- jruby-head
|
7
|
+
- rbx-19mode
|
8
|
+
script: bundle exec rspec spec
|
9
|
+
branches:
|
10
|
+
only:
|
11
|
+
- master
|
12
|
+
matrix:
|
13
|
+
fast_finish: true
|
14
|
+
allow_failures:
|
15
|
+
- rvm: jruby-19mode
|
16
|
+
- rvm: jruby-head
|
17
|
+
- rvm: rbx-19mode
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
9
|
+
end
|
10
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Brandon Dennis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Eff
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'eff'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install eff
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/eff
ADDED
data/eff.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eff/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "eff"
|
8
|
+
spec.version = Eff::VERSION
|
9
|
+
spec.authors = ["Brandon Dennis"]
|
10
|
+
spec.email = ["toady00@gmail.com"]
|
11
|
+
spec.description = %q{Wrapper around fpm (effing package manager)}
|
12
|
+
spec.summary = %q{Wrapper around fpm (effing package manager)}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "fpm"
|
22
|
+
spec.add_dependency "faraday"
|
23
|
+
spec.add_dependency "typhoeus", "~> 0.6.7"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "guard"
|
29
|
+
spec.add_development_dependency "guard-rspec"
|
30
|
+
spec.add_development_dependency "pry"
|
31
|
+
spec.add_development_dependency "pry-plus"
|
32
|
+
spec.add_development_dependency "simplecov"
|
33
|
+
spec.add_development_dependency "fakefs"
|
34
|
+
end
|
data/lib/eff.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module Eff
|
4
|
+
class Downloader
|
5
|
+
attr_reader :uri, :file, :response
|
6
|
+
|
7
|
+
def initialize(url, file)
|
8
|
+
self.uri = URI(url)
|
9
|
+
self.file = file
|
10
|
+
end
|
11
|
+
|
12
|
+
def get
|
13
|
+
@response = Faraday.get(uri)
|
14
|
+
end
|
15
|
+
|
16
|
+
def save
|
17
|
+
File.open(file, 'wb') do |f|
|
18
|
+
f.write(response_body)
|
19
|
+
end if success?
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO: should this really trigger it to download?
|
23
|
+
def success?
|
24
|
+
get unless response
|
25
|
+
@response.success?
|
26
|
+
end
|
27
|
+
|
28
|
+
def file=(value)
|
29
|
+
clear_response!
|
30
|
+
@file = File.expand_path(value, Dir.pwd)
|
31
|
+
end
|
32
|
+
|
33
|
+
def uri=(value)
|
34
|
+
clear_response!
|
35
|
+
@uri = URI(value)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def response_body
|
40
|
+
response.body
|
41
|
+
end
|
42
|
+
|
43
|
+
def clear_response!
|
44
|
+
@response = nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/eff/package.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'eff/downloader'
|
2
|
+
require 'eff/template'
|
3
|
+
require 'eff/package/semantic_version'
|
4
|
+
|
5
|
+
module Eff
|
6
|
+
class Package
|
7
|
+
attr_accessor :save_file, :version
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@url_template = options[:url_template]
|
11
|
+
self.save_file = options[:save_file]
|
12
|
+
self.version = options[:version]
|
13
|
+
new_downloader
|
14
|
+
end
|
15
|
+
|
16
|
+
def download
|
17
|
+
downloader.get
|
18
|
+
end
|
19
|
+
|
20
|
+
def save
|
21
|
+
downloader.save
|
22
|
+
end
|
23
|
+
|
24
|
+
# TODO: should this really trigger it to download?
|
25
|
+
def downloaded?
|
26
|
+
downloader.success?
|
27
|
+
end
|
28
|
+
|
29
|
+
def url
|
30
|
+
template = Eff::Template.new(@url_template, version)
|
31
|
+
template.result
|
32
|
+
end
|
33
|
+
|
34
|
+
def save_file=(value)
|
35
|
+
@save_file = File.expand_path(value, Dir.pwd)
|
36
|
+
end
|
37
|
+
|
38
|
+
def version=(value)
|
39
|
+
@version = SemanticVersion.new(value)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def downloader
|
44
|
+
@downloader
|
45
|
+
end
|
46
|
+
|
47
|
+
def new_downloader
|
48
|
+
@downloader = Eff::Downloader.new(url, save_file)
|
49
|
+
end
|
50
|
+
|
51
|
+
def download_response
|
52
|
+
downloader.response
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Eff
|
2
|
+
class Package
|
3
|
+
class SemanticVersion
|
4
|
+
PARTS = %i(major minor patch release identity)
|
5
|
+
|
6
|
+
PARTS.each do |part|
|
7
|
+
attr_accessor part
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(version_string)
|
11
|
+
@version_string = version_string
|
12
|
+
parse!
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_h
|
16
|
+
Hash[
|
17
|
+
PARTS.map { |part| [part, send(part)] }
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def parse!
|
23
|
+
remaining, @identity = @version_string.split("+")
|
24
|
+
remaining, @release = remaining.split("-")
|
25
|
+
@major, @minor, @patch = remaining.split(".")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/eff/template.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Eff
|
4
|
+
class Template
|
5
|
+
attr_reader :result, :src
|
6
|
+
|
7
|
+
def initialize(src, erb_vars = {})
|
8
|
+
@src = ERB.new(src)
|
9
|
+
self.erb_vars = erb_vars
|
10
|
+
end
|
11
|
+
|
12
|
+
def erb_vars=(value)
|
13
|
+
@erb_vars = normalize_erb_vars(value)
|
14
|
+
interpolate_result
|
15
|
+
@erb_vars
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def erb_vars
|
20
|
+
@erb_vars
|
21
|
+
end
|
22
|
+
|
23
|
+
def interpolate_result
|
24
|
+
@result = erb_binding_wrapper do |binding|
|
25
|
+
@src.result(binding)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def erb_binding_wrapper(&block)
|
30
|
+
set_erb_vars
|
31
|
+
value = yield(binding)
|
32
|
+
unset_erb_vars
|
33
|
+
value
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_erb_vars
|
37
|
+
erb_vars.each do |erb_var, value|
|
38
|
+
instance_variable_set erb_var, value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def unset_erb_vars
|
43
|
+
erb_vars.each do |erb_var, value|
|
44
|
+
remove_instance_variable erb_var
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def normalize_erb_vars(erb_vars)
|
49
|
+
Hash[
|
50
|
+
erb_vars.to_h.map { |k, v| ["@#{k}".to_sym, v] }
|
51
|
+
]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/eff/verifier.rb
ADDED
data/lib/eff/version.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'eff/downloader'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'fakefs/spec_helpers'
|
5
|
+
|
6
|
+
describe Eff::Downloader do
|
7
|
+
include FakeFS::SpecHelpers
|
8
|
+
|
9
|
+
let(:url) { "http://google.com" }
|
10
|
+
let(:file) { "test.tmp" }
|
11
|
+
let(:full_path) { File.expand_path(file, Dir.pwd) }
|
12
|
+
let(:fake_success) { OpenStruct.new(body: "I'm a fake response!", success?: true) }
|
13
|
+
let(:fake_failure) { OpenStruct.new(body: "I'm a fake response!", success?: false) }
|
14
|
+
|
15
|
+
# describe '.get' do
|
16
|
+
# it 'returns the body if response is successful' do
|
17
|
+
# Faraday.stub(:get).and_return(fake_success)
|
18
|
+
# Eff::Downloader.get(url, file).should eq(fake_success.body)
|
19
|
+
# end
|
20
|
+
|
21
|
+
# it 'returns nil if the response is not successful' do
|
22
|
+
# Faraday.stub(:get).and_return(fake_failure)
|
23
|
+
# Eff::Downloader.get(url, file).should be_nil
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
# describe '.get!' do
|
28
|
+
# it 'writes the appropriate file' do
|
29
|
+
# Faraday.stub(:get).and_return(fake_success)
|
30
|
+
# Eff::Downloader.get!(url, file)
|
31
|
+
# File.exists?(File.expand_path(file, Dir.pwd)).should be_true
|
32
|
+
# end
|
33
|
+
|
34
|
+
# it 'downloads the appropriate file' do
|
35
|
+
# Faraday.should_receive(:get).with(URI(url)).and_return(fake_success)
|
36
|
+
# Eff::Downloader.get!(url, file)
|
37
|
+
# end
|
38
|
+
|
39
|
+
# it 'returns the location of the saved file' do
|
40
|
+
# Faraday.stub(:get).and_return(fake_success)
|
41
|
+
# Eff::Downloader.get!(url, file).should be_true
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
|
45
|
+
describe 'instance' do
|
46
|
+
before { Faraday.stub(:get).and_return(fake_success) }
|
47
|
+
|
48
|
+
let(:downloader) { Eff::Downloader.new(url, file) }
|
49
|
+
|
50
|
+
describe '#get' do
|
51
|
+
it 'returns a response' do
|
52
|
+
downloader.get.should respond_to :success?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#uri=' do
|
57
|
+
let(:another_url) { "http://example.com" }
|
58
|
+
let(:another_uri) { URI(another_url) }
|
59
|
+
it 'resets response to nil' do
|
60
|
+
downloader.get
|
61
|
+
downloader.response.should_not be_nil
|
62
|
+
downloader.uri = another_url
|
63
|
+
downloader.response.should be_nil
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'sets the new uri' do
|
67
|
+
downloader.uri = another_url
|
68
|
+
downloader.uri.should eq(another_uri)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#file' do
|
73
|
+
let(:another_file) { '~/some_other_file' }
|
74
|
+
|
75
|
+
it 'resets response to nil' do
|
76
|
+
downloader.get
|
77
|
+
downloader.response.should_not be_nil
|
78
|
+
downloader.file = another_file
|
79
|
+
downloader.response.should be_nil
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'sets the new file' do
|
83
|
+
downloader.file = another_file
|
84
|
+
downloader.file.should eq(File.expand_path(another_file, Dir.pwd))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'successfully downloaded' do
|
89
|
+
describe '#save' do
|
90
|
+
it 'gets the response if it has not already' do
|
91
|
+
Faraday.should_receive(:get).with(URI(url)).and_return(fake_success)
|
92
|
+
downloader.save
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'writes the file to disk' do
|
96
|
+
downloader.save
|
97
|
+
File.exists?(File.expand_path(file, Dir.pwd)).should be_true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#success?' do
|
102
|
+
it 'returns true' do
|
103
|
+
downloader.should be_success
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'unsuccessfully downloaded' do
|
109
|
+
before { Faraday.stub(:get).and_return(fake_failure) }
|
110
|
+
|
111
|
+
describe '#save' do
|
112
|
+
it 'gets the response if it has not already' do
|
113
|
+
Faraday.should_receive(:get).with(URI(url)).and_return(fake_success)
|
114
|
+
downloader.save
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'does not write the file to disk' do
|
118
|
+
downloader.save
|
119
|
+
File.exists?(File.expand_path(file, Dir.pwd)).should_not be_true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#success?' do
|
124
|
+
it 'returns false' do
|
125
|
+
downloader.should_not be_success
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
data/spec/eff_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'eff/package/semantic_version'
|
3
|
+
|
4
|
+
describe Eff::Package::SemanticVersion do
|
5
|
+
describe '#to_h' do
|
6
|
+
let(:version_hash) {
|
7
|
+
Hash[
|
8
|
+
:major, "1",
|
9
|
+
:minor, "2",
|
10
|
+
:patch, "3",
|
11
|
+
:release, "p456",
|
12
|
+
:identity, "7890"
|
13
|
+
]
|
14
|
+
}
|
15
|
+
let(:valid_versions) { %w(1 1.2 1.2.3 1.2.3-p456 1.2.3-p456+7890) }
|
16
|
+
|
17
|
+
it 'should return the correct hash' do
|
18
|
+
valid_versions.each do |version_string|
|
19
|
+
semver = Eff::Package::SemanticVersion.new version_string
|
20
|
+
hash = semver.to_h
|
21
|
+
first_nil = false
|
22
|
+
version_hash.each do |part, value|
|
23
|
+
hash_value = hash[part]
|
24
|
+
first_nil ||= hash_value.nil?
|
25
|
+
if first_nil
|
26
|
+
hash[part].should be_nil
|
27
|
+
else
|
28
|
+
hash[part].should eq(value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'eff/package'
|
3
|
+
require 'fakefs/spec_helpers'
|
4
|
+
|
5
|
+
describe Eff::Package do
|
6
|
+
include FakeFS::SpecHelpers
|
7
|
+
|
8
|
+
let(:url_template) { '<%= "http://example.com/package-#{@major}.#{@minor}.#{@patch}.deb" %>' }
|
9
|
+
let(:url) { 'http://example.com/package-1.2.3.deb' }
|
10
|
+
let(:save_file) { '~/example.txt' }
|
11
|
+
let(:full_save_path) { File.expand_path(save_file, Dir.pwd) }
|
12
|
+
let(:version) { '1.2.3'}
|
13
|
+
let(:options) { { url_template: url_template, save_file: save_file, version: version } }
|
14
|
+
let(:package) { Eff::Package.new options }
|
15
|
+
|
16
|
+
let(:fake_success) { OpenStruct.new(body: "I'm a fake response!", success?: true) }
|
17
|
+
let(:fake_failure) { OpenStruct.new(body: "I'm a fake response!", success?: false) }
|
18
|
+
|
19
|
+
subject { package }
|
20
|
+
|
21
|
+
before { Faraday.stub(:get).and_return(fake_success) }
|
22
|
+
|
23
|
+
it { should respond_to :download }
|
24
|
+
it { should respond_to :save }
|
25
|
+
it { should respond_to :downloaded? }
|
26
|
+
it { should respond_to :url }
|
27
|
+
it { should respond_to :save_file }
|
28
|
+
it { should respond_to :version }
|
29
|
+
|
30
|
+
describe 'downloader wrapper method' do
|
31
|
+
describe '#download' do
|
32
|
+
it 'calls #get' do
|
33
|
+
Eff::Downloader.any_instance.should_receive(:get)
|
34
|
+
package.download
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#save' do
|
39
|
+
it 'calls #save' do
|
40
|
+
Eff::Downloader.any_instance.should_receive(:save)
|
41
|
+
package.save
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#downloaded?' do
|
46
|
+
it 'calls success?' do
|
47
|
+
Eff::Downloader.any_instance.should_receive(:success?)
|
48
|
+
package.downloaded?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#url' do
|
54
|
+
it 'returns the correct url' do
|
55
|
+
package.url.should eq(url)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
GEM_ROOT = File.expand_path("../../", __FILE__)
|
2
|
+
$:.unshift File.join(GEM_ROOT, "lib")
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'pry-rescue/rspec'
|
6
|
+
require 'eff'
|
7
|
+
|
8
|
+
if ENV["TRAVIS"]
|
9
|
+
require 'coveralls'
|
10
|
+
Coveralls.wear!
|
11
|
+
else
|
12
|
+
require 'simplecov'
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir[File.join(GEM_ROOT, "spec", "support", "**/*.rb")].each { |f| require f }
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.order = "random"
|
19
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
I'm sorry, did I break your concentration? I didn't mean to do that. Please, continue, you were saying something about best intentions. What's the matter? Oh, you were finished! Well, allow me to retort. What does Marsellus Wallace look like?
|
2
|
+
|
3
|
+
Look, just because I don't be givin' no man a foot massage don't make it right for Marsellus to throw Antwone into a glass motherfuckin' house, fuckin' up the way the ****** talks. Motherfucker do that shit to me, he better paralyze my ass, 'cause I'll kill the motherfucker, know what I'm sayin'?
|
4
|
+
|
5
|
+
Do you see any Teletubbies in here? Do you see a slender plastic tag clipped to my shirt with my name printed on it? Do you see a little Asian child with a blank expression on his face sitting outside on a mechanical helicopter that shakes when you put quarters in it? No? Well, that's what you see at a toy store. And you must think you're in a toy store, because you're here shopping for an infant named Jeb.
|
6
|
+
|
7
|
+
You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'eff/template'
|
3
|
+
|
4
|
+
describe Eff::Template do
|
5
|
+
before(:each) do
|
6
|
+
@src = '<%= "#{@name}, I am your father." %>'
|
7
|
+
@erb_vars = { name: "Luke" }
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:template) { Eff::Template.new @src, @erb_vars }
|
11
|
+
|
12
|
+
describe '#erb_vars=' do
|
13
|
+
it 'converts keys to instance variable keys' do
|
14
|
+
template.instance_variable_get(:@erb_vars).should eq({ :@name => "Luke"})
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#result' do
|
19
|
+
it 'correctly creates the result' do
|
20
|
+
template.result.should eq("Luke, I am your father.")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'handles multiple vars' do
|
24
|
+
@src = '<%= "#{@name} - #{@age}" %>'
|
25
|
+
@erb_vars = { name: "Luke", age: 21 }
|
26
|
+
template.result.should eq("Luke - 21")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'eff/verifier'
|
3
|
+
|
4
|
+
describe Eff::Verifier do
|
5
|
+
let(:file) { "spec/support/static_file_for_digesting.txt" }
|
6
|
+
let(:sha1) { "75cfdde12aeb435fd0c68c99df1027190953997e" }
|
7
|
+
let(:md5) { "1c0b1fcddc0cd9677ecfb79e1d127e03" }
|
8
|
+
|
9
|
+
it 'returns true if the hashes match' do
|
10
|
+
Eff::Verifier.check(file, sha1).should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns false if the hashes do not match' do
|
14
|
+
Eff::Verifier.check(file, "this doesn't match").should_not be_true
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'can validate with md5' do
|
18
|
+
Eff::Verifier.check(file, md5, Digest::MD5).should be_true
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Dennis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fpm
|
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: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: typhoeus
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.6.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.6.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry-plus
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: fakefs
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: Wrapper around fpm (effing package manager)
|
182
|
+
email:
|
183
|
+
- toady00@gmail.com
|
184
|
+
executables:
|
185
|
+
- eff
|
186
|
+
extensions: []
|
187
|
+
extra_rdoc_files: []
|
188
|
+
files:
|
189
|
+
- .gitignore
|
190
|
+
- .rspec
|
191
|
+
- .simplecov
|
192
|
+
- .travis.yml
|
193
|
+
- Gemfile
|
194
|
+
- Guardfile
|
195
|
+
- LICENSE.txt
|
196
|
+
- README.md
|
197
|
+
- Rakefile
|
198
|
+
- bin/eff
|
199
|
+
- eff.gemspec
|
200
|
+
- lib/eff.rb
|
201
|
+
- lib/eff/downloader.rb
|
202
|
+
- lib/eff/package.rb
|
203
|
+
- lib/eff/package/semantic_version.rb
|
204
|
+
- lib/eff/template.rb
|
205
|
+
- lib/eff/verifier.rb
|
206
|
+
- lib/eff/version.rb
|
207
|
+
- spec/downloader_spec.rb
|
208
|
+
- spec/eff_spec.rb
|
209
|
+
- spec/package_semantic_version_spec.rb
|
210
|
+
- spec/package_spec.rb
|
211
|
+
- spec/spec_helper.rb
|
212
|
+
- spec/support/static_file_for_digesting.txt
|
213
|
+
- spec/template_spec.rb
|
214
|
+
- spec/verifier_spec.rb
|
215
|
+
homepage: ''
|
216
|
+
licenses:
|
217
|
+
- MIT
|
218
|
+
metadata: {}
|
219
|
+
post_install_message:
|
220
|
+
rdoc_options: []
|
221
|
+
require_paths:
|
222
|
+
- lib
|
223
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
224
|
+
requirements:
|
225
|
+
- - '>='
|
226
|
+
- !ruby/object:Gem::Version
|
227
|
+
version: '0'
|
228
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
|
+
requirements:
|
230
|
+
- - '>='
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: '0'
|
233
|
+
requirements: []
|
234
|
+
rubyforge_project:
|
235
|
+
rubygems_version: 2.1.11
|
236
|
+
signing_key:
|
237
|
+
specification_version: 4
|
238
|
+
summary: Wrapper around fpm (effing package manager)
|
239
|
+
test_files:
|
240
|
+
- spec/downloader_spec.rb
|
241
|
+
- spec/eff_spec.rb
|
242
|
+
- spec/package_semantic_version_spec.rb
|
243
|
+
- spec/package_spec.rb
|
244
|
+
- spec/spec_helper.rb
|
245
|
+
- spec/support/static_file_for_digesting.txt
|
246
|
+
- spec/template_spec.rb
|
247
|
+
- spec/verifier_spec.rb
|
248
|
+
has_rdoc:
|