shift 0.1.0 → 0.4.0
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/CHANGELOG +20 -0
- data/README.md +105 -37
- data/Rakefile +1 -1
- data/TODO +3 -0
- data/bin/shifter +5 -0
- data/lib/shift.rb +42 -36
- data/lib/shift/action_map.rb +106 -0
- data/lib/shift/cli.rb +43 -0
- data/lib/shift/errors.rb +7 -3
- data/lib/shift/i/closure_compiler.rb +23 -0
- data/lib/shift/{c → i}/coffee_script.rb +6 -3
- data/lib/shift/i/echo.rb +9 -0
- data/lib/shift/{c → i}/rdiscount.rb +6 -2
- data/lib/shift/{c → i}/redcarpet.rb +6 -2
- data/lib/shift/{c → i}/sass.rb +6 -2
- data/lib/shift/{c → i}/uglify_js.rb +7 -3
- data/lib/shift/{c → i}/yui_compressor.rb +7 -3
- data/lib/shift/i/zlib_reader.rb +23 -0
- data/lib/shift/i/zlib_writer.rb +27 -0
- data/lib/shift/{c/identity.rb → interface.rb} +39 -42
- data/lib/shift/interface_list.rb +67 -0
- data/lib/shift/interfaces.rb +20 -0
- data/lib/shift/mapper.rb +95 -0
- data/lib/shift/mappings.rb +51 -28
- data/lib/shift/mappings.yml +6 -0
- data/lib/shift/string.rb +125 -0
- data/shift.gemspec +3 -2
- data/test/data/letter.echo +0 -5
- data/test/helper.rb +2 -12
- data/test/{c → i}/closure_compiler_test.rb +6 -2
- data/test/{c → i}/coffee_script_test.rb +6 -2
- data/test/i/rdiscount_test.rb +22 -0
- data/test/i/redcarpet_test.rb +22 -0
- data/test/i/sass_test.rb +19 -0
- data/test/{c → i}/uglify_js_test.rb +6 -2
- data/test/{c → i}/yui_compressor_test.rb +6 -2
- data/test/i/zlib_reader.rb +24 -0
- data/test/interface_test.rb +60 -0
- data/test/mapper_test.rb +144 -0
- data/test/shift_test.rb +12 -43
- data/test/string_test.rb +39 -0
- metadata +39 -24
- data/lib/shift/c/closure_compiler.rb +0 -19
- data/test/c/identity_test.rb +0 -79
- data/test/c/rdiscount_test.rb +0 -18
- data/test/c/redcarpet_test.rb +0 -18
- data/test/c/sass_test.rb +0 -14
- data/test/support.rb +0 -37
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Shift
|
4
|
-
class ClosureCompiler < Identity
|
5
|
-
|
6
|
-
def self.gem_dependencies
|
7
|
-
%w{closure-compiler}
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.compiler_class
|
11
|
-
Closure::Compiler
|
12
|
-
end
|
13
|
-
|
14
|
-
def process_plain(str)
|
15
|
-
@engine.compile(str)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
data/test/c/identity_test.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'helper')
|
2
|
-
|
3
|
-
# Test Shift::Identity.
|
4
|
-
class IdentityTest < TestCase
|
5
|
-
|
6
|
-
def subject
|
7
|
-
Shift::Identity
|
8
|
-
end
|
9
|
-
|
10
|
-
def instance
|
11
|
-
@instance ||= subject.new(options)
|
12
|
-
end
|
13
|
-
|
14
|
-
def options
|
15
|
-
{}
|
16
|
-
end
|
17
|
-
|
18
|
-
def transformations
|
19
|
-
{
|
20
|
-
'echo' => 'echo',
|
21
|
-
'' => ''
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'instructions' do
|
26
|
-
unless subject == Shift::Identity
|
27
|
-
refute_same subject.instructions,
|
28
|
-
subject.superclass.instructions,
|
29
|
-
'gives instructions'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'has_default_instance' do
|
34
|
-
assert_instance_of subject, subject.default
|
35
|
-
end
|
36
|
-
|
37
|
-
test 'process' do
|
38
|
-
transformations.each do |a, b|
|
39
|
-
assert_equal b, instance.process(a)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# the usual ruby system file errors will just pass through,
|
44
|
-
# no use in testing for them.
|
45
|
-
|
46
|
-
test 'read' do
|
47
|
-
transformations.each do |a, b|
|
48
|
-
with_tempfile(a) do |path|
|
49
|
-
assert_equal b, instance.read(path)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
test 'read and write' do
|
55
|
-
transformations.each do |a, b|
|
56
|
-
with_tempfile(a) do |src_path|
|
57
|
-
with_tempfile do |trg_path|
|
58
|
-
instance.read(src_path).write(trg_path)
|
59
|
-
assert_equal b, IO.read(trg_path)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
test 'process and write' do
|
66
|
-
transformations.each do |a, b|
|
67
|
-
with_tempfile do |path|
|
68
|
-
instance.process(a).write(path)
|
69
|
-
assert_equal b, IO.read(path)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
test 'initialize when unavailable' do
|
75
|
-
wrap = Class.new(subject).extend(Unavabelizer)
|
76
|
-
assert_raises(Shift::DependencyError) { wrap.new }
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
data/test/c/rdiscount_test.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'identity_test')
|
2
|
-
|
3
|
-
|
4
|
-
class RDiscountTest < IdentityTest
|
5
|
-
|
6
|
-
def subject
|
7
|
-
Shift::RDiscount
|
8
|
-
end
|
9
|
-
|
10
|
-
def instance
|
11
|
-
subject.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def transformations
|
15
|
-
{ 'hello' => "<p>hello</p>\n" }
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/test/c/redcarpet_test.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'identity_test')
|
2
|
-
|
3
|
-
|
4
|
-
class RedCarpetTest < IdentityTest
|
5
|
-
|
6
|
-
def subject
|
7
|
-
Shift::Redcarpet
|
8
|
-
end
|
9
|
-
|
10
|
-
def instance
|
11
|
-
subject.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def transformations
|
15
|
-
{ 'hello' => "<p>hello</p>\n" }
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/test/c/sass_test.rb
DELETED
data/test/support.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
|
2
|
-
class UnavailableComponent < Shift::Identity
|
3
|
-
|
4
|
-
INSTRUCTIONS = 'meditate.'
|
5
|
-
|
6
|
-
def self.available?
|
7
|
-
false
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
class NullComponent < Shift::Identity
|
13
|
-
|
14
|
-
def self.available?
|
15
|
-
true
|
16
|
-
end
|
17
|
-
|
18
|
-
def process(str)
|
19
|
-
''
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
Shift::MAPPINGS['unavailable'] = ['UnavailableComponent'] * 10
|
25
|
-
|
26
|
-
Shift::MAPPINGS['null'] = %w{NullComponent}
|
27
|
-
Shift::MAPPINGS['bingo.bongo'] = %w{NullComponent}
|
28
|
-
|
29
|
-
Shift::MAPPINGS['prioritized'] = %w{UnavailableComponent
|
30
|
-
NullComponent Identity}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|