Project

british

0.0
No commit activity in last 3 years
No release in over 3 years
Allows to use alternative words endings: -ise instead of -ize etc. Defines `is_an?` as an alias of the is_a? method. Provides a module to use `initialise` in your classes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 11.0
~> 0.8
~> 0.1
>= 0.9.0.rc1
~> 0.4
~> 1.5
~> 5.13
~> 13.0
~> 6.2
~> 5.5
~> 0.76
~> 1.0
~> 0.9
>= 0.9.20
 Project Readme

British

Build Status Inline docs Gem Version

forthebadge

A tiny module which is supposed to help Brits to use Ruby with more comfort.

WARNING: This gem was created just for the purpose of an experiment and fun. Use it in your code at your own risk!

"WHY?!"

Why

screen_1

screen_2

screen_3

screen_4

screen_5

Installation

gem install british

Usage

In a nutshell: if you write your own class using British English methods and attributes: just include British::Initialisable and it will be possible to use initialise in your class + other developers will be able to call American methods on your class instances (without bothering you about the aliases).

If you want to call British methods and attributes on other developer's classes, just include British there: by monkey-patching or in source code (if possible) or by calling ThirdPartyClass.include(British), and Bob's your uncle – use British methods on them.

If you are an author of a class written in American Englsih, you may want to include British into your class to allow your library/class users to call either American or British methods.

##Examples

# Create classes with `initialise` constructor
# And your own British methods and attributes
require 'british'

class BritishObject < BlackBoxObject
  # use British::Initialisable within your classes only *1 …
  include British::Initialisable

  attr_reader :colour

  # works exactly like an initialize (including `super` usage)
  def initialise(test)
    @test = test
    @colour = 'red'

    super('black', 'box', 'arguments')
  end

  def magnetise(test)
    @test
  end
end

british_object = BritishObject.new('Hello UK!')
british_object.test # => 'Hello UK!'

# Use American or British endings with any method or attribute
british_object.color     # => "red"
british_object.colour    # => "red"

british_object.magnetize # => "Hello UK!"
british_object.magnetise # => "Hello UK!"

# *1 … patch third party or all the system Objects
# (wouldn't really recommend to do the last one)
String.include(British)
'cheers!'.capitalise # => "Cheers!"

require 'active_support/inflector'
include British

'cheers!'.capitalise # => "Cheers!"
'oi_ya_bloody_wanker'.camelise # => "OiYaBloodyWanker"

# Extend an object instance to make it British
not_british = SomeClass.new # with #color method
refugee = SomeClass.new # with #color method

# Make it British
british = refugee.extend(British)

not_british.colour # undefined method `colour'
british.colour # works well

# Use is_an?/an? with classes like an Array!
[].is_an? Array # => true
[].an? Array    # => true

##Docs

RubyDoc.info

Development

yard --plugin tomdoc      # generate documentation
open doc/index.html       # open documentation in a browser

rake                      # or `rake test` — run all the tests
rake reek                 # execute reek code smells analysis

rubocop                   # execute rubocop code smells analysis

rake simplecov            # code coverage details
open coverage/index.html  # open coverage report in a browser

inch                      # run inches documentation analysis

Semantic Commit

Known Issues

  • Any stack trace of undefined method includes British method_missing and then the original error-line

References