Skip to content

Commit

Permalink
chore: update infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Galkin committed Apr 27, 2017
1 parent 5ad69e0 commit a4f458c
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 21 deletions.
25 changes: 25 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
build:
test:
image: abakpress/dind-testing
pull: true
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
- POSTGRES_IMAGE_TAG=9.3-latest
- SPHINX_IMAGE_TAG=2.2-latest
commands:
- wrapdocker docker -v

- fetch-images
--image whilp/ssh-agent
--image abakpress/ruby-app:$RUBY_IMAGE_TAG
--image abakpress/postgres-db:$POSTGRES_IMAGE_TAG
--image abakpress/sphinx-index:$SPHINX_IMAGE_TAG

- dip ssh add -T -v /ssh_keys -k /ssh_keys/id_rsa
- dip provision
- dip rspec
5 changes: 5 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--color
--tty
--format progress
--order random
--backtrace
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
source 'https://rubygems.org'

gem 'json', '< 2' if RUBY_VERSION < '2'
gem 'activesupport', '< 5' if RUBY_VERSION < '2'

gemspec
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RedisCounters

[![Dolly](http://dolly.railsc.ru/badges/abak-press/redis_counters/master)](http://dolly.railsc.ru/projects/36/builds/latest/?ref=master)
[![Build Status](https://drone.railsc.ru/api/badges/abak-press/redis_counters/status.svg)](https://drone.railsc.ru/abak-press/redis_counters)
[![Code Climate](https://codeclimate.com/github/abak-press/redis_counters/badges/gpa.svg)](https://codeclimate.com/github/abak-press/redis_counters)
[![Test Coverage](https://codeclimate.com/github/abak-press/redis_counters/badges/coverage.svg)](https://codeclimate.com/github/abak-press/redis_counters/coverage)

Expand Down
43 changes: 43 additions & 0 deletions dip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: '1'

environment:
DOCKER_RUBY_VERSION: 2.2
RUBY_IMAGE_TAG: 2.2-latest
COMPOSE_FILE_EXT: development
RAILS_ENV: test
APRESS_GEMS_CREDENTIALS: ""

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

rake:
service: app
command: bundle exec rake

rspec:
service: app
command: bundle exec rspec

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

provision:
- docker volume create --name bundler_data
- dip bundle config --local https://gems.railsc.ru/ ${APRESS_GEMS_CREDENTIALS}
- dip clean
- dip bundle 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
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '2'

services:
app:
image: abakpress/ruby-app:$RUBY_IMAGE_TAG
environment:
- SSH_AUTH_SOCK=/ssh/auth/sock
- BUNDLE_PATH=/bundle/$DOCKER_RUBY_VERSION
- BUNDLE_CONFIG=/app/.bundle/config
command: bash
10 changes: 3 additions & 7 deletions lib/redis_counters/hash_counter.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# coding: utf-8
require 'redis_counters/base_counter'
require 'redis_counters/clusterize_and_partitionize'

module RedisCounters

# Счетчик на основе redis-hash, с возможностью партиционирования и кластеризации значений.

class HashCounter < BaseCounter
include ClusterizeAndPartitionize

Expand Down Expand Up @@ -38,16 +35,16 @@ def group_keys
# Protected: Возвращает данные партиции в виде массива хешей.
#
# Каждый элемент массива, представлен в виде хеша, содержащего все параметры кластеризации и
# значение счетчика в ключе :value.
# значение счетчика в ключе :value. Данные в счётчике могут эскейпиться бекслэшем: "a:b:c\\:d"
#
# cluster - Array - листовой кластер - массив параметров однозначно идентифицирующий кластер.
# partition - Array - листовая партиция - массив параметров однозначно идентифицирующий партицию.
#
# Returns Array of WithIndifferentAccess.
#
# Returns Array of HashWithIndifferentAccess.
def partition_data(cluster, partition)
keys = group_keys.dup.unshift(:value)
redis.hgetall(key(partition, cluster)).inject(Array.new) do |result, (key, value)|
# values = key.split(/(?<!\\)#{value_delimiter}/, -1).unshift(format_value(value))
values = key.split(value_delimiter, -1).unshift(format_value(value))
values.delete_at(1) unless group_keys.present?
result << Hash[keys.zip(values)].with_indifferent_access
Expand All @@ -66,5 +63,4 @@ def float_mode?
@float_mode ||= options.fetch(:float_mode, false)
end
end

end
3 changes: 1 addition & 2 deletions redis_counters.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_dependency 'activesupport', '>= 3.0'
spec.add_dependency 'activesupport', '>= 3.0', '< 5'

spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
Expand All @@ -27,5 +27,4 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'cane', '>= 2.6.0'
spec.add_development_dependency 'bundler-audit'
spec.add_development_dependency 'apress-changelogger'
end
10 changes: 2 additions & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'mock_redis'
require 'timecop'

require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start

require 'simplecov'

SimpleCov.start('test_frameworks')

require 'redis_counters'
Expand All @@ -18,7 +15,4 @@

RSpec.configure do |config|
config.backtrace_exclusion_patterns = [/lib\/rspec\/(core|expectations|matchers|mocks)/]
config.color_enabled = true
config.formatter = 'documentation'
config.order = 'random'
end
end

0 comments on commit a4f458c

Please sign in to comment.