Module: CitySDK
- Defined in:
- lib/citysdk.rb,
lib/citysdk/api.rb,
lib/citysdk/util.rb,
lib/citysdk/importer.rb,
lib/citysdk/file_reader.rb
Defined Under Namespace
Classes: API, Exception, FileReader, HostException, Importer
Constant Summary collapse
- VERSION =
'1.1.0'
Class Method Summary collapse
Instance Method Summary collapse
-
#jsonlog(o) ⇒ Object
for debugging purposes…
Class Method Details
.make_cdk_id(layer, text) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/citysdk/util.rb', line 28 def self.make_cdk_id(layer, text) # Normalize text: # downcase, strip, # normalize (é = e, ü = u), # remove ', ", `, # replace sequences of non-word characters by '.', # Remove leading and trailing '.' n = text.to_s.downcase.strip .gsub(/['"`]/, '') .gsub(/\W+/, '.') .gsub(/((\.$)|(^\.))/, '') "#{layer}.#{::I18n.transliterate(n)}" end |
.parse_json(str) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/citysdk/util.rb', line 62 def self.parse_json(str) begin return str.blank? ? {} : JSON.parse(str, symbolize_names: true) rescue Exception => e raise CitySDK::Exception.new("#{e.message}; input: #{str}") end end |
Instance Method Details
#jsonlog(o) ⇒ Object
for debugging purposes…
45 46 47 |
# File 'lib/citysdk/util.rb', line 45 def jsonlog(o) puts JSON.pretty_generate({ o.class.to_s => o }) end |