Module: Artemis

Defined in:
lib/artemis.rb,
lib/artemis/client.rb,
lib/artemis/railtie.rb,
lib/artemis/version.rb,
lib/artemis/adapters.rb,
lib/artemis/exceptions.rb,
lib/artemis/test_helper.rb,
lib/artemis/graphql_endpoint.rb,
lib/artemis/adapters/curb_adapter.rb,
lib/artemis/adapters/test_adapter.rb,
lib/artemis/adapters/abstract_adapter.rb,
lib/artemis/adapters/net_http_adapter.rb,
lib/artemis/adapters/multi_domain_adapter.rb,
lib/artemis/adapters/net_http_persistent_adapter.rb

Defined Under Namespace

Modules: Adapters, TestHelper Classes: Client, ConfigurationError, EndpointNotFound, Error, FixtureNotFound, GraphQLEndpoint, GraphQLError, GraphQLFileNotFound, GraphQLServerError, InstallGenerator, MutationGenerator, QueryGenerator, Railtie

Constant Summary collapse

VERSION =
"0.8.0"

Class Method Summary collapse

Class Method Details

.config_for(name, app:, env: Rails.env) ⇒ Object

backported from github.com/rails/rails/blob/b9ca94ca/railties/lib/rails/application.rb#L226 TODO: Remove once dropping Rails <= 4.1 support



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/artemis.rb', line 16

def self.config_for(name, app:, env: Rails.env)
  if name.is_a?(Pathname)
    yaml = name
  else
    yaml = Pathname.new("#{app.paths["config"].existent.first}/#{name}.yml")
  end

  if yaml.exist?
    require "erb"
    (YAML.load(ERB.new(yaml.read).result) || {})[env] || {}
  else
    raise "Could not load configuration. No such file - #{yaml}"
  end
rescue Psych::SyntaxError => e
  raise "YAML syntax error occurred while parsing #{yaml}. " \
    "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
    "Error: #{e.message}"
end

.config_for_graphql(app) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/artemis.rb', line 6

def self.config_for_graphql(app)
  if app.respond_to?(:config_for)
    app.config_for(:graphql)
  else
    config_for(:graphql, app: app)
  end
end