octicons_v2 0.0.0.pre.02f9d7a → 0.0.0.pre.3ba887a

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
  SHA256:
3
- metadata.gz: a1aee7edd4eb9c2b6061fee731298abb940bb05dfd5ee1c0f291da2a1177f68f
4
- data.tar.gz: ba6dd42e0154246c3d8b59e67532140ac265b44a07aa3aad35c59da0bae1da16
3
+ metadata.gz: 5ccaa6fe4043aadd722dd6d6f33578abad77f18ba1849e234e828ba48183bdf6
4
+ data.tar.gz: bb83495bb4336fbddad85fc4d0583d1262813900a7a135aefab13667a1d01cb4
5
5
  SHA512:
6
- metadata.gz: f8e611d19c64419e4b1399dc9214d79a316206e77307fde5c2f86e11e6f05482a07ecf9e7d9dfe123eb3ff9cb2eb44c620976a6370d956dd7351977ca3bce01f
7
- data.tar.gz: 7a6650c7d35896b034ec65abd16c471812075dc209f27ec11e94510459606f0acfbf6094c3120e6ece7cecee07833bf2fc3d0ecdf526c734ed5f3933114aeb7c
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["path"]
11
- @width = octicon["width"]
12
- @height = octicon["height"]
13
- @keywords = octicon["keywords"]
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
- # We're using width as an approximation for height if the height option is not passed in
89
- height = options[:height] || options[:width] || DEFAULT_HEIGHT
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
- "name" => octicon["name"],
93
- "keywords" => octicon["keywords"],
94
- "width" => octicon["heights"][natural_height.to_s]["width"].to_i,
95
- "height" => natural_height,
96
- "path" => octicon["heights"][natural_height.to_s]["path"]
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 closest_natural_height(natural_heights, height)
102
- return natural_heights.reduce(natural_heights[0].to_i) do |acc, natural_height|
103
- natural_height.to_i <= height.to_i ? natural_height.to_i : acc
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
@@ -1,3 +1,3 @@
1
1
  module OcticonsV2
2
- VERSION = "0.0.0.pre.02f9d7a".freeze
2
+ VERSION = "0.0.0.pre.3ba887a".freeze
3
3
  end
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.02f9d7a
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-31 00:00:00.000000000 Z
11
+ date: 2020-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri