Sha256: a1ba9ec0dfcd1ca93415c87e5ef34a10e4dab296598dafc2f479541c2a87470d

Contents?: true

Size: 862 Bytes

Versions: 4

Compression:

Stored size: 862 Bytes

Contents

require 'pathname'

module SlackResources
  module Resources
    module EventApi
      BASE_PATH = Pathname(__dir__).join('event_api')

      SUMMARY_PATH = BASE_PATH.join('summary.json')
      DETAILS_PATH = BASE_PATH.join('details')
      EXAMPLES_PATH = BASE_PATH.join('examples')
      SCHEMAS_PATH = BASE_PATH.join('schemas')

      class << self
        def details(name)
          File.read(DETAILS_PATH.join("#{name}.json"))
        end

        def example(name)
          File.read(EXAMPLES_PATH.join("#{name}.json"))
        end

        def schemas(name)
          File.read(SCHEMAS_PATH.join("#{name}.json"))
        end

        def event_types
          summary_file.map { |h| h['event'] }
        end

        private

        def summary_file
          @summary_file = JSON.parse(File.read(SUMMARY_PATH))
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
slack_resources-0.1.6 lib/slack_resources/resources/event_api.rb
slack_resources-0.1.5 lib/slack_resources/resources/event_api.rb
slack_resources-0.1.4 lib/slack_resources/resources/event_api.rb
slack_resources-0.0.0 lib/slack_resources/resources/event_api.rb