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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7c14ede3502c50a5b4e5efca31b7933c5f88dec
4
- data.tar.gz: 164fc9357ae195c449607c32a1fb293e5cc50f28
3
+ metadata.gz: c7b8ca7fac20a05bc98321c0399958a6f31235be
4
+ data.tar.gz: b02b03054e555319d9ca36371858f37307c8868a
5
5
  SHA512:
6
- metadata.gz: d14a82921a4ee5756716f368c547361da67da84b5105b70efd39f0a630fb6d095e3bed937b36f6b3682c49ca7f6b69d9d92c43e200fdc240a5490f4259fd7406
7
- data.tar.gz: 3f709ea5147b9e029f6fd927115e0e7e50443c9e8c32eb6574b964851f2583726857fdbedd3a512e46af4b8127886f2af310dbf6fbf5a2fc38f5ed552d1a744b
6
+ metadata.gz: 2e48eb1d5749468d078cb8d280b866d2309653c0239a64dc6fdfa9fcf1c2433756243730694ca94d6ac859e2be1e590c64dd2665b4c8f9ef8295062f4310da0f
7
+ data.tar.gz: 755731141391d6723e289658605e370faa548d7fb49c94f3fe9f1a42f31ff8812fedac8f5be1abd4ffeadde64839d6fe35de3b7b72b595518744c7b25de4f446
data/README.md CHANGED
@@ -15,6 +15,10 @@ Converts SVG or CSS StyleSheets for IconFont like [iconfont.css](https://github.
15
15
  Install it yourself as:
16
16
 
17
17
  $ gem install iftoc
18
+
19
+ Update it yourself as:
20
+
21
+ $ gem update iftoc
18
22
 
19
23
  ## Usage
20
24
 
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
- # hfile
63
- hfilepath = $outpath+"/Iconfont.h"
64
- Iftoc.putStringToFile(Iftoc.generateHFile(iconfontMap), hfilepath)
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
@@ -1,3 +1,3 @@
1
1
  module Iftoc
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iftoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - 庞海礁