Sha256: 5c514861d7b2dce4919a863755ff6a2c21b72951fbcb8c65f424cb11a540fe1e

Contents?: true

Size: 587 Bytes

Versions: 6

Compression:

Stored size: 587 Bytes

Contents

# Copyright 2019-present, GraphQL Foundation
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

def title(s):
  '''Capitalize the first character of s.'''
  return s[0].capitalize() + s[1:]


def camel(s):
  '''Lowercase the first character of s.'''
  return s[0].lower() + s[1:]


def snake(s):
  '''Convert from title or camelCase to snake_case.'''
  if len(s) < 2:
    return s.lower()
  out = s[0].lower()
  for c in s[1:]:
    if c.isupper():
      out += '_'
      c = c.lower()
    out += c
  return out

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-graphql-0.2.1 ext/libgraphqlparser/ast/casing.py
rails-graphql-0.2.0 ext/libgraphqlparser/ast/casing.py
rails-graphql-0.1.3 ext/libgraphqlparser/ast/casing.py
rails-graphql-0.1.2 ext/libgraphqlparser/ast/casing.py
rails-graphql-0.1.1 ext/libgraphqlparser/ast/casing.py
rails-graphql-0.1.0 ext/libgraphqlparser/ast/casing.py