icomoon 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +31 -0
- data/bin/icomoon +5 -0
- data/lib/icomoon.rb +2 -0
- data/lib/icomoon/cli.rb +59 -0
- data/lib/icomoon/cli/config.rb +43 -0
- data/lib/icomoon/cli/exec.rb +31 -0
- data/lib/icomoon/cli/exec/base.rb +59 -0
- data/lib/icomoon/cli/exec/help.rb +23 -0
- data/lib/icomoon/cli/exec/import.rb +143 -0
- data/lib/icomoon/cli/exec/init.rb +160 -0
- data/lib/icomoon/cli/exec_param.rb +13 -0
- data/lib/icomoon/cli/icon.rb +12 -0
- data/lib/icomoon/cli/logger.rb +15 -0
- data/lib/icomoon/cli/operation.rb +54 -0
- data/lib/icomoon/cli/parse_argv.rb +27 -0
- data/lib/icomoon/cli/question.rb +13 -0
- data/lib/icomoon/cli/survey.rb +36 -0
- data/lib/icomoon/cli/writer.rb +26 -0
- data/lib/icomoon/version.rb +3 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53b0108a30656c9c7590ed344b6343d72947be75
|
4
|
+
data.tar.gz: 103310f193a88ea46fb4098dfb905f1e02ecf607
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53158fe6b99a2a08effbe4603e589fd7f74d49419aaaa9922d8918511faead57a44fd582f24f9a28ae38b614dbf6c40a883aba0c4bae90bae0468de58302ae2a
|
7
|
+
data.tar.gz: c39ba697be84deff9885723059921aa2b2fd3a5394d2283a3a40c0487824faaeee7f48306b7691a7824c841fdab119a12d6f7048e04dba6e96eafebc64c2e8cb
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Icomoon
|
2
|
+
This helper will make using Icomoon icons set easier.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
If you want to use Icomoon icons on your project, this is what will help you.
|
6
|
+
|
7
|
+
### Installation
|
8
|
+
Add this to your Gemfile:
|
9
|
+
```ruby
|
10
|
+
gem 'icomoon'
|
11
|
+
```
|
12
|
+
And then `bundle install`. You can always run `icomoon help` if you need help.
|
13
|
+
|
14
|
+
### Getting started
|
15
|
+
- run `icomoon init`
|
16
|
+
|
17
|
+
### Adding/removing icons (basically updating your icon set)
|
18
|
+
- open [IcoMoon App](https://icomoon.io/app/#/projects)
|
19
|
+
- click "Import Project" and select icomoon.json file from your project (it's located in the "Directory of fonts files" directory from the survey you took before)
|
20
|
+
- click "Load" on the imported project
|
21
|
+
- add/remove icons, change project preferences
|
22
|
+
- download set and unzip without changing folder name
|
23
|
+
- run `icomoon import` and specify location of unzipped icon set (`--dir` or `-d`)
|
24
|
+
- update icons file code (will display)
|
25
|
+
|
26
|
+
## Requirements
|
27
|
+
- ruby 2.2.2 or higher
|
28
|
+
- requires your application to use SASS/SCSS
|
29
|
+
|
30
|
+
## Note
|
31
|
+
It was tested on OS X only, not tested on Linux nor Windows.
|
data/bin/icomoon
ADDED
data/lib/icomoon.rb
ADDED
data/lib/icomoon/cli.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'json'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
require 'icomoon/cli/exec_param'
|
6
|
+
require 'icomoon/cli/exec'
|
7
|
+
require 'icomoon/cli/parse_argv'
|
8
|
+
require 'icomoon/cli/survey'
|
9
|
+
require 'icomoon/cli/question'
|
10
|
+
require 'icomoon/cli/logger'
|
11
|
+
require 'icomoon/cli/operation'
|
12
|
+
require 'icomoon/cli/writer'
|
13
|
+
require 'icomoon/cli/config'
|
14
|
+
require 'icomoon/cli/icon'
|
15
|
+
|
16
|
+
module Icomoon
|
17
|
+
module Cli
|
18
|
+
MANIFEST_FILENAME = 'icomoon.json'
|
19
|
+
|
20
|
+
Error = Class.new(StandardError)
|
21
|
+
Warning = Class.new(StandardError)
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def start(argv)
|
25
|
+
Icomoon::Cli::Exec.run(argv)
|
26
|
+
end
|
27
|
+
|
28
|
+
def logs(text)
|
29
|
+
logger.log(text, true)
|
30
|
+
end
|
31
|
+
|
32
|
+
def log(text)
|
33
|
+
logger.log(text, false)
|
34
|
+
end
|
35
|
+
|
36
|
+
def error(text)
|
37
|
+
puts "#{'Error:'.red} #{text}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def put_separator
|
41
|
+
logs('---')
|
42
|
+
end
|
43
|
+
|
44
|
+
def file_exists?(path)
|
45
|
+
File.exists?(path)
|
46
|
+
end
|
47
|
+
|
48
|
+
def logger
|
49
|
+
@@logger
|
50
|
+
end
|
51
|
+
|
52
|
+
def logger=(logger)
|
53
|
+
@@logger = logger
|
54
|
+
end
|
55
|
+
|
56
|
+
@@logger = Icomoon::Cli::Logger.new
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Icomoon
|
2
|
+
module Cli
|
3
|
+
class Config
|
4
|
+
CONFIG_FILE_NAME = '.icomoon-config.json'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def read
|
8
|
+
if !File.exists? config_file_full_path
|
9
|
+
fail Icomoon::Cli::Error, 'Config file not found.'
|
10
|
+
end
|
11
|
+
|
12
|
+
content = JSON.parse(File.read(config_file_full_path))
|
13
|
+
|
14
|
+
Struct.new(
|
15
|
+
:icons_set_name,
|
16
|
+
:icons_file_path,
|
17
|
+
:fonts_file_dir,
|
18
|
+
:css_class
|
19
|
+
).new(
|
20
|
+
content['icons_set_name'],
|
21
|
+
content['icons_file_path'],
|
22
|
+
content['fonts_file_dir'],
|
23
|
+
content['css_class']
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def write(config)
|
28
|
+
Icomoon::Cli::Writer.write(CONFIG_FILE_NAME) do |file|
|
29
|
+
file.puts(JSON.pretty_generate(config))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def config_file_exists?
|
34
|
+
File.exists? CONFIG_FILE_NAME
|
35
|
+
end
|
36
|
+
|
37
|
+
def config_file_full_path
|
38
|
+
File.expand_path(CONFIG_FILE_NAME)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'icomoon/version'
|
2
|
+
|
3
|
+
require 'icomoon/cli/exec/base'
|
4
|
+
require 'icomoon/cli/exec/init'
|
5
|
+
require 'icomoon/cli/exec/import'
|
6
|
+
require 'icomoon/cli/exec/help'
|
7
|
+
|
8
|
+
module Icomoon
|
9
|
+
module Cli
|
10
|
+
module Exec
|
11
|
+
class << self
|
12
|
+
def run(argv)
|
13
|
+
command = argv.shift
|
14
|
+
|
15
|
+
case command
|
16
|
+
when 'init'
|
17
|
+
Icomoon::Cli::Exec::Init.run(argv)
|
18
|
+
when 'import'
|
19
|
+
Icomoon::Cli::Exec::Import.run(argv)
|
20
|
+
when 'help', nil
|
21
|
+
Icomoon::Cli::Exec::Help.run(argv)
|
22
|
+
when 'version', '--version', '-v'
|
23
|
+
Icomoon::Cli.logs Icomoon::VERSION
|
24
|
+
else
|
25
|
+
Icomoon::Cli.logs "invalid command: #{command}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Icomoon
|
2
|
+
module Cli
|
3
|
+
module Exec
|
4
|
+
class Base
|
5
|
+
@@params = []
|
6
|
+
|
7
|
+
def self.params
|
8
|
+
@@params
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(args)
|
12
|
+
@args = args
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def run(argv)
|
17
|
+
if argv.count == 1 && argv[0] == 'help'
|
18
|
+
return display_help
|
19
|
+
end
|
20
|
+
|
21
|
+
new(Icomoon::Cli::ParseArgv.call(argv, params)).run
|
22
|
+
end
|
23
|
+
|
24
|
+
def display_help
|
25
|
+
puts @command_help_text
|
26
|
+
end
|
27
|
+
|
28
|
+
def help(text)
|
29
|
+
@command_help_text = text
|
30
|
+
end
|
31
|
+
|
32
|
+
def param(*args)
|
33
|
+
add_param(true, *args)
|
34
|
+
end
|
35
|
+
|
36
|
+
def flag(*args)
|
37
|
+
add_param(false, *args)
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_param(needs_value, *args)
|
41
|
+
key = args.shift
|
42
|
+
params << Icomoon::Cli::ExecParam.new(key, args, needs_value) if args.count.nonzero?
|
43
|
+
|
44
|
+
method_name = needs_value ? key : "#{key}?"
|
45
|
+
define_param_reader(key, method_name)
|
46
|
+
end
|
47
|
+
|
48
|
+
def define_param_reader(key, method_name = key)
|
49
|
+
class_eval("def #{method_name}; args[#{key.to_sym.inspect}] rescue nil; end")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
attr_reader :args
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Icomoon
|
2
|
+
module Cli
|
3
|
+
module Exec
|
4
|
+
class Help < Icomoon::Cli::Exec::Base
|
5
|
+
help <<~STRING
|
6
|
+
:-)
|
7
|
+
STRING
|
8
|
+
|
9
|
+
def run
|
10
|
+
puts <<~STRING
|
11
|
+
Usage: icomoon command [...options]
|
12
|
+
|
13
|
+
Run `icomoon command help` to get help about specific command.
|
14
|
+
|
15
|
+
Commands:
|
16
|
+
- help Displays this help text.
|
17
|
+
- init Initializes and configures Icomoon.
|
18
|
+
STRING
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Icomoon
|
4
|
+
module Cli
|
5
|
+
module Exec
|
6
|
+
class Import < Icomoon::Cli::Exec::Base
|
7
|
+
CONFIG_FILE_NAME = '.icomoonrc'
|
8
|
+
EXTENSIONS = %w[eot ttf woff svg].freeze
|
9
|
+
|
10
|
+
help <<~STRING
|
11
|
+
Usage: icomoon import [--major]
|
12
|
+
|
13
|
+
This subprogram imports fonts files and JSON manifest from given
|
14
|
+
directory. It also updates icon font version.
|
15
|
+
|
16
|
+
options:
|
17
|
+
|
18
|
+
-dir, -d Specifies source directory for importing files.
|
19
|
+
This option is required.
|
20
|
+
STRING
|
21
|
+
|
22
|
+
param :source_dir, '--dir', '-d'
|
23
|
+
|
24
|
+
def run
|
25
|
+
Icomoon::Cli::Operation.new do
|
26
|
+
validate_params
|
27
|
+
end
|
28
|
+
|
29
|
+
Icomoon::Cli::Operation.new do
|
30
|
+
read_config
|
31
|
+
end
|
32
|
+
|
33
|
+
Icomoon::Cli::Operation.new 'Checking files' do
|
34
|
+
EXTENSIONS.each do |ext|
|
35
|
+
check_source_file("fonts/#{config.icons_set_name}.#{ext}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Icomoon::Cli::Operation.new 'Copying font files' do
|
40
|
+
EXTENSIONS.each do |ext|
|
41
|
+
filename = "#{config.icons_set_name}.#{ext}"
|
42
|
+
copy_file(filename, source_subdir: 'fonts')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Icomoon::Cli::Operation.new 'Copying JSON manifest' do
|
47
|
+
copy_file('selection.json', target_filename: Icomoon::Cli::MANIFEST_FILENAME)
|
48
|
+
end
|
49
|
+
|
50
|
+
Icomoon::Cli::Operation.new do
|
51
|
+
validate_and_print_code
|
52
|
+
end
|
53
|
+
|
54
|
+
Icomoon::Cli::Operation.dump_warnings
|
55
|
+
Icomoon::Cli::Operation.dump_errors
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
attr_reader :config
|
61
|
+
|
62
|
+
def read_config
|
63
|
+
@config = Icomoon::Cli::Config.read
|
64
|
+
end
|
65
|
+
|
66
|
+
def check_source_file(path)
|
67
|
+
absolute_path = File.join(source_dir, config.icons_set_name, path)
|
68
|
+
return true if File.exists?(absolute_path)
|
69
|
+
fail Icomoon::Cli::Error, "File not found: #{absolute_path}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def copy_file(filename, source_subdir: '', target_filename: filename)
|
73
|
+
FileUtils.cp(
|
74
|
+
File.join(source_dir, config.icons_set_name, source_subdir, filename),
|
75
|
+
File.expand_path(File.join(config.fonts_file_dir, target_filename))
|
76
|
+
)
|
77
|
+
rescue StandardError => e
|
78
|
+
fail Icomoon::Cli::Error, e.message
|
79
|
+
end
|
80
|
+
|
81
|
+
def validate_and_print_code
|
82
|
+
css_icons_path = File.expand_path(config.icons_file_path)
|
83
|
+
css_icon_regex = /\&--([0-9a-z_\-]+)\:before \{\s+content: \"\\(e[0-9a-f]+)\"/
|
84
|
+
css_icons = array_to_icons(File.read(css_icons_path).scan(css_icon_regex))
|
85
|
+
|
86
|
+
svg_icons_path = File.expand_path(File.join(config.fonts_file_dir, "#{config.icons_set_name}.svg"))
|
87
|
+
svg_icon_regex = /unicode=\"&#x([0-9a-z]+);\" glyph-name=\"([0-9a-z_\-]+)\"/
|
88
|
+
svg_icons = array_to_icons(File.read(svg_icons_path).scan(svg_icon_regex).map(&:reverse))
|
89
|
+
|
90
|
+
find_unused_icons(css_icons, svg_icons)
|
91
|
+
print_code_update(css_icons, svg_icons)
|
92
|
+
end
|
93
|
+
|
94
|
+
def find_unused_icons(css_icons, svg_icons)
|
95
|
+
unused_icons = css_icons.select do |css_icon|
|
96
|
+
svg_icons.map(&:code).index(css_icon.code).nil?
|
97
|
+
end
|
98
|
+
|
99
|
+
n = unused_icons.count
|
100
|
+
|
101
|
+
return true if n.zero?
|
102
|
+
|
103
|
+
names = unused_icons.map(&:name).join(', ')
|
104
|
+
message = "#{n} unused #{n == 1 ? 'icon' : 'icons'} detected: #{names}."
|
105
|
+
Icomoon::Cli::Operation.warn! message
|
106
|
+
end
|
107
|
+
|
108
|
+
def print_code_update(css_icons, svg_icons)
|
109
|
+
missing_icons = svg_icons.select do |svg_icon|
|
110
|
+
css_icons.map(&:code).index(svg_icon.code).nil?
|
111
|
+
end
|
112
|
+
|
113
|
+
if missing_icons.count.zero?
|
114
|
+
Icomoon::Cli::Operation.warn! 'No new icons detected.'
|
115
|
+
return
|
116
|
+
end
|
117
|
+
|
118
|
+
code = missing_icons.map do |icon|
|
119
|
+
<<~STRING
|
120
|
+
&--#{icon.name}:before {
|
121
|
+
content: "\\#{icon.code}";
|
122
|
+
}
|
123
|
+
STRING
|
124
|
+
end.join("\n").cyan
|
125
|
+
|
126
|
+
puts "\nAdd this to #{config.icons_file_path}:\n\n#{code}"
|
127
|
+
end
|
128
|
+
|
129
|
+
def validate_params
|
130
|
+
if source_dir.nil?
|
131
|
+
fail Icomoon::Cli::Error, 'Source directory argument (--dir, -d) is required.'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def array_to_icons(array)
|
136
|
+
array.map do |name, code|
|
137
|
+
Icomoon::Cli::Icon.new(name, code)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
module Icomoon
|
2
|
+
module Cli
|
3
|
+
module Exec
|
4
|
+
class Init < Icomoon::Cli::Exec::Base
|
5
|
+
help <<~STRING
|
6
|
+
Usage: icomoon init [--force, -f]
|
7
|
+
|
8
|
+
This subprogram will help you to create starting
|
9
|
+
files such as icon stylesheet file and config initializer.
|
10
|
+
Just run `icomoon init` and follow instructions.
|
11
|
+
|
12
|
+
options:
|
13
|
+
|
14
|
+
--force, -f Overrides config and stylesheet files.
|
15
|
+
STRING
|
16
|
+
|
17
|
+
flag :force, '--force', '-f'
|
18
|
+
|
19
|
+
def run
|
20
|
+
config = Icomoon::Cli::Survey.run do |s|
|
21
|
+
s.ask :icons_set_name, 'Icon set name', 'icomoon-icons'
|
22
|
+
s.ask :icons_file_path, 'Path of icons stylesheet file', 'app/assets/stylesheets/_icons.scss'
|
23
|
+
s.ask :fonts_file_dir, 'Directory of fonts files', 'app/assets/fonts/'
|
24
|
+
s.ask :css_class, 'CSS icon class', 'icon'
|
25
|
+
end
|
26
|
+
|
27
|
+
dir = config[:fonts_file_dir]
|
28
|
+
manifest_path = File.expand_path(File.join(dir, Icomoon::Cli::MANIFEST_FILENAME))
|
29
|
+
|
30
|
+
Icomoon::Cli.put_separator
|
31
|
+
|
32
|
+
Icomoon::Cli::Operation.new do
|
33
|
+
ensure_pristine(config, manifest_path)
|
34
|
+
end
|
35
|
+
|
36
|
+
Icomoon::Cli::Operation.new 'Creating config file' do
|
37
|
+
write_config(config)
|
38
|
+
end
|
39
|
+
|
40
|
+
Icomoon::Cli::Operation.new 'Initializing icons stylesheet' do
|
41
|
+
write_styles(config)
|
42
|
+
end
|
43
|
+
|
44
|
+
Icomoon::Cli::Operation.new 'Creating JSON manifest' do
|
45
|
+
write_manifest(config, manifest_path)
|
46
|
+
end
|
47
|
+
|
48
|
+
Icomoon::Cli::Operation.dump_warnings
|
49
|
+
Icomoon::Cli::Operation.dump_errors
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def ensure_pristine(config, manifest_path)
|
55
|
+
return true if force?
|
56
|
+
|
57
|
+
force_tip = 'use --force (-f) option if you want to override.'
|
58
|
+
|
59
|
+
if Icomoon::Cli::Config.config_file_exists?
|
60
|
+
fail Icomoon::Cli::Error, 'Config file already exists, '\
|
61
|
+
+ force_tip
|
62
|
+
end
|
63
|
+
|
64
|
+
if Icomoon::Cli.file_exists?(config[:icons_file_path])
|
65
|
+
fail Icomoon::Cli::Error, 'Styles file already exists, '\
|
66
|
+
+ force_tip
|
67
|
+
end
|
68
|
+
|
69
|
+
if Icomoon::Cli.file_exists?(manifest_path)
|
70
|
+
fail Icomoon::Cli::Error, 'icomoon.json file already exists, '\
|
71
|
+
+ force_tip
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def write_config(config)
|
76
|
+
Icomoon::Cli::Config.write(config)
|
77
|
+
end
|
78
|
+
|
79
|
+
def write_styles(config)
|
80
|
+
icons_file_path = config[:icons_file_path]
|
81
|
+
icons_set_name = config[:icons_set_name]
|
82
|
+
css_class = config[:css_class]
|
83
|
+
|
84
|
+
Icomoon::Cli::Writer.write(icons_file_path) do |file|
|
85
|
+
file.puts(<<~STRING
|
86
|
+
@font-face {
|
87
|
+
font-family: '#{icons_set_name}';
|
88
|
+
src: asset-url('#{icons_set_name}.eot');
|
89
|
+
src: asset-url('#{icons_set_name}.eot') format('embedded-opentype'),
|
90
|
+
asset-url('#{icons_set_name}.ttf') format('truetype'),
|
91
|
+
asset-url('#{icons_set_name}.woff') format('woff');
|
92
|
+
}
|
93
|
+
|
94
|
+
.#{css_class} {
|
95
|
+
font-family: '#{icons_set_name}';
|
96
|
+
|
97
|
+
// &--icon-name:before {
|
98
|
+
// content: \"\\e900\";
|
99
|
+
// }
|
100
|
+
}
|
101
|
+
STRING
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def write_manifest(config, manifest_path)
|
107
|
+
font_name = config[:icons_set_name]
|
108
|
+
css_class = config[:css_class]
|
109
|
+
icons_file_path = config[:icons_file_path]
|
110
|
+
prefix = "#{css_class}-"
|
111
|
+
|
112
|
+
Icomoon::Cli::Writer.write_json(
|
113
|
+
manifest_path,
|
114
|
+
IcoMoonType: 'selection',
|
115
|
+
icons: [],
|
116
|
+
height: 1024,
|
117
|
+
metadata: {
|
118
|
+
name: font_name
|
119
|
+
},
|
120
|
+
preferences: {
|
121
|
+
showGlyphs: true,
|
122
|
+
showQuickUse: true,
|
123
|
+
showQuickUse2: true,
|
124
|
+
showSVGs: true,
|
125
|
+
fontPref: {
|
126
|
+
prefix: prefix,
|
127
|
+
metadata: {
|
128
|
+
fontFamily: font_name,
|
129
|
+
majorVersion: 0,
|
130
|
+
minorVersion: 1
|
131
|
+
},
|
132
|
+
metrics: {
|
133
|
+
emSize: 1024,
|
134
|
+
baseline: 6.25,
|
135
|
+
whitespace: 50
|
136
|
+
},
|
137
|
+
embed: false,
|
138
|
+
showSelector: false,
|
139
|
+
showMetrics: false,
|
140
|
+
showMetadata: false,
|
141
|
+
showVersion: false
|
142
|
+
},
|
143
|
+
imagePref: {
|
144
|
+
prefix: prefix,
|
145
|
+
png: true,
|
146
|
+
useClassSelector: true,
|
147
|
+
color: 0,
|
148
|
+
bgColor: 16777215,
|
149
|
+
classSelector: ".#{css_class}"
|
150
|
+
},
|
151
|
+
historySize: 50,
|
152
|
+
showCodes: true,
|
153
|
+
gridSize: 16
|
154
|
+
}
|
155
|
+
)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Icomoon
|
2
|
+
module Cli
|
3
|
+
class Operation
|
4
|
+
@@warnings = []
|
5
|
+
@@errors = []
|
6
|
+
@@skip_all = false
|
7
|
+
|
8
|
+
def initialize(name = nil)
|
9
|
+
return unless block_given?
|
10
|
+
return if self.class.skip?
|
11
|
+
|
12
|
+
Icomoon::Cli.log "#{name}... " if name
|
13
|
+
|
14
|
+
begin
|
15
|
+
yield
|
16
|
+
puts '✔'.green if name
|
17
|
+
rescue Icomoon::Cli::Error => error
|
18
|
+
@@errors << error
|
19
|
+
puts '✘'.red if name
|
20
|
+
Icomoon::Cli::Operation.skip_all!
|
21
|
+
rescue Icomoon::Cli::Warning => warning
|
22
|
+
@@warnings << warning
|
23
|
+
puts '✘'.red if name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.dump_warnings
|
28
|
+
while (warning = @@warnings.shift)
|
29
|
+
Icomoon::Cli.logs "#{'Warning:'.yellow} #{warning.message}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.dump_errors(exit_code = nil)
|
34
|
+
while (error = @@errors.shift)
|
35
|
+
Icomoon::Cli.logs "#{'Error:'.red} #{error.message}"
|
36
|
+
end
|
37
|
+
|
38
|
+
exit(exit_code) if exit_code
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.warn!(message)
|
42
|
+
@@warnings << Icomoon::Cli::Operation::Warning.new(message)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.skip_all!
|
46
|
+
@@skip_all = true
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.skip?
|
50
|
+
@@skip_all
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Icomoon
|
2
|
+
module Cli
|
3
|
+
class ParseArgv
|
4
|
+
def self.call(argv, params)
|
5
|
+
result = {}
|
6
|
+
|
7
|
+
params.each do |param|
|
8
|
+
param.aliases.each do |aliaz|
|
9
|
+
idx = argv.find_index { |arg| argv.include? aliaz }
|
10
|
+
|
11
|
+
if idx
|
12
|
+
value = param.needs_value ? argv.delete_at(idx + 1) : true
|
13
|
+
argv.delete_at(idx)
|
14
|
+
result[param.key] = value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if argv.count.nonzero?
|
20
|
+
Icomoon::Cli.error "Unrecognized arguments: #{argv.join(', ')}"
|
21
|
+
end
|
22
|
+
|
23
|
+
result
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Icomoon
|
2
|
+
module Cli
|
3
|
+
class Survey
|
4
|
+
def initialize
|
5
|
+
@questions = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def ask(value, name, default = nil)
|
9
|
+
questions << Icomoon::Cli::Question.new(value, name, default)
|
10
|
+
end
|
11
|
+
|
12
|
+
def read!
|
13
|
+
Hash.new.tap do |answers|
|
14
|
+
questions.each do |q|
|
15
|
+
Icomoon::Cli.log "#{'question'.light_black} #{q.name} (#{q.default || 'none'}): "
|
16
|
+
|
17
|
+
answer = (gets || '').chomp
|
18
|
+
answer = q.default if /\A[\s]*\z/.match?(answer)
|
19
|
+
|
20
|
+
answers[q.value] = answer
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.run
|
26
|
+
survey = new
|
27
|
+
yield(survey)
|
28
|
+
survey.read!
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :questions
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Icomoon
|
2
|
+
module Cli
|
3
|
+
class Writer
|
4
|
+
class << self
|
5
|
+
def write(path)
|
6
|
+
return unless block_given?
|
7
|
+
|
8
|
+
path = File.expand_path(path)
|
9
|
+
|
10
|
+
File.new(path, 'w+').tap do |file|
|
11
|
+
yield file
|
12
|
+
file.close
|
13
|
+
end
|
14
|
+
|
15
|
+
path
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_json(path, json = {})
|
19
|
+
write(path) do |file|
|
20
|
+
file.puts(JSON.pretty_generate(json))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: icomoon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- polakowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
description: Rails helper makes using Icomoon easier.
|
42
|
+
email: marek.polakowski@gmail.com
|
43
|
+
executables:
|
44
|
+
- icomoon
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- README.md
|
49
|
+
- bin/icomoon
|
50
|
+
- lib/icomoon.rb
|
51
|
+
- lib/icomoon/cli.rb
|
52
|
+
- lib/icomoon/cli/config.rb
|
53
|
+
- lib/icomoon/cli/exec.rb
|
54
|
+
- lib/icomoon/cli/exec/base.rb
|
55
|
+
- lib/icomoon/cli/exec/help.rb
|
56
|
+
- lib/icomoon/cli/exec/import.rb
|
57
|
+
- lib/icomoon/cli/exec/init.rb
|
58
|
+
- lib/icomoon/cli/exec_param.rb
|
59
|
+
- lib/icomoon/cli/icon.rb
|
60
|
+
- lib/icomoon/cli/logger.rb
|
61
|
+
- lib/icomoon/cli/operation.rb
|
62
|
+
- lib/icomoon/cli/parse_argv.rb
|
63
|
+
- lib/icomoon/cli/question.rb
|
64
|
+
- lib/icomoon/cli/survey.rb
|
65
|
+
- lib/icomoon/cli/writer.rb
|
66
|
+
- lib/icomoon/version.rb
|
67
|
+
homepage: https://github.com/polakowski/icomoon
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.2.2
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.4.8
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Icomoon helper
|
91
|
+
test_files: []
|