Skip to content

Commit

Permalink
Merge pull request #17 from Le6ow5k1/master
Browse files Browse the repository at this point in the history
feature: add String#mb_downcase method
  • Loading branch information
Le6ow5k1 authored Nov 9, 2016
2 parents c6c1931 + 90bf503 commit 51c861e
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
matrix:
include:
- DOCKER_RUBY_VERSION: 2.2
RUBY_IMAGE_TAG: 2.2-1

- DOCKER_RUBY_VERSION: 1.9.3
RUBY_IMAGE_TAG: 1.9.3-2

build:
image: abakpress/dind:2
privileged: true
volumes:
- /home/data/drone/images:/images
- /home/data/drone/gems:/bundle
- /home/data/drone/key_cache:/ssh_keys
environment:
- COMPOSE_FILE_EXT=drone
commands:
- wrapdocker docker -v

- if [ ! -e /images/ssh-agent.tar ]; then docker pull whilp/ssh-agent; docker save whilp/ssh-agent > /images/ssh-agent.tar; fi
- if [ ! -e /images/ruby_$RUBY_IMAGE_TAG.tar ]; then docker pull abakpress/ruby:$RUBY_IMAGE_TAG; docker save abakpress/ruby:$RUBY_IMAGE_TAG > /images/ruby_$RUBY_IMAGE_TAG.tar; fi

- docker load -i /images/ssh-agent.tar
- docker load -i /images/ruby_$RUBY_IMAGE_TAG.tar

- dip ssh add -T -v /ssh_keys -k /ssh_keys/id_rsa
- dip provision
- dip rspec
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in string_tools.gemspec
gemspec

if RUBY_VERSION < '2'
gem 'activerecord', '< 5.0'
gem 'actionpack', '< 5.0'
gem 'activesupport', '< 5.0'
gem 'pry-debugger'
else
gem 'pry-byebug'
end
41 changes: 41 additions & 0 deletions dip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '1'

environment:
DOCKER_RUBY_VERSION: 1.9.3
RUBY_IMAGE_TAG: 1.9.3-2
COMPOSE_FILE_EXT: development
RAILS_ENV: test

compose:
files:
- docker-compose.yml
- docker-compose.${COMPOSE_FILE_EXT}.yml

interaction:
sh:
service: app

irb:
service: app
command: irb

bundle:
service: app
command: bundle

appraisal:
service: app
command: bundle exec appraisal

rspec:
service: app
command: bundle exec appraisal bundle exec rspec

clean:
service: app
command: rm -f Gemfile.lock gemfiles/*.gemfile.*

provision:
- docker volume create --name bundler_data
- dip bundle install
- dip appraisal install
18 changes: 18 additions & 0 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '2'

services:
app:
volumes:
- .:/app
- ../:/localgems
- ssh-data:/ssh:ro
- bundler-data:/bundle

volumes:
bundler-data:
external:
name: bundler_data

ssh-data:
external:
name: ssh_data
13 changes: 13 additions & 0 deletions docker-compose.drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '2'

services:
app:
volumes:
- .:/app
- /bundle:/bundle
- ssh-data:/ssh:ro

volumes:
ssh-data:
external:
name: ssh_data
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '2'

services:
app:
image: abakpress/ruby:$RUBY_IMAGE_TAG
environment:
- SSH_AUTH_SOCK=/ssh/auth/sock
- BUNDLE_PATH=/bundle/$DOCKER_RUBY_VERSION
command: bash
11 changes: 11 additions & 0 deletions lib/string_tools/core_ext/string.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# coding: utf-8

require 'rchardet19'
require 'addressable/uri'
require 'active_support/core_ext/module'
Expand Down Expand Up @@ -192,6 +194,15 @@ def to_cp1251!
self.replace(self.to_cp1251)
end

def mb_downcase
# https://github.com/rails/rails/commit/393e19e508a08ede0f5037bccb984e3eb252d579
if ActiveSupport::VERSION::STRING >= '4.0.0' && ActiveSupport::VERSION::STRING <= '4.2.0'
ActiveSupport::Multibyte::Unicode.send(:database).codepoints
end

mb_chars.downcase.to_s
end

private

def surround_with_ansi(ascii_seq)
Expand Down
9 changes: 9 additions & 0 deletions spec/string_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# coding: utf-8

require 'spec_helper'

describe String do
describe '#mb_downcase' do
it { expect("Кириллица".mb_downcase).to eq("кириллица") }
end
end
1 change: 0 additions & 1 deletion string_tools.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'appraisal', '>= 1.0.2'
spec.add_development_dependency 'combustion', '>= 0.5.3'
spec.add_development_dependency 'simplecov', '>= 0.9'
spec.add_development_dependency 'pry-debugger'
end

0 comments on commit 51c861e

Please sign in to comment.