iftoc 0.1.8 → 0.1.9
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.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/bin/iftoc +23 -6
- data/lib/iftoc/version.rb +1 -1
- data/lib/iftoc.rb +27 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7b8ca7fac20a05bc98321c0399958a6f31235be
|
|
4
|
+
data.tar.gz: b02b03054e555319d9ca36371858f37307c8868a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e48eb1d5749468d078cb8d280b866d2309653c0239a64dc6fdfa9fcf1c2433756243730694ca94d6ac859e2be1e590c64dd2665b4c8f9ef8295062f4310da0f
|
|
7
|
+
data.tar.gz: 755731141391d6723e289658605e370faa548d7fb49c94f3fe9f1a42f31ff8812fedac8f5be1abd4ffeadde64839d6fe35de3b7b72b595518744c7b25de4f446
|
data/README.md
CHANGED
data/bin/iftoc
CHANGED
|
@@ -6,9 +6,10 @@ require 'iftoc'
|
|
|
6
6
|
|
|
7
7
|
$inpath = ARGV[0]
|
|
8
8
|
$outpath = Dir::pwd
|
|
9
|
+
$outStyle = "OC"
|
|
9
10
|
|
|
10
11
|
$helpString = <<-EOB
|
|
11
|
-
Usage: iftoc <svgfile | cssfile> [--out <outpath>]
|
|
12
|
+
Usage: iftoc <svgfile | cssfile> [--out <outpath>] [--lang <language>]
|
|
12
13
|
EOB
|
|
13
14
|
|
|
14
15
|
def paramCheck
|
|
@@ -18,6 +19,12 @@ def paramCheck
|
|
|
18
19
|
opts.on("-o", "--out <outpath>", String) do |value|
|
|
19
20
|
$outpath = value
|
|
20
21
|
end
|
|
22
|
+
|
|
23
|
+
opts.on("-l", "--lang <language>", String) do |value|
|
|
24
|
+
if value.to_s.downcase == "swift" then
|
|
25
|
+
$outStyle = "Swift"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
21
28
|
end.parse!
|
|
22
29
|
|
|
23
30
|
if ARGV.count < 1 then
|
|
@@ -59,13 +66,23 @@ if !iconfontName || iconfontMap.count < 1 then
|
|
|
59
66
|
exit(1)
|
|
60
67
|
end
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
if $outStyle == "Swift" then
|
|
70
|
+
|
|
71
|
+
#swift
|
|
72
|
+
swiftfilepath = $outpath+"/Iconfont.swift"
|
|
73
|
+
Iftoc.putStringToFile(Iftoc.generateSwiftFile(iconfontName, iconfontMap), swiftfilepath)
|
|
74
|
+
|
|
75
|
+
else
|
|
76
|
+
|
|
77
|
+
# hfile
|
|
78
|
+
hfilepath = $outpath+"/Iconfont.h"
|
|
79
|
+
Iftoc.putStringToFile(Iftoc.generateHFile(iconfontMap), hfilepath)
|
|
65
80
|
|
|
66
81
|
# mfile
|
|
67
|
-
mfilepath = $outpath+"/Iconfont.m"
|
|
68
|
-
Iftoc.putStringToFile(Iftoc.generateMFile(iconfontName, iconfontMap), mfilepath)
|
|
82
|
+
mfilepath = $outpath+"/Iconfont.m"
|
|
83
|
+
Iftoc.putStringToFile(Iftoc.generateMFile(iconfontName, iconfontMap), mfilepath)
|
|
84
|
+
|
|
85
|
+
end
|
|
69
86
|
|
|
70
87
|
puts "Done!"
|
|
71
88
|
|
data/lib/iftoc/version.rb
CHANGED
data/lib/iftoc.rb
CHANGED
|
@@ -127,6 +127,32 @@ module Iftoc
|
|
|
127
127
|
|
|
128
128
|
return mString
|
|
129
129
|
end
|
|
130
|
+
|
|
131
|
+
def generateSwiftFile(iconFontName, iconfontMap)
|
|
132
|
+
string1 = <<-EOB
|
|
133
|
+
//
|
|
134
|
+
// Iconfont.swift
|
|
135
|
+
// AutoCoding
|
|
136
|
+
//
|
|
137
|
+
EOB
|
|
138
|
+
|
|
139
|
+
string2 = <<-EOB
|
|
140
|
+
// Copyright © 2017年 olinone. All rights reserved.
|
|
141
|
+
//
|
|
142
|
+
|
|
143
|
+
import UIKit
|
|
144
|
+
|
|
145
|
+
public func iconFontWithSize(size: CGFloat) -> UIFont {
|
|
146
|
+
EOB
|
|
147
|
+
|
|
148
|
+
mString = string1 + "// Created by AutoCoding on " + Time.new.strftime("%Y/%m/%d") + ".\n" + string2 + " return UIFont(name: \"" + iconFontName + "\", size: size)!" + "\n}\n\n"
|
|
149
|
+
|
|
150
|
+
iconfontMap.each { |key, value|
|
|
151
|
+
mString = mString + "let icon" + key + " = \"\\u{"+ value +"}\"\n\n"
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return mString
|
|
155
|
+
end
|
|
130
156
|
|
|
131
157
|
def putStringToFile(text, path)
|
|
132
158
|
hio = File.open(path, "w+")
|
|
@@ -140,6 +166,7 @@ module Iftoc
|
|
|
140
166
|
module_function :parseCSSIconFont
|
|
141
167
|
module_function :generateHFile
|
|
142
168
|
module_function :generateMFile
|
|
169
|
+
module_function :generateSwiftFile
|
|
143
170
|
module_function :putStringToFile
|
|
144
171
|
|
|
145
172
|
end
|