kastner-kompress 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.
- data/README.mkdn +3 -0
- data/lib/kompress/compress.rb +7 -0
- data/lib/kompress/config.rb +53 -0
- data/lib/kompress/exceptions.rb +1 -0
- data/lib/kompress.rb +7 -0
- data/test/config_test.rb +47 -0
- data/test/test_helper.rb +14 -0
- metadata +60 -0
data/README.mkdn
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Kompress
|
2
|
+
module Config
|
3
|
+
extend self
|
4
|
+
|
5
|
+
attr_reader :commands, :settings
|
6
|
+
|
7
|
+
def presets
|
8
|
+
@presets || {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def write
|
12
|
+
yield self
|
13
|
+
end
|
14
|
+
|
15
|
+
def command(hash)
|
16
|
+
@commands ||= {}
|
17
|
+
@commands.merge! hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def setting(hash)
|
21
|
+
@settings ||= {}
|
22
|
+
@settings.merge! hash
|
23
|
+
end
|
24
|
+
|
25
|
+
def preset(hash)
|
26
|
+
@presets ||= {}
|
27
|
+
hash.each do |k, v|
|
28
|
+
@presets[k] = Preset.new(k, v)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Preset
|
33
|
+
attr_reader :name
|
34
|
+
attr_accessor :options
|
35
|
+
|
36
|
+
def initialize(name, options = {})
|
37
|
+
@command = options.delete(:command) || ""
|
38
|
+
@name = name.to_s
|
39
|
+
@options = options
|
40
|
+
end
|
41
|
+
|
42
|
+
def command
|
43
|
+
kc = Kompress::Config
|
44
|
+
replacements = kc.settings.merge(kc.commands.merge(@options))
|
45
|
+
@command.gsub(/:\w+/) {|s| replacements[s.gsub(/^:/,'').intern] || s }
|
46
|
+
end
|
47
|
+
|
48
|
+
def description
|
49
|
+
@options[:description] || @name
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
class Kompress::NoConfigurationError < StandardError; end
|
data/lib/kompress.rb
ADDED
data/test/config_test.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
describe "Kompress" do
|
4
|
+
it "should raise an error if no configuration supplied" do
|
5
|
+
lambda { Kompress.compress_using(:awesome) }.should.raise Kompress::NoConfigurationError
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Kompress::Config" do
|
10
|
+
setup do
|
11
|
+
Kompress::Config.write do |k|
|
12
|
+
k.command :ffmpeg => "/usr/bin/ffmpeg"
|
13
|
+
k.setting :directory => "/t"
|
14
|
+
|
15
|
+
k.preset :test => {
|
16
|
+
:command => ":ffmpeg go > :directory"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should map commands to locations" do
|
22
|
+
Kompress::Config.commands[:ffmpeg].should == "/usr/bin/ffmpeg"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should map settings" do
|
26
|
+
Kompress::Config.settings[:directory].should == "/t"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should substitue placeholders" do
|
30
|
+
Kompress::Config.presets[:test].command.should == "/usr/bin/ffmpeg go > /t"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "Kompress::Config::Preset" do
|
35
|
+
setup do
|
36
|
+
@p = Kompress::Config::Preset.new(:rad, {:description => "Rad testing preset"})
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have a description" do
|
40
|
+
@p.description.should == "Rad testing preset"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should use the name as a description if none provided" do
|
44
|
+
@p.options.delete(:description)
|
45
|
+
@p.description.should == "rad"
|
46
|
+
end
|
47
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kastner-kompress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erik Kastner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-09-14 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Kompress - kompress videos and see progress
|
17
|
+
email: kastner@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/kompress.rb
|
26
|
+
- README.mkdn
|
27
|
+
- lib/kompress/compress.rb
|
28
|
+
- lib/kompress/config.rb
|
29
|
+
- lib/kompress/exceptions.rb
|
30
|
+
- test/test_helper.rb
|
31
|
+
- test/config_test.rb
|
32
|
+
has_rdoc: false
|
33
|
+
homepage: http://github.com/kastner/kompress.git
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options:
|
36
|
+
- --main
|
37
|
+
- README.mkdn
|
38
|
+
require_paths:
|
39
|
+
- .
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.2.0
|
56
|
+
signing_key:
|
57
|
+
specification_version: 2
|
58
|
+
summary: Kompress - kompress videos and see progress
|
59
|
+
test_files: []
|
60
|
+
|