icomoon2sass 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hash.rb +26 -0
- data/lib/icomoon2sass.rb +49 -1
- data/lib/icomoon2sass/cli.rb +6 -34
- data/lib/icomoon2sass/utilities.rb +9 -0
- data/lib/icomoon2sass/version.rb +1 -1
- data/lib/run.rb +5 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76a022fa1734a2a2327fdcf8be6196a8086dd7ce
|
4
|
+
data.tar.gz: 726612498b2e206c2765165bc54272598d741015
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51ed00395230f2a3df1291d0bcd6725c4a1f525f57e96c752d2fa9a77d0a79f4fde2b4014006f34b4faf4f4958c19c15d6a41138f6d63a0057a0717f8c21731f
|
7
|
+
data.tar.gz: f762faacccbdf3bb5b2a539c1f5226266081d60545bd3231343719db1dd03daf110616cfd1b969350a8669ce3ebc1586ff62797accd94333a9ac4e0cb544673c
|
data/lib/hash.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class Hash
|
2
|
+
def transform_keys
|
3
|
+
result = {}
|
4
|
+
each_key do |key|
|
5
|
+
result[yield(key)] = self[key]
|
6
|
+
end
|
7
|
+
result
|
8
|
+
end
|
9
|
+
|
10
|
+
def transform_keys!
|
11
|
+
keys.each do |key|
|
12
|
+
self[yield(key)] = delete(key)
|
13
|
+
end
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def symbolize_keys
|
18
|
+
transform_keys{ |key| key.to_sym rescue key }
|
19
|
+
end
|
20
|
+
|
21
|
+
def symbolize_keys!
|
22
|
+
transform_keys!{ |key| key.to_sym rescue key }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
data/lib/icomoon2sass.rb
CHANGED
@@ -4,8 +4,56 @@ require 'icomoon2sass/zip'
|
|
4
4
|
require 'icomoon2sass/dir'
|
5
5
|
require 'icomoon2sass/font'
|
6
6
|
require 'icomoon2sass/sass'
|
7
|
+
require 'icomoon2sass/utilities'
|
8
|
+
require 'hash'
|
7
9
|
|
8
10
|
module Icomoon2Sass
|
9
|
-
|
11
|
+
|
12
|
+
def self.run!(source, font_path, sass_path, options = {})
|
13
|
+
defaults = {
|
14
|
+
scss: false,
|
15
|
+
compatible: false,
|
16
|
+
oocss: false
|
17
|
+
}
|
18
|
+
|
19
|
+
options = defaults.merge options.symbolize_keys
|
20
|
+
|
21
|
+
utilities = Icomoon2Sass::Utilities.new
|
22
|
+
|
23
|
+
if source.end_with? '.zip'
|
24
|
+
files = Icomoon2Sass::Zip.new source
|
25
|
+
|
26
|
+
elsif Dir.exists? source
|
27
|
+
files = Icomoon2Sass::Dir.new source
|
28
|
+
|
29
|
+
else
|
30
|
+
raise 'Source must be either a directory or .zip file!'
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
raise 'Source must contain \'selection.json\'.' unless files.files['selection.json']
|
35
|
+
|
36
|
+
font = Icomoon2Sass::Font.new files.metadata_file
|
37
|
+
|
38
|
+
syntax = options[:scss] ? 'scss' : 'sass'
|
39
|
+
|
40
|
+
compatible = options[:compatible] || false
|
41
|
+
|
42
|
+
sass = Icomoon2Sass::Sass.new font, syntax, compatible
|
43
|
+
|
44
|
+
|
45
|
+
# Save the Sass file
|
46
|
+
utilities.create_file "#{sass_path}/_icons.#{sass.syntax}", sass.code
|
47
|
+
|
48
|
+
if options[:oocss]
|
49
|
+
utilities.create_file "#{sass_path}/_oocss_icons.#{sass.syntax}", sass.oocss
|
50
|
+
end
|
51
|
+
|
52
|
+
files.font_files.each do |filename, content|
|
53
|
+
utilities.create_file "#{font_path}/#{filename.sub('fonts/', '')}", content
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
10
58
|
end
|
11
59
|
|
data/lib/icomoon2sass/cli.rb
CHANGED
@@ -5,7 +5,7 @@ require 'icomoon2sass'
|
|
5
5
|
class Icomoon2Sass::CLI < Thor::Group
|
6
6
|
include Thor::Actions
|
7
7
|
|
8
|
-
argument :
|
8
|
+
argument :source
|
9
9
|
|
10
10
|
class_option :'font-path', type: :string, default: './', desc: 'Destination path for font files'
|
11
11
|
class_option :'sass-path', type: :string, default: './', desc: 'Destination path for Sass files'
|
@@ -15,43 +15,15 @@ class Icomoon2Sass::CLI < Thor::Group
|
|
15
15
|
|
16
16
|
def start
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
begin
|
19
|
+
Icomoon2Sass.run! source, options['font-path'], options['sass-path'], options
|
20
20
|
|
21
|
-
|
21
|
+
rescue Exception => e
|
22
|
+
say_status(e, '', :red)
|
22
23
|
|
23
|
-
elsif Dir.exists? icomoon
|
24
|
-
say_status('Reading directory.', '', :blue)
|
25
|
-
|
26
|
-
files = Icomoon2Sass::Dir.new icomoon
|
27
|
-
|
28
|
-
else
|
29
|
-
return say_status('WTF?!', 'I have no idea what I\'m doing.', :red)
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
return say_status('You seem to be missing \'selection.json\'.', '', :red) unless files.files['selection.json']
|
34
|
-
|
35
|
-
|
36
|
-
font = Icomoon2Sass::Font.new files.metadata_file
|
37
|
-
|
38
|
-
syntax = options['scss'] ? 'scss' : 'sass'
|
39
|
-
|
40
|
-
compatible = options['compatible'] || false
|
41
|
-
|
42
|
-
sass = Icomoon2Sass::Sass.new font, syntax, compatible
|
43
|
-
|
44
|
-
|
45
|
-
# Save the Sass file
|
46
|
-
create_file "#{options['sass-path']}/_icons.#{sass.syntax}", sass.code
|
47
|
-
|
48
|
-
if options['oocss']
|
49
|
-
create_file "#{options['sass-path']}/_oocss_icons.#{sass.syntax}", sass.oocss
|
50
24
|
end
|
51
25
|
|
52
|
-
|
53
|
-
create_file "#{options['font-path']}/#{filename.sub('fonts/', '')}", content
|
54
|
-
end
|
26
|
+
return
|
55
27
|
|
56
28
|
end
|
57
29
|
end
|
data/lib/icomoon2sass/version.rb
CHANGED
data/lib/run.rb
CHANGED
@@ -7,16 +7,20 @@ ARGV << '--help' if ARGV.empty?
|
|
7
7
|
help_message = <<-EOT
|
8
8
|
Usage: icomoon2sass path/to/icomoon(.zip) [OPTIONS]
|
9
9
|
|
10
|
+
You can also pass the path to an unzipped directory.
|
11
|
+
|
12
|
+
|
10
13
|
OPTIONS
|
11
14
|
--font-path PATH Destination path for font files, defaults to current directory
|
12
15
|
--sass-path PATH Destination path for Sass files, defaults to current directory
|
13
16
|
--scss Use the SCSS syntax
|
14
17
|
-c, --compatible Generate code compatible with Sass 3.2
|
18
|
+
--oocss Generate OOCSS-style classes
|
15
19
|
|
16
20
|
|
17
21
|
OUTPUT
|
18
22
|
By default icomoon2sass generates Sass code in the indented Sass syntax. Further,
|
19
|
-
the default generated code is only
|
23
|
+
the default generated code is only compatible with Sass 3.3+.
|
20
24
|
|
21
25
|
$icons: (
|
22
26
|
github: \'\\28\',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icomoon2sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jed Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -61,6 +61,7 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- bin/icomoon2sass
|
64
|
+
- lib/hash.rb
|
64
65
|
- lib/icomoon2sass.rb
|
65
66
|
- lib/icomoon2sass/archive.rb
|
66
67
|
- lib/icomoon2sass/cli.rb
|
@@ -71,6 +72,7 @@ files:
|
|
71
72
|
- lib/icomoon2sass/templates/map.sass.erb
|
72
73
|
- lib/icomoon2sass/templates/oocss_list.sass.erb
|
73
74
|
- lib/icomoon2sass/templates/oocss_map.sass.erb
|
75
|
+
- lib/icomoon2sass/utilities.rb
|
74
76
|
- lib/icomoon2sass/version.rb
|
75
77
|
- lib/icomoon2sass/zip.rb
|
76
78
|
- lib/run.rb
|