class Artemis::InstallGenerator

Public Instance Methods

download_schema() click to toggle source
# File lib/generators/artemis/install/install_generator.rb, line 42
def download_schema
  say "      downloading GraphQL schema from #{endpoint_url}..."

  if options['authorization'].present?
    rake "graphql:schema:update SERVICE=#{file_name} AUTHORIZATION='#{options['authorization']}'"
  else
    rake "graphql:schema:update SERVICE=#{file_name}"
  end
end
generate_client() click to toggle source
# File lib/generators/artemis/install/install_generator.rb, line 11
def generate_client
  template "client.rb", client_file_name
  create_file query_dir_gitkeep, ""
end
generate_config() click to toggle source
# File lib/generators/artemis/install/install_generator.rb, line 16
  def generate_config
    in_root do
      if behavior == :invoke && !File.exist?(config_file_name)
        template "graphql.yml", config_file_name
      else
        inject_into_file config_file_name, <<-YAML, after: "development:\n"
  #{file_name}:
    <<: *default
    url: #{endpoint_url}\n
YAML

        inject_into_file config_file_name, <<-YAML, after: "test:\n", force: true
  #{file_name}:
    <<: *default
    url: #{endpoint_url}\n
YAML

        inject_into_file config_file_name, <<-YAML, after: "production:\n", force: true
  #{file_name}:
    <<: *default
    url: #{endpoint_url}\n
YAML
      end
    end
  end

Private Instance Methods

client_file_name() click to toggle source
# File lib/generators/artemis/install/install_generator.rb, line 58
def client_file_name
  if respond_to?(:mountable_engine?) && mountable_engine?
    "app/operations/#{namespaced_path}/#{file_name}.rb"
  else
    "app/operations/#{file_name}.rb"
  end
end
config_file_name() click to toggle source
# File lib/generators/artemis/install/install_generator.rb, line 74
def config_file_name
  "config/graphql.yml"
end
file_name() click to toggle source
Calls superclass method
# File lib/generators/artemis/install/install_generator.rb, line 54
def file_name # :doc:
  @_file_name ||= super.underscore
end
query_dir_gitkeep() click to toggle source
# File lib/generators/artemis/install/install_generator.rb, line 66
def query_dir_gitkeep
  if respond_to?(:mountable_engine?) && mountable_engine?
    "app/operations/#{namespaced_path}/#{file_name}/.gitkeep"
  else
    "app/operations/#{file_name}/.gitkeep"
  end
end