fontello_rails_converter 0.2.0 → 0.3.0
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 +8 -8
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/README.md +2 -0
- data/bin/fontello +31 -6
- data/lib/fontello_rails_converter/cli.rb +10 -4
- data/lib/fontello_rails_converter/fontello_api.rb +2 -2
- data/lib/fontello_rails_converter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzdhMjhjZGZjMjE1NDNjYmYxNzQ3NjIwZDMyYTI1YjA5Y2FjMGRhMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2NlYTNmNWFjMTAyMjVmN2IzNGVlN2YxYmM1ZjFjZDc5NjcwYThkNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2VkZGMxNmQ4MDljOTIwZWE4YjdiYjJmOTY1ZTJmNjIwY2FlNTc2ZThhNzcz
|
10
|
+
OWQzNzYzMmYxOWFlYjllYjI3OGE3ODU5NTQwNjA0MTZkNGEzMmMzMzQ4YTk3
|
11
|
+
OGI5ZTM3MGZiZTE4Mjc2OTYyYjI3ZGY1NjI2YWI1MTU3OTliYTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGZiZTUzOTVjMWYwNTAyZTc3MTY3NDZhYTBhZDhlZTNkOGUzNTEzMTBjOWIw
|
14
|
+
YWUzNDk3YmJhMjhkZWQwMjVkZTUyZDQwNGVhN2RlYTYyNzM2YTRiOWU5ODli
|
15
|
+
ODAwYmJmYzE4YWQ0MmYyZWQ2NWU2NjBjYThkMjk3NjRiNjM0MTc=
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 0.3.0
|
4
|
+
|
5
|
+
* allow setting global options using a .yml file (e.g. /rails_root/config/fontello_rails_converter.yml)
|
6
|
+
* allow configuration of the stylesheet extension for the SCSS files (`.css.scss` or `.scss`)
|
7
|
+
* fail gracefully when there is no config file yet (90ec5942383cc5558a097aa78c4adcc809ab6a0e)
|
8
|
+
* fixes for 2 encoding issues #11 and #12 by @hqm42
|
9
|
+
|
3
10
|
### 0.2.0
|
4
11
|
|
5
12
|
* removed deprecated rake task
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
## fontello_rails_converter
|
2
2
|
|
3
|
+
[](https://travis-ci.org/railslove/fontello_rails_converter)
|
4
|
+
|
3
5
|
CLI gem for comfortably working with icon fonts from [http://fontello.com](http://fontello.com) for usage in Rails apps.
|
4
6
|
|
5
7
|
Main features:
|
data/bin/fontello
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
+
require 'yaml'
|
4
5
|
require "fontello_rails_converter"
|
5
6
|
command = ARGV[0]
|
6
7
|
|
@@ -9,19 +10,34 @@ if ARGV[0].nil?
|
|
9
10
|
exit
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
+
def set_options_based_on_rails_root(options)
|
13
14
|
options[:asset_dir] = "#{options[:rails_root_dir]}/vendor/assets"
|
14
15
|
options.merge!({
|
15
16
|
stylesheet_dir: "#{options[:asset_dir]}/stylesheets",
|
16
17
|
font_dir: "#{options[:asset_dir]}/fonts",
|
17
18
|
zip_file: "#{options[:rails_root_dir]}/tmp/fontello.zip",
|
18
19
|
config_file: "#{options[:asset_dir]}/fonts/config.json",
|
19
|
-
fontello_session_id_file: "#{options[:rails_root_dir]}/tmp/fontello_session_id"
|
20
|
+
fontello_session_id_file: "#{options[:rails_root_dir]}/tmp/fontello_session_id",
|
21
|
+
options_file: "#{options[:rails_root_dir]}/config/fontello_rails_converter.yml"
|
20
22
|
})
|
21
23
|
end
|
22
24
|
|
23
|
-
options
|
24
|
-
|
25
|
+
def set_options_from_file(options)
|
26
|
+
if File.exist?(options[:options_file])
|
27
|
+
options_from_file = YAML.load_file options[:options_file]
|
28
|
+
options_from_file.each do |key, value|
|
29
|
+
options[key.to_sym] = value if options.keys.include?(key.to_sym)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# defaults
|
35
|
+
options = {
|
36
|
+
rails_root_dir: '.',
|
37
|
+
stylesheet_extension: '.css.scss'
|
38
|
+
}
|
39
|
+
set_options_based_on_rails_root(options)
|
40
|
+
set_options_from_file(options)
|
25
41
|
|
26
42
|
OptionParser.new do |opts|
|
27
43
|
opts.banner = "Usage: fontello COMMAND [options]\n\n"
|
@@ -30,6 +46,11 @@ OptionParser.new do |opts|
|
|
30
46
|
|
31
47
|
opts.separator "Global options:"
|
32
48
|
|
49
|
+
opts.on("-o", "--options-file [PATH]", "options .yml file (default: /rails_root/config/fontello_rails_converter.yml)") do |opt|
|
50
|
+
options[:options_file] = opt
|
51
|
+
set_options_from_file(options)
|
52
|
+
end
|
53
|
+
|
33
54
|
opts.on("-i", "--fontello-session-id [ID]", "Pass in session ID from fontello.com (e.g. fb235ab72cad01d2b46aaa023ab4abbd) otherwise it will be taken from session-id-file\n\n") do |opt|
|
34
55
|
options[:fontello_session_id] = opt
|
35
56
|
end
|
@@ -42,7 +63,11 @@ OptionParser.new do |opts|
|
|
42
63
|
|
43
64
|
opts.separator "`convert` options:"
|
44
65
|
|
45
|
-
opts.on("-n", "--no-download", "Converts existing .zip file without automatically downloading a new one
|
66
|
+
opts.on("-n", "--no-download", "Converts existing .zip file without automatically downloading a new one") do |opt|
|
67
|
+
options[:no_download] = true
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on("--stylesheet-extension", "Pick between e.g. '.css.scss' or '.scss'\n\n") do |opt|
|
46
71
|
options[:no_download] = true
|
47
72
|
end
|
48
73
|
|
@@ -56,7 +81,7 @@ OptionParser.new do |opts|
|
|
56
81
|
|
57
82
|
opts.on("-r", "--rails-root [PATH]", "Rails root path (default: current location)") do |opt|
|
58
83
|
options[:rails_root_dir] = opt
|
59
|
-
|
84
|
+
set_options_based_on_rails_root(options)
|
60
85
|
end
|
61
86
|
|
62
87
|
opts.on("-c", "--config-file [PATH]", "config.json file (default: /rails_root/vendor/assets/fonts/config.json)") do |opt|
|
@@ -12,8 +12,14 @@ module FontelloRailsConverter
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def open
|
15
|
-
|
16
|
-
|
15
|
+
if config_file_exists?
|
16
|
+
@fontello_api.new_session_from_config unless @options[:open_existing] == true
|
17
|
+
Launchy.open @fontello_api.session_url
|
18
|
+
else
|
19
|
+
puts red("there's no config file yet!")
|
20
|
+
puts red("follow these instructions: https://github.com/railslove/fontello_rails_converter#initial-usage")
|
21
|
+
puts red("to setup your project")
|
22
|
+
end
|
17
23
|
end
|
18
24
|
|
19
25
|
def download
|
@@ -34,12 +40,12 @@ module FontelloRailsConverter
|
|
34
40
|
# stylesheets
|
35
41
|
if filename.end_with? '.css'
|
36
42
|
# extract stylesheet to target location
|
37
|
-
target_file = File.join @options[:stylesheet_dir],
|
43
|
+
target_file = File.join @options[:stylesheet_dir], filename.gsub('.css', @options[:stylesheet_extension])
|
38
44
|
zipfile.extract(file, target_file) { true }
|
39
45
|
puts green("copied #{target_file}")
|
40
46
|
|
41
47
|
if !filename.end_with? "animation.css", "-ie7.css", "-codes.css", "-ie7-codes.css", "-embedded.css"
|
42
|
-
converted_css = self.convert_main_stylesheet File.read(target_file)
|
48
|
+
converted_css = self.convert_main_stylesheet File.read(target_file).encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
43
49
|
File.open(target_file, 'w') { |f| f.write(converted_css) }
|
44
50
|
puts green("converted #{target_file} for Sass & asset pipeline")
|
45
51
|
end
|
@@ -24,7 +24,7 @@ module FontelloRailsConverter
|
|
24
24
|
|
25
25
|
def download_zip_body
|
26
26
|
response = RestClient.get "#{session_url}/get"
|
27
|
-
response.body
|
27
|
+
response.body.force_encoding("UTF-8")
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -46,4 +46,4 @@ module FontelloRailsConverter
|
|
46
46
|
File.open(@fontello_session_id_file, 'w+') { |f| f.write @session_id }
|
47
47
|
end
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontello_rails_converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Hilden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|