icomoon-cli 0.1.0 → 0.1.1

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: a16aae804f9d6388ccd24169bbb87e9d94737238
4
- data.tar.gz: c9502529623e5557593947268a8799b4f208bfc0
3
+ metadata.gz: 54e58814511a2c9deb563392dd4e81f3cd6bf09e
4
+ data.tar.gz: 50dcc0a2ccdef3347f25886958d98eb3bd0cb4ce
5
5
  SHA512:
6
- metadata.gz: 34307bd99ec210bc6456d7b5d35bdf74d1a49a6ba90e9b59aa44635b9ee83c4bd46c1e4af5e2a52c48fc483fb1dfe67991707bb031661a4506df9c657a1c933b
7
- data.tar.gz: aba80d9a9e24334384653fbadd7ca3e1f5827e1a1c696c0c97b98b0643a88309c6452d3d34e002c8bcfde00c611b21084b3c2da72fa48aad5dba8ec6d0453099
6
+ metadata.gz: b197ef77ff83ec3bbbd7fa7c67e2494bcd9e7f44e816889ec049adac49345849f2c1455e22dffa7ef2cdd09fc430cb74049ccd63a525f9aa3272104e63e2af17
7
+ data.tar.gz: 96fa42273490b74a02d4ae8e4cf01da98df6cfa677f7f41b5e0ad9846c9a81388f01ec6999d7367dc331dc0a674d7e44c1c324072ba8e192770926efd4335c29
data/README.md CHANGED
@@ -1,18 +1,31 @@
1
1
  # Icomoon
2
2
 
3
- Icomoon gem helps to update icomoon assets via command line. this gem will automate all the steps to be done while we update icomoon's icon list.
3
+ Icomoon gem helps to update icomoon's icons via command line. this gem will automate all the steps to be done while we update icomoon's icon set.
4
4
 
5
5
  ## Installation
6
6
 
7
-
8
- $ gem install icomoon
7
+ $ gem install icomoon-cli
9
8
 
10
9
  ## Usage
11
10
 
11
+ - Open [Iconmoon App](https://icomoon.io/app/#/projects)
12
+ - Follow this [Documentation](https://icomoon.io/docs.html) to know how to get started with icomoon.
13
+ - Once you have created icon set download the icon set.
14
+ - By default this gem assume it's Rails Application hence will be importing to our default rails assets folder and will be keeping a copy of `selection.json` file in our applications **public folder**. if you want to customise the path you can create a file name `.icomoon.yml` add the key value pair as follows in the root of project directory.
15
+
16
+ ```yml
17
+ working_directory: "/vendor/icofont/tmp"
18
+ font_directory: "/vendor/icofont/fonts"
19
+ stylesheet_directory: "/vendor/icofont/stylesheets"
20
+ stylesheet: "icons.scss"
21
+ selection_directory: "/vendor/icofont/stylesheets"
22
+ ```
23
+
24
+ - You can either give path for icomoon's generated zip file or you can just give path to the extracted icon set folder.
12
25
 
13
- $ icomoon [path/to/icomoon.zip file]
26
+ $ icomoon [path/to/icomoon]
27
+
14
28
 
15
- > By default this gem assume icomoon assets resides inside our default rails assets folder and this will keep a copy of selection.json file in our applications public folder.
16
29
 
17
30
  ## Contributing
18
31
 
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'icomoon'
3
3
 
4
- icomoon_zip = ARGV[0]
4
+ icomoon_files = ARGV[0]
5
5
 
6
- abort "Provide a file path to icomoon zip file" unless icomoon_zip
6
+ abort "Provide a file path to icomoon files" unless icomoon_files
7
7
 
8
- Icomoon.update(icomoon_zip)
8
+ Icomoon.import(icomoon_files)
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Vishal Taj PM"]
9
9
  spec.email = ["vishaltajpm@gmail.com"]
10
10
 
11
- spec.summary = %q{Gem is used to update icomoon icons}
12
- spec.description = %q{Gem is used to update icomoon icons in rails application}
11
+ spec.summary = "A command line tool to update icomoon icon sets for rails application"
12
+ spec.description = "Icomoon gem helps to update icomoon's icons via command line. this gem will automate all the steps to be done while we update icomoon's icon set."
13
13
  spec.homepage = "https://github.com/VishalTaj/icomoon"
14
14
  spec.license = "MIT"
15
15
 
@@ -1,33 +1,47 @@
1
1
  require "icomoon/version"
2
2
 
3
+ require 'yaml'
4
+
3
5
  module Icomoon
4
6
  class Error < StandardError; end
5
- def self.update(zipfile)
7
+ def self.import(icomoon_files)
6
8
  begin
7
- zipfile = File.join(zipfile)
9
+ icomoon_files = File.join(icomoon_files)
8
10
  app_root = Dir.getwd
9
- tmpdir = File.join(app_root, 'tmp', 'iconfont')
10
- vendorfontsdir = File.join(app_root, 'app', 'assets', 'fonts')
11
- vendorcssdir = File.join(app_root, 'app', 'assets', 'stylesheets')
11
+ icon_config = YAML.load_file(File.join(app_root, '.icomoon.yml')).to_hash rescue {}
12
+
13
+ working_dir = icon_config["working_directory"] ? File.join(app_root, icon_config["working_directory"], "icofont") : File.join(app_root, 'tmp', 'iconfont')
14
+ working_dir = File.expand_path(working_dir)
15
+ font_dir = icon_config["font_directory"] ? File.join(app_root, icon_config["font_directory"]) : File.join(app_root, 'app', 'assets', 'fonts')
16
+ css_dir = icon_config["stylesheet_directory"] ? File.join(app_root, icon_config["stylesheet_directory"]) : File.join(app_root, 'app', 'assets', 'stylesheets')
17
+ selection_dir = icon_config["selection_directory"] ? File.join(app_root, icon_config["selection_directory"]) : File.join(app_root, 'public', 'selection.json')
18
+ stylesheet_name = icon_config["stylesheet"] || 'icons.css'
12
19
 
13
- if !File.exist?(File.join(app_root, 'tmp')) || !File.exist?(vendorfontsdir) || !File.exist?(vendorcssdir)
14
- abort "Current directory not a Rails app directory."
20
+ if (!File.exist?(File.join(app_root, 'tmp')) || !icon_config["working_directory"]) || !File.exist?(font_dir) || !File.exist?(css_dir)
21
+ abort "Current directory doesn't seems to be an application directory. please move to project root folder and run again"
15
22
  end
16
23
 
17
- unless File.directory? tmpdir
18
- system "mkdir #{tmpdir}"
24
+ unless File.directory? working_dir
25
+ system "mkdir #{working_dir}"
19
26
  end
20
27
 
21
- system "unzip -u #{zipfile} -d #{tmpdir}"
28
+ if File.extname(icomoon_files) == '.zip'
29
+ system "unzip -u #{icomoon_files} -d #{working_dir}"
30
+ is_temp = true
31
+ else
32
+ working_dir = File.expand_path(icomoon_files)
33
+ is_temp = false
34
+ end
22
35
 
23
- Dir.glob(File.join(tmpdir, 'fonts', '*')) do |file|
24
- puts "Copying #{file} to #{vendorfontsdir}"
25
- system "cp #{file} #{vendorfontsdir}"
36
+ Dir.glob(File.join(working_dir, 'fonts', '*')) do |file|
37
+ puts "Copying #{file} to #{font_dir}"
38
+ system "cp #{file} #{font_dir}"
26
39
  end
27
40
 
28
41
  puts 'Copying the stylesheet'
29
- stylesheet = File.join(vendorcssdir, 'icons.scss')
30
- system "cp #{File.join(tmpdir, 'style.css')} #{stylesheet}"
42
+ stylesheet = File.join(css_dir, stylesheet_name)
43
+ File.write(stylesheet, "") unless File.exist?(stylesheet)
44
+ system "cp #{File.join(working_dir, 'style.css')} #{stylesheet}"
31
45
 
32
46
  puts 'Updating font URLs in stylesheet'
33
47
  stylesheet_content = File.read(stylesheet)
@@ -37,12 +51,12 @@ module Icomoon
37
51
  end
38
52
 
39
53
  puts 'Updating selection.json file'
40
- system "cp -rf #{File.join(tmpdir, 'selection.json')} #{File.join(app_root, 'public', 'selection.json')}"
54
+ system "cp -f #{File.join(working_dir, 'selection.json')} #{File.join(selection_dir)}"
41
55
 
42
56
  ensure
43
- if File.directory? tmpdir
57
+ if File.directory?(working_dir) && is_temp
44
58
  puts 'Deleting tmp folder'
45
- system "rm -rf #{tmpdir}"
59
+ system "rm -rf #{working_dir}"
46
60
  end
47
61
  end
48
62
  end
@@ -1,3 +1,3 @@
1
1
  module Icomoon
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icomoon-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vishal Taj PM
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-22 00:00:00.000000000 Z
11
+ date: 2019-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
- description: Gem is used to update icomoon icons in rails application
55
+ description: Icomoon gem helps to update icomoon's icons via command line. this gem
56
+ will automate all the steps to be done while we update icomoon's icon set.
56
57
  email:
57
58
  - vishaltajpm@gmail.com
58
59
  executables:
@@ -100,5 +101,5 @@ rubyforge_project:
100
101
  rubygems_version: 2.6.13
101
102
  signing_key:
102
103
  specification_version: 4
103
- summary: Gem is used to update icomoon icons
104
+ summary: A command line tool to update icomoon icon sets for rails application
104
105
  test_files: []