icomoon_as_well 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 81c3a66c336cd2e723e2c29e458765f5eb737a1e
4
+ data.tar.gz: dc36c622c7b5c34d3acdacdd61acf7c7b1197c42
5
+ SHA512:
6
+ metadata.gz: bf5a935e1220eb4aa4b4f1523986e293064345ad23b032db2a75ab8487b56729a5df611f0876008605e98a7fc41d2f45662023b12aa0d297accd253ba43a6ac5
7
+ data.tar.gz: 0e12a628621ee300cc976e1d5857bf40ccada981f9656abe4fc6f66a83ced18963fd741ec7071cc4da084874cdd0091ac539ca9b0ff236699f62446705fc7443
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "icomoon_as_well"
4
+
5
+ if File.exist?(ARGV[0].to_s) && ARGV[0].to_s =~ /^.+\.zip$/ && Dir.exist?(ARGV[1].to_s)
6
+ target = ARGV[1].split("/")
7
+ if ARGV[2] == "--rails"
8
+ target << "app" << "assets"
9
+ end
10
+ icomoon = IcomoonAsWell::Icomoon.new(ARGV[0], File.join(target), ARGV[2].to_s == "--rails")
11
+ end
12
+
@@ -0,0 +1,44 @@
1
+ require 'fileutils'
2
+
3
+ module IcomoonAsWell
4
+ module FileHelper
5
+ def parse_css(file)
6
+ icons = {}
7
+ c = 0
8
+ lines = file.split("\n")
9
+ while c <= lines.count
10
+ line = lines[c]
11
+ c += 1
12
+ if line.to_s =~ /^\.icon-(\S+):before\s*{\s*$/
13
+ icon_name = $1
14
+ value = lines[c]
15
+ c += 1
16
+ icon_name.gsub!(/\s+/, '')
17
+ value.gsub!(/^\s+/, '').gsub!(/content:/, '').gsub!(/["'\\\s\;]+/, '')
18
+ icons[icon_name] = value
19
+ end
20
+ end
21
+ icons
22
+ end
23
+ def put_files(entry, names, target_dir)
24
+ unless Dir.exist?(target_dir)
25
+ FileUtils.mkpath(target_dir)
26
+ end
27
+ names.each do |name|
28
+ filename = name.gsub(/^.+\//, '')
29
+ File.open(File.join(target_dir, filename), "w"){ |file| file.write(entry[name]) }
30
+ end
31
+ end
32
+
33
+ def icomoon_dir(target_dir)
34
+ unless Dir.exists?("#{target_dir}/stylesheets")
35
+ FileUtils.mkpath(File.join(target_dir, "stylesheets"))
36
+ end
37
+ unless Dir.exists?("#{target_dir}/stylesheets/icomoon")
38
+ FileUtils.mkpath(File.join(target_dir, "stylesheets", "icomoon"))
39
+ end
40
+ "#{target_dir}/stylesheets/icomoon"
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,2 @@
1
+ $icomoon-prefix: "icon";
2
+ @include font-face-as-well("Icomoon", "icomoon");
@@ -0,0 +1,6 @@
1
+ <% @icomoon_variables.each do |key, value| %>.#{$icomoon-prefix}-<%=key%> {
2
+ &:before {
3
+ content: $icon-<%=key%>;
4
+ }
5
+ }
6
+ <% end %>
@@ -0,0 +1,13 @@
1
+ [class^="#{$icomoon-prefix}-"], [class*=" #{$icomoon-prefix}-"] {
2
+ speak: none;
3
+ font-style: normal;
4
+ font-weight: normal;
5
+ font-variant: normal;
6
+ text-transform: none;
7
+ -webkit-font-smoothing: antialiased;
8
+ -moz-osx-font-smoothing: grayscale;
9
+ &:before {
10
+ font-family: "Icomoon";
11
+ }
12
+ }
13
+
@@ -0,0 +1,45 @@
1
+ @mixin font-face-as-well($name, $filename, $weight: normal, $style: normal, $prefix: '') {
2
+ @font-face {
3
+ font-family: $name;
4
+ src: url(asset-path('#{$name}/#{$filename}#{$prefix}.eot'));
5
+ src: url(asset-path('#{$name}/#{$filename}#{$prefix}.svg##{$name}')) format('svg'),
6
+ url(asset-path('#{$name}/#{$filename}#{$prefix}.eot?#iefix')) format('embedded-opentype'),
7
+ url(asset-path('#{$name}/#{$filename}#{$prefix}.woff')) format('woff'),
8
+ url(asset-path('#{$name}/#{$filename}#{$prefix}.ttf')) format('truetype');
9
+ font-weight: $weight;
10
+ font-style: $style;
11
+ }
12
+ }
13
+ @mixin icon-prop {
14
+ font-family: "Icomoon";
15
+ font-weight: normal;
16
+ font-style: normal;
17
+ }
18
+ @mixin icomoon($icon){
19
+ &:before {
20
+ content: $icon;
21
+ font-family: "Icomoon";
22
+ @include icon-prop;
23
+ }
24
+ }
25
+ @mixin icon-pseudo($icon, $times: 1){
26
+ $content: '';
27
+ @if $times > 1 {
28
+ @for $i from 1 through $times {
29
+ $content: #{$content$icon};
30
+ }
31
+ }
32
+ @else {
33
+ $content: $icon;
34
+ }
35
+ content: $content;
36
+ @include icon-prop;
37
+ @content
38
+ }
39
+ @mixin icomoon-after($icon){
40
+ &:after {
41
+ content: $icon;
42
+ @include icon-prop;
43
+ }
44
+ }
45
+
@@ -0,0 +1,2 @@
1
+ <% @icomoon_variables.each do |key, value| %>$icon-<%=key%>: "\<%=value%>";
2
+ <% end %>
@@ -0,0 +1,17 @@
1
+ require 'zip'
2
+
3
+ module IcomoonAsWell
4
+ class Unzip
5
+ attr_reader :files
6
+ def initialize(path)
7
+ @files = {}
8
+ Zip::File.open(path) do |zip|
9
+ zip.each do |entry|
10
+ if entry.file?
11
+ @files[entry.name] = entry.get_input_stream.read
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module IcomoonAsWell
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'erb'
2
+ require "icomoon_as_well/version"
3
+ require "icomoon_as_well/unzip"
4
+ require "icomoon_as_well/file_helper"
5
+
6
+ module IcomoonAsWell
7
+ class Icomoon
8
+ include FileHelper
9
+ def initialize(path, target_dir, is_rails)
10
+ @archive = Unzip.new(path)
11
+ put_files(@archive.files, @archive.files.keys.map{|name| name if name =~ /^fonts\/(.+)$/}.compact, File.join(target_dir, "fonts", "Icomoon"))
12
+ @icomoon_variables = parse_css(@archive.files["style.css"])
13
+ @icon_prefix = "icon"
14
+ ["variables", "icons", "core", "mixins", "main"].each do |tpl|
15
+ renderer = ::ERB.new File.read("#{File.dirname(__FILE__)}/icomoon_as_well/templates/#{tpl}.scss.erb")
16
+ File.open(File.join(icomoon_dir(target_dir), "#{tpl}.scss"), "w"){|f| f.write(renderer.result(binding)) }
17
+ end
18
+ if is_rails && target_dir =~ /^(.+)\/app\/assets.*$/
19
+ app_dir = $1
20
+ put_files(@archive.files, ["selection.json"], File.join(app_dir, "doc"))
21
+ end
22
+ end
23
+ end
24
+ end
25
+
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icomoon_as_well
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubyzip
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ description: Icomoon unpacker in a best way
56
+ email:
57
+ - babakhanov1@gmail.com
58
+ executables:
59
+ - icomoon_as_well
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - bin/icomoon_as_well
64
+ - lib/icomoon_as_well.rb
65
+ - lib/icomoon_as_well/file_helper.rb
66
+ - lib/icomoon_as_well/templates/core.scss.erb
67
+ - lib/icomoon_as_well/templates/icons.scss.erb
68
+ - lib/icomoon_as_well/templates/main.scss.erb
69
+ - lib/icomoon_as_well/templates/mixins.scss.erb
70
+ - lib/icomoon_as_well/templates/variables.scss.erb
71
+ - lib/icomoon_as_well/unzip.rb
72
+ - lib/icomoon_as_well/version.rb
73
+ homepage: https://github.com/babakhanov1
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.5.1
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Icomoon unpacker
97
+ test_files: []