Checked 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,98 +1,104 @@
|
|
1
1
|
|
2
2
|
module Checked
|
3
|
-
class Clean
|
4
|
-
module Mods
|
5
|
-
module Strings
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
|
3
|
+
class Clean
|
4
|
+
module Mods
|
5
|
+
module Strings
|
6
|
+
|
7
|
+
def self.apply? d
|
8
|
+
d.target.is_a?(String) ||
|
9
|
+
d.target.is_a?(StringIO)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.on_apply d
|
13
|
+
case d.target
|
14
|
+
when StringIO
|
15
|
+
d.target.rewind
|
16
|
+
d.target= d.target.readlines
|
17
|
+
else
|
18
|
+
# Do nothing.
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def untar
|
23
|
+
target
|
24
|
+
.sub(/\.tar\.gz$/, '')
|
25
|
+
.sub(/\.tar/, '')
|
26
|
+
end
|
27
|
+
|
28
|
+
def file_names matcher
|
29
|
+
target.strip.split.select { |word| word[matcher] }
|
30
|
+
end
|
31
|
+
|
32
|
+
def file_names_by_ext ext
|
33
|
+
names = file_names(ext)
|
34
|
+
bases = names.map { |s|
|
35
|
+
s.sub(%r!#{ext}$!, '')
|
36
|
+
}
|
37
|
+
|
38
|
+
names.zip bases
|
39
|
+
end
|
40
|
+
|
41
|
+
def shell
|
42
|
+
target
|
43
|
+
.strip
|
44
|
+
.split("\n")
|
45
|
+
.map(&:strip)
|
46
|
+
.reject { |line| line.empty? }
|
47
|
+
.join(' && ')
|
48
|
+
end
|
49
|
+
|
50
|
+
def chop_ext
|
51
|
+
target.sub /\.[^\.]+$/, ''
|
52
|
+
end
|
53
|
+
|
54
|
+
def ruby_name
|
55
|
+
c = ::Checked::Clean.new( File.basename( target ) )
|
56
|
+
c.< :chop_rb
|
57
|
+
c.target
|
58
|
+
end
|
59
|
+
|
60
|
+
def chop_rb
|
61
|
+
target.sub %r!\.rb$!, ''
|
62
|
+
end
|
63
|
+
|
64
|
+
def chop_slash_r
|
65
|
+
target.gsub "\r", ''
|
66
|
+
end
|
67
|
+
|
68
|
+
def os_stardard
|
69
|
+
chop_slash_r.strip
|
70
|
+
end
|
71
|
+
|
72
|
+
def file_names matcher
|
73
|
+
strip.split.select { |word| word[matcher] }
|
74
|
+
end
|
75
|
+
|
76
|
+
def file_names_by_ext ext
|
77
|
+
names = file_names(ext)
|
78
|
+
bases = names.map { |s|
|
79
|
+
s.sub(%r!#{ext}$!, '')
|
80
|
+
}
|
81
|
+
|
82
|
+
names.zip bases
|
83
|
+
end
|
84
|
+
|
85
|
+
def to_single
|
86
|
+
target.gsub( /s\Z/, '' )
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_plural
|
90
|
+
target.to_single + 's'
|
91
|
+
end
|
92
|
+
|
93
|
+
def to_class_name
|
94
|
+
target.split('_').map(&:capitalize).join('_')
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_camel_case
|
98
|
+
target.split('_').map(&:capitalize).join
|
99
|
+
end
|
100
|
+
|
101
|
+
end # === module Strings
|
102
|
+
end # === module Mods
|
103
|
+
end # === class Clean
|
98
104
|
end # === module Checked
|
data/lib/Checked/version.rb
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
describe "Demand file_address!" do
|
2
|
+
|
3
|
+
it 'must fail if string has control characters' do
|
4
|
+
lambda {
|
5
|
+
d = Checked::Demand.new(File.expand_path "~/\tbashee")
|
6
|
+
d.<< :file_address!
|
7
|
+
}.should.raise(Checked::Demand::Failed)
|
8
|
+
.message.should.match %r!has invalid characters: !
|
9
|
+
end
|
10
|
+
|
11
|
+
end # === describe Demand file_address!
|
12
|
+
|
1
13
|
|
2
14
|
describe "Demand not_dir!" do
|
3
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Checked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-15 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &9627280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9627280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bacon
|
27
|
-
requirement: &
|
27
|
+
requirement: &9605340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9605340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Bacon_Colored
|
38
|
-
requirement: &
|
38
|
+
requirement: &9601420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *9601420
|
47
47
|
description: ! "\n Various DSLs to clean, question (Ask), and validate (Demand)
|
48
48
|
your objects,\n their classes (data types), and their properties.\n "
|
49
49
|
email:
|