All Projects → sbagdat → Turkish_support

sbagdat / Turkish_support

Licence: mit
Turkish character support for core ruby methods.

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Turkish support

Codetriage
Discover the best way to get started contributing to Open Source projects
Stars: ✭ 1,185 (+1345.12%)
Mutual labels:  rails
Realtime Rails
Realtime rails support. See website for documentation:
Stars: ✭ 77 (-6.1%)
Mutual labels:  rails
Vue Rails Form Builder
A custom Rails form builder for Vue.js
Stars: ✭ 81 (-1.22%)
Mutual labels:  rails
Hotwire Chat
Hotwire Chat is a demo Ruby on Rails web application built with Hotwire.
Stars: ✭ 73 (-10.98%)
Mutual labels:  rails
Rails emoji
Emoji for Ruby on Rails
Stars: ✭ 76 (-7.32%)
Mutual labels:  rails
Formadmin
Modern and responsive theme for Active Admin used by Formaweb.
Stars: ✭ 79 (-3.66%)
Mutual labels:  rails
System tester
A Development Tool for creating and managing system tests for Ruby on Rails >= 5.1 Applications
Stars: ✭ 73 (-10.98%)
Mutual labels:  rails
Classroom
GitHub Classroom automates repository creation and access control, making it easy for teachers to distribute starter code and collect assignments on GitHub.
Stars: ✭ 1,243 (+1415.85%)
Mutual labels:  rails
Tabler Rubygem
Rubygem for https://tabler.github.io
Stars: ✭ 77 (-6.1%)
Mutual labels:  rails
Rails Webpacker
Rails on webpack and yarn with new webpacker gem. Multiple examples using react, vue and angular
Stars: ✭ 80 (-2.44%)
Mutual labels:  rails
Activeadmin quill editor
Quill Rich Text Editor for ActiveAdmin
Stars: ✭ 76 (-7.32%)
Mutual labels:  rails
Route downcaser
Makes routing in Rails case-insensitive
Stars: ✭ 76 (-7.32%)
Mutual labels:  rails
Rails Apz
The guide to build a Rails app from a to z.
Stars: ✭ 79 (-3.66%)
Mutual labels:  rails
Test Prof
Ruby Tests Profiling Toolbox
Stars: ✭ 1,193 (+1354.88%)
Mutual labels:  rails
Npm Rails
NPM support for Rails with Bundler-like DSL
Stars: ✭ 81 (-1.22%)
Mutual labels:  rails
Active enumerable
ActiveRecord like query methods for Ruby enumerable collections.
Stars: ✭ 73 (-10.98%)
Mutual labels:  rails
Vglist
A video game library tracking web app built in Rails and powered by Wikidata.
Stars: ✭ 78 (-4.88%)
Mutual labels:  rails
Rails docker template
Docker template for Rails app or Rails + Webpacker app development.
Stars: ✭ 82 (+0%)
Mutual labels:  rails
Bhf
Rails-Engine-Gem that offers an admin interface for trusted user
Stars: ✭ 81 (-1.22%)
Mutual labels:  rails
Karafka
Framework for Apache Kafka based Ruby and Rails applications development.
Stars: ✭ 1,223 (+1391.46%)
Mutual labels:  rails

TurkishSupport

Gem Version Build Status Code Climate Coverage Status

Turkish character support for core ruby methods. This gem provides support nearly all String methods, such as String#split, String#match, String#gsub. It also provides support for Array#sortand some bonus methods like String#titleize.

Requirements

Installation

Add this line to your application's Gemfile:

gem 'turkish_support'

And then execute:

$ bundle

Or install it yourself as:

$ gem install turkish_support

Usage

After the installation of the gem, you should follow these steps.

Using with ruby

  • Require the gem:
  require 'turkish_support'
  • Add using TurkishSupport line to a class or a module.

Example usage inside a class:

require 'turkish_support'

class CanSpeakInTurkish
  using TurkishSupport

  def split_me_up(string, sep)
    string.split(sep)
  end
end

CanSpeakInTurkish.new.split_me_up('çar çarı çarşı', 'ç')
# ['ar', 'arı', 'arşı']

Using with ruby on rails

Note: You don't need to require, because it is already required by the rails.

  • You must add using TurkishSupport line to the top of the scope.
  using TurkishSupport

  class TopModel < ApplicationRecord
    # your code goes here
  end
  • If you want to use TurkishSupport with a custom class or a module that is not inherited from any rails tie, you must add using TurkishSupport line to the class or module.
  class CustomClass
    using TurkishSupport

    # your code goes here
  end

String Methods

<=> (spaceship)

  'Cahit' <=> 'Çağla' # => -1
  'Sıtkı' <=> 'Ömer'  # =>  1
  'Eren'  <=> 'Eren'  # =>  0
  'c'     <=> 'ca'    # => -1

<, <=, >, >= (comparisons)

  'd'   >  'ç'     # => true
  'aha' >= 'ağa'   # => true
  'd'   <  'ç'     # => false
  'ağa' <= 'aha'   # => true

[] and []=

  'Türkiye Cumhuriyeti'[/\w+/] # => "Türkiye"
  'Çetin'[/[a-ğ]+/i]           # => "Çe"

capitalize and capitalize!

  str = 'türkÇE desteĞİ'

  str.capitalize    # => "Türkçe desteği"
  str.capitalize!   # => "Türkçe desteği"

casecmp

  'sıtKI'.casecmp('SITkı')     # => 0

downcase and downcase!

  str = 'İSMAİL'

  str.downcase    # => "ismail"
  str.downcase!   # => "ismail"

gsub and gsub!

  'ağa paşa ağa'.gsub(/\b[a-h]+\b/, 'bey') # => "bey paşa bey"

index

  '?ç-!+*/-ğüı'.index(/\w+/)        # => 1
  '?ç-!+*/-ğüı'.index(/[a-z]+/, 2)  # => 8

match

  'Aşağı'.match(/\w+/)
  # => #<MatchData "Aşağı">

  'Aşağı Ayrancı'.match(/^\w+\s\w+$/)
  # => #<MatchData "Aşağı Ayrancı">

  'aüvvağğ öövvaağ'.match(/^[a-z]+\s[a-z]+$/)
  # => #<MatchData "aüvvağğ öövvaağ">

  'BAĞCIlar'.match(/[A-Z]+/)
  # => #<MatchData "BAĞCI">

  'Aşağı Ayrancı'.match(/\W+/)
  # => #<MatchData "">

partition

  'Bağlarbaşı Çarşı'.partition(/\W+/) # => ["Bağlarbaşı", " ", "Çarşı"]

rpartition

  'Bağlarbaşı Çarşı Kalabalık'.rpartition(/\W+/)
  # => ["Bağlarbaşı Çarşı", " ", "Kalabalık"]

rindex

  'şç-!+*/-ğüı'.rindex(/\w+/, 7)  # => 1

scan

  'Bağlarbaşı Çarşı Kalabalık'.scan(/[a-z]+/i)
  # => ["Bağlarbaşı", "Çarşı", "Kalabalık"]

slice and slice!

  'Duayen'.slice(/[^h-ö]+/) # => "Duaye"

split

  'Bağlarbaşı Çarşı Kalabalık'.split(/\W+/)
  # => ["Bağlarbaşı", "Çarşı", "Kalabalık"]

  'Bağlarbaşı Çarşı Kalabalık'.split(/[ç-ş]+/)
  # => ["Ba", "a", "ba", " Ça", " Ka", "aba"]

sub and sub!

  'ağapaşaağa'.sub(/[a-h]+/, 'bey')  # => "beypaşaağa"

swapcase and swapcase!

  'TuğÇE'.swapcase    # => "tUĞçe"
  'TuğÇE'.swapcase!   # => "tUĞçe"

titleize and titleize!

These methods are not core methods of ruby, but they are accepted as useful in most situations.

  'türkÇE desteĞİ'.titleize           # => "Türkçe Desteği"
  'türkÇE desteĞİ'.titleize!          # => "Türkçe Desteği"

  # Parenthesis, quotes, etc. support
  "rUBY roCkS... (really! 'tRUSt' ME)".titleize
  # => "Ruby Rocks... (Really! 'Trust' Me)"

upcase and upcase!

  str = 'Bağcılar'

  str.upcase    # => "BAĞCILAR"
  str           # => "Bağcılar"

  str.upcase!   # => "BAĞCILAR"
  str           # => "BAĞCILAR"

Array Methods

sort and sort!

  %w(iki üç dört ılık iğne iyne).sort
  # => ["dört", "ılık", "iğne", "iki", "iyne", "üç"]

Development

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sbagdat/turkish_support. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the TurkishSupport project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].