agric 0.0.1 → 0.0.2

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.
@@ -140,27 +140,37 @@ module Agric
140
140
 
141
141
  reference_file = compiler_dir.join('reference.yml')
142
142
  reference = YAML.load_file(reference_file)
143
+ reference = {} unless reference.is_a?(Hash)
143
144
 
144
145
  icons = {}
145
146
 
146
147
  Dir.chdir(glyphs) do
147
- config["glyphs"] = Dir.glob("*.svg").sort.collect do |cf|
148
- name = cf.split(/\./).first
149
- icons[name] = reference[name] || (reference.values.sort.last || "efff").to_i(16).succ.to_s(16)
150
- reference[name] = icons[name]
151
- {"css" => name, "code" => icons[name].to_i(16)}
148
+ Dir.glob("*.svg").sort.collect do |cf|
149
+ name = cf.split(/\./).first.to_s
150
+ unless reference.has_key?(name)
151
+ reference[name] = (reference.values.sort.last || "efff").to_i(16).succ.to_s(16)
152
+ end
153
+ icons[name] = reference[name]
152
154
  end
153
155
  end
154
-
156
+
155
157
  # Removes undefined glyphs from reference
156
158
  for ref in reference.keys
157
159
  reference.delete(ref) unless icons.keys.include?(ref)
158
160
  end
159
161
 
160
162
  File.open(reference_file, "wb") do |f|
161
- f.write reference.to_yaml
163
+ f.write "# Auto-updated. Nothing to touch.\n"
164
+ for name, code in reference
165
+ f.write "'#{name}': '#{code}'\n"
166
+ end
162
167
  end
163
168
 
169
+ # Build glyphs
170
+ config["glyphs"] = icons.sort{|a,b| a[1] <=> b[1]}.collect do |name, unicode|
171
+ {"css" => name, "code" => unicode.to_i(16)}
172
+ end
173
+
164
174
  File.open(config_file, "wb") do |f|
165
175
  f.write config.to_yaml
166
176
  end
data/lib/agric/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Agric
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
Binary file