Sha256: 92859c8d6462b568848942673ca2636f6dff76ecebe8a3946b8240c8be2b159d

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class Type
# Set: All "Json" cards
#
# include_set Abstract::Pointer
module Json;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card-mod-format/set/type/json.rb"; end

event :validate_json, :validate, on: :save, changed: :content do
  check_json_syntax if content.present?
end

def check_json_syntax
  parse_content
rescue JSON::ParserError => e
  errors.add t(:format_invalid_json), e.message.sub(/^\d+: /, "").to_s
end

def parse_content
  JSON.parse content
end

def item_names _args={}
  parse_content.keys.map(&:to_name)
end

def item_values
  parse_content.values
end

def item_value name
  parse_content[name]
end

module HtmlFormat; module_parent.send :register_set_format, Card::Format::HtmlFormat, self; extend Card::Set::AbstractFormat
  view :core do
    process_content ::CodeRay.scan(_render_raw, :json).div
  end

  def input_type
    :ace_editor
  end

  def ace_mode
    :json
  end
end
end;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card-mod-format/set/type/json.rb ~~

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
card-1.101.7 tmpsets/set/mod007-card-mod-format/type/json.rb
card-1.101.6 tmpsets/set/mod007-card-mod-format/type/json.rb