Giter Club home page Giter Club logo

chcase's Introduction

ChCase

ChCase is a small library to convert case of a given string between camelCase, PascalCase, snake_case, kebab-case, Sentence case, and space-separated.

This is my first attempt to create a library (yet small and straightforward though).

Usage

1. Declare as a Dependency

For Flatpak Apps

If you want to use this library in a flatpaked app, simply call it as a module:

modules:
  - name: chcase
    buildsystem: meson
    sources:
      - type: git
        url: https://github.com/ryonakano/chcase.git
        tag: '2.1.0'

Then call chcase in your meson file:

executable(
    meson.project_name(),
    'src/Application.vala',
    dependencies: [
        dependency('gtk+-3.0'),
        dependency('chcase')
    ],
    install: true
)

Now you can use the library in your project.

For Other Packages (e.g. Debian Packaging)

This library is not (yet) provided as a package for any distributions, so the best way to use it to your project is to embed it as a git submodule:

git submodule add https://github.com/ryonakano/chcase subprojects/chcase

Load the embeded chcase library as a dependency in the root meson.build:

chcase_subproject = subproject('chcase')
chcase_deps = chcase_subproject.get_variable('libchcase')

Add the loaded chcase_deps in the dependencies list in meson.build that has executable method:

executable(
    meson.project_name(),
    'src/Application.vala',
    dependencies: [
        dependency('gtk+-3.0'),
        chcase_deps,
    ],
    install: true
)

Now you can use the library in your project.

2. Start Coding

Set the case for input string and result string and then perform conversion.

var converter = new ChCase.Converter.with_case (ChCase.Case.SPACE_SEPARATED, ChCase.Case.CAMEL);
string input_text = "say hello to ChCase";
string output_text = converter.convert_case (input_text);
stdout.printf ("Input: %s / Output: %s\n", input_text, output_text);
// Result
// Input: say hello to ChCase / Output: sayHelloToChCase

There is an example code prepared in this repository, so it may help you.

Building and Installation

If you mean to perform code changes and create a pull request against this project, you may want to build and install the library from source code.

You'll need the following dependencies:

  • libglib2.0-dev
  • meson (>= 0.56.0)
  • valac

Run meson setup to configure the build environment and run meson compile to build:

meson setup builddir --prefix=/usr
meson compile -C builddir

To install, use meson install:

meson install -C builddir

You can optionally build and run a demo app:

meson configure builddir -Ddemo=true
meson compile -C builddir
./builddir/examples/example

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.