rtlit 0.0.2 → 0.0.3
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/lib/rtlit/converter.rb +5 -3
- data/lib/rtlit/util.rb +32 -9
- data/lib/rtlit/version.rb +1 -1
- metadata +7 -2
data/lib/rtlit/converter.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
module RTLit
|
1
|
+
module RTLit #nodoc
|
2
2
|
|
3
|
+
# CSS string LTR to RTL converter
|
4
|
+
#
|
3
5
|
module Converter
|
4
6
|
|
5
7
|
class << self
|
@@ -8,7 +10,7 @@ module RTLit
|
|
8
10
|
# Accepts any valid CSS string.
|
9
11
|
# Returns a CSS string.
|
10
12
|
#
|
11
|
-
# @param [String
|
13
|
+
# @param [String] css the css string to convert to RTL
|
12
14
|
# @return [String] the RTL version of the css
|
13
15
|
#
|
14
16
|
# Example:
|
@@ -19,7 +21,7 @@ module RTLit
|
|
19
21
|
# padding-right: 10px;
|
20
22
|
# }"
|
21
23
|
#
|
22
|
-
# to_rtl(css)
|
24
|
+
# rtl_css = to_rtl(css)
|
23
25
|
#
|
24
26
|
def to_rtl(css) ''
|
25
27
|
place_holder = '|====|'
|
data/lib/rtlit/util.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
-
module RTLit
|
1
|
+
module RTLit #nodoc
|
2
2
|
|
3
|
+
# Files and directories utilities for converting
|
4
|
+
# CSS-formatted files to RTL
|
3
5
|
module Util
|
4
6
|
|
5
7
|
class << self
|
6
8
|
|
7
|
-
#
|
9
|
+
# Converts CSS-formatted file to RTL.
|
10
|
+
#
|
8
11
|
# Accepts source and destination file paths.
|
12
|
+
#
|
13
|
+
# @param [String] src the source file to convert
|
14
|
+
# @param [String] dest the destination file to write converted CSS to
|
15
|
+
#
|
9
16
|
# Example:
|
10
17
|
# process_file('/path/to/file.css', '/path/to/file-rtl.css')
|
18
|
+
#
|
11
19
|
def process_file(src, dest)
|
12
20
|
puts 'Reading %s' % src
|
13
21
|
css = File.open(src,'r'){ |f| f.read }
|
@@ -16,9 +24,17 @@ module RTLit
|
|
16
24
|
File.open(dest,'w'){ |f| f.write rtl_css }
|
17
25
|
end
|
18
26
|
|
19
|
-
#
|
27
|
+
# Converts CSS-formatted files in a directory, optionally filtered by extension, to RTL.
|
28
|
+
#
|
20
29
|
# Accepts source and destination directories and an optional file extension string
|
21
|
-
#
|
30
|
+
#
|
31
|
+
# @param [String] src the source directory to convert
|
32
|
+
# @param [String] dest the destination directory to write converted CSS files to
|
33
|
+
# @param [String] ext optional file extension to filter source files by
|
34
|
+
#
|
35
|
+
# Exmaple:
|
36
|
+
# process_directory('/tmp', '/tmp/rtl', 'less')
|
37
|
+
#
|
22
38
|
def process_directory(src, dest, ext = nil)
|
23
39
|
src_path = '%s/*.%s' % [File.expand_path(src), ext || '*']
|
24
40
|
dest_path = File.expand_path dest
|
@@ -28,12 +44,19 @@ module RTLit
|
|
28
44
|
end
|
29
45
|
end
|
30
46
|
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
47
|
+
# Convert CSS-formatted file or directory containing such files, which can optionally be filtered by file extension.
|
48
|
+
#
|
49
|
+
# Accepts source and destination paths to file or directory to convert and
|
50
|
+
# an optional file extension string to filter by (in case source path is a directory)
|
51
|
+
#
|
52
|
+
# @param [String] src the source directory to convert
|
53
|
+
# @param [String] dest the destination directory to write converted CSS files to
|
54
|
+
# @param [String] ext optional file extension to filter source files by
|
55
|
+
#
|
34
56
|
# Example:
|
35
|
-
#
|
36
|
-
#
|
57
|
+
# process_file_or_directory('/some/path', '/some/dest', 'less') # process only .less files directory
|
58
|
+
# process_file_or_directory('/some/file.css','/some/file-rtl.css')
|
59
|
+
#
|
37
60
|
def process_file_or_directory(src, dest, ext = nil)
|
38
61
|
|
39
62
|
raise 'Source not given' if src.nil? or not File.exists? src
|
data/lib/rtlit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -48,12 +48,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
48
|
- - ! '>='
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
hash: -4536212592836592277
|
51
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
55
|
none: false
|
53
56
|
requirements:
|
54
57
|
- - ! '>='
|
55
58
|
- !ruby/object:Gem::Version
|
56
59
|
version: '0'
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
hash: -4536212592836592277
|
57
63
|
requirements: []
|
58
64
|
rubyforge_project: rtlit
|
59
65
|
rubygems_version: 1.8.17
|
@@ -65,4 +71,3 @@ test_files:
|
|
65
71
|
- test/assets/rtl.css
|
66
72
|
- test/test_file_conversion.rb
|
67
73
|
- test/test_ltr_to_rtl.rb
|
68
|
-
has_rdoc:
|