cloudfoundry/bosh · instance.rb
ruby logo
def spec
      return nil if spec_json.nil?

      begin
        result = JSON.parse(spec_json)
      rescue JSON::ParserError
        return 'error'
      end

      result
    end
Similar code snippets
1.
cloudfoundry/bosh · variables_parser.rb
Match rating: 54.45% · See similar code snippets
ruby logo
def parse(spec)
      validate(spec) if spec
      parse_links(spec)
      Variables.new(spec)
    end
2.
Match rating: 53.17% · See similar code snippets
ruby logo
def spec_as_json
      json = {
        :name => spec.name,
        :version => spec.version,
        :manifest_version => calculate_manifest_version
      }

      json[:description] = spec.description if spec.description
      json[:icons] = spec.icons
      json[:default_locale] = spec.default_locale if spec.default_locale
      json[:browser_action] = action_as_json(spec.browser_action) if spec.browser_action
      json[:page_action] = action_as_json(spec.page_action) if spec.page_action
      json[:app] = packaged_app_as_json if spec.packaged_app
      if spec.background_page
        json[:background] = { :page => spec.background_page }
      end
      unless spec.background_scripts.empty?
        json[:background] = { :scripts => spec.background_scripts }
      end
      json[:chrome_url_overrides] = spec.overriden_pages unless spec.overriden_pages.empty?
      json[:content_scripts] = content_scripts_as_json unless spec.content_scripts.empty?
      json[:content_security_policy] = spec.content_security_policy if spec.content_security_policy
      json[:homepage_url] = spec.homepage if spec.homepage
      json[:incognito] = spec.incognito_mode if spec.incognito_mode
      json[:intents] = web_intents_as_json unless spec.web_intents.empty?
      json[:minimum_chrome_version] = spec.minimum_chrome_version if spec.minimum_chrome_version
      json[:nacl_modules] = nacl_modules_as_json unless spec.nacl_modules.empty?
      json[:offline_enabled] = spec.offline_enabled unless spec.offline_enabled.nil?
      json[:omnibox] = spec.omnibox_keyword if spec.omnibox_keyword
      json[:options_page] = spec.options_page if spec.options_page
      json[:permissions] = spec.permissions unless spec.permissions.empty?
      json[:requirements] = requirements_as_json if has_requirements?
      json[:update_url] = spec.update_url if spec.update_url
      json[:web_accessible_resources] = spec.web_accessible_resources unless spec.web_accessible_resources.empty?

      json
    end
3.
zverok/saharspec · be_json.rb
Match rating: 52.39% · See similar code snippets
ruby logo
def be_json(expected = Saharspec::Matchers::BeJson::NONE)
      Saharspec::Matchers::BeJson.new(expected)
    end
4.
waterlink/rack-reverse-proxy · rule.rb
Match rating: 51.0% · See similar code snippets
ruby logo
def build_matcher(spec)
      return /^#{spec}/ if spec.is_a?(String)
      return spec if spec.respond_to?(:match)
      return spec if spec.respond_to?(:call)
      raise ArgumentError, "Invalid Rule for reverse_proxy"
    end
5.
blackwinter/athena · xml.rb
Match rating: 50.57% · See similar code snippets
ruby logo
def merge_specs(container, key, spec)
      container.insert!(key => spec) { |_, spec1, spec2|
        if spec1.respond_to?(:specs!)
          spec1.specs!(spec2.respond_to?(:specs) ? spec2.specs : spec2)
          spec1
        else
          spec1.merge(spec2)
        end
      }
    end
6.
blackwinter/athena · xml.rb
Match rating: 50.25% · See similar code snippets
ruby logo
def define_spec(element, field, config, arg)
      spec = ElementSpec.new(element, field, config)
      arg.is_a?(Hash) ? spec.specs!(arg) : spec.default!(SubElementSpec.new(spec))
      spec
    end
7.
geminabox/geminabox · incoming_gem.rb
Match rating: 49.93% · See similar code snippets
ruby logo
def valid?
      spec && spec.name && spec.version
    rescue Gem::Package::Error
      false
    end
8.
bundler/gemstash · gem_pusher.rb
Match rating: 49.68% · See similar code snippets
ruby logo
def store_gemspec
      spec = gem.spec
      spec = Marshal.dump(spec)
      spec = Zlib::Deflate.deflate(spec)
      storage.resource(full_name).save(spec: spec)
    end
9.
copiousfreetime/stickler · local.rb
Match rating: 48.81% · See similar code snippets
ruby logo
def speclite_from_specification( spec )
      Stickler::SpecLite.new( spec.name, spec.version.to_s, spec.platform )
    end
10.
bitjourney/ts_routes-rails · generator.rb
Match rating: 48.5% · See similar code snippets
ruby logo
def serialize(route, spec, parent_route)
      return nil unless spec
      return spec.tr(':', '').to_json if spec.is_a?(String)

      expr = serialize_spec(route, spec)
      if parent_route
        "#{serialize_spec(parent_route, parent_route.path.spec, nil)} + #{expr}"
      else
        expr
      end
    end