octicons_v2 0.0.0.pre.02f9d7a → 0.0.0.pre.3ba887a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/octicons_v2/octicon_v2.rb +14 -16
- data/lib/octicons_v2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ccaa6fe4043aadd722dd6d6f33578abad77f18ba1849e234e828ba48183bdf6
|
4
|
+
data.tar.gz: bb83495bb4336fbddad85fc4d0583d1262813900a7a135aefab13667a1d01cb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b7cdc2d1c5ab5182dfc1430e4d096a3700504c803a2305a91dc10928b20eb2aac41625a5a6eb0ada27a6c63ef3c52899b5971eadcf68716de74910c849d763c
|
7
|
+
data.tar.gz: 4dde20a0c432224aeaaf8a341fa56d1e5ba00df555354ca9515cb6390d7b56c2c72f16c243e91329d23a005c1676de306f453edacee915dd4bf07b14689dbaf3
|
@@ -1,16 +1,15 @@
|
|
1
1
|
module OcticonsV2
|
2
2
|
class OcticonV2
|
3
|
-
DEFAULT_HEIGHT = 16
|
4
3
|
|
5
4
|
attr_reader :path, :options, :width, :height, :symbol, :keywords
|
6
5
|
|
7
6
|
def initialize(symbol, options = {})
|
8
7
|
@symbol = symbol.to_s
|
9
8
|
if octicon = get_octicon(@symbol, options)
|
10
|
-
@path = octicon[
|
11
|
-
@width = octicon[
|
12
|
-
@height = octicon[
|
13
|
-
@keywords = octicon[
|
9
|
+
@path = octicon[:path]
|
10
|
+
@width = octicon[:width]
|
11
|
+
@height = octicon[:height]
|
12
|
+
@keywords = octicon[:keywords]
|
14
13
|
@options = options
|
15
14
|
@options.merge!({
|
16
15
|
class: classes,
|
@@ -85,22 +84,21 @@ module OcticonsV2
|
|
85
84
|
|
86
85
|
def get_octicon(symbol, options = {})
|
87
86
|
if octicon = OcticonsV2::OCTICON_SYMBOLS[symbol]
|
88
|
-
|
89
|
-
|
90
|
-
natural_height = closest_natural_height(octicon["heights"].keys, height)
|
87
|
+
height = options[:height] || options[:width] || 16
|
88
|
+
octicon_height = closest_octicon_height(octicon["heights"].keys, height)
|
91
89
|
return {
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
90
|
+
name: octicon["name"],
|
91
|
+
keywords: octicon["keywords"],
|
92
|
+
width: octicon["heights"][octicon_height.to_s]["width"].to_i,
|
93
|
+
height: octicon_height,
|
94
|
+
path: octicon["heights"][octicon_height.to_s]["path"]
|
97
95
|
}
|
98
96
|
end
|
99
97
|
end
|
100
98
|
|
101
|
-
def
|
102
|
-
return
|
103
|
-
|
99
|
+
def closest_octicon_height(octicon_heights, height)
|
100
|
+
return octicon_heights.reduce(octicon_heights[0].to_i) do |acc, octicon_height|
|
101
|
+
octicon_height.to_i <= height.to_i ? octicon_height.to_i : acc
|
104
102
|
end
|
105
103
|
end
|
106
104
|
end
|
data/lib/octicons_v2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octicons_v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.pre.
|
4
|
+
version: 0.0.0.pre.3ba887a
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|