Skip to content

Commit 72fa870

Browse files
committed
nib meet RuboCop and CodeClimate test coverage
1 parent 98fbaa7 commit 72fa870

21 files changed

+264
-163
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
codeship.aes
2+
codeship.env
13
keys/*
24
tmp/*
35
.DS_Store

.rubocop.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
AllCops:
2+
TargetRubyVersion: 2.3
3+
Exclude:
4+
- vendor/**
5+
- bin/**
6+
- config/environments/**
7+
- spec/dummy/**/*
8+
9+
Documentation:
10+
# don't require classes to be documented
11+
Enabled: false
12+
13+
Encoding:
14+
# no need to always specify encoding
15+
Enabled: false
16+
17+
Style/FrozenStringLiteralComment:
18+
# love the idea of frozen string literal, hate the idea of using a comment
19+
# in each file to enable/check for it
20+
Enabled: false
21+
22+
AlignParameters:
23+
# allow for multi-line methods to have normal indentation.
24+
# for example:
25+
#
26+
# Person.where(
27+
# first_name: 'tom',
28+
# last_name: 'foolery'
29+
# )
30+
EnforcedStyle: with_fixed_indentation
31+
32+
Style/AlignParameters:
33+
# allow for end of if to be aligned with a variable.
34+
# for example:
35+
#
36+
# foo = if a == b
37+
# 'bar'
38+
# else
39+
# 'baz'
40+
# end
41+
EnforcedStyle: with_fixed_indentation
42+
43+
Lint/EndAlignment:
44+
AlignWith: variable
45+
46+
ClassAndModuleChildren:
47+
# ok to use compact style when modules are predefined.
48+
# for example the following is fine so long as we're sure that
49+
# module MDB has already been required/defined.
50+
#
51+
# class MDB::Person; end
52+
Enabled: false

Guardfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ guard :rspec, cmd: 'rspec', spec_paths: %w(spec/unit) do
1313
ruby = dsl.ruby
1414
dsl.watch_spec_files_for(ruby.lib_files)
1515
end
16+
17+
guard :rubocop do
18+
watch(/.+\.rb$/)
19+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
20+
end

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ begin
2020

2121
task spec: %w(rspec:unit rspec:integration)
2222
task default: %i(spec)
23-
rescue LoadError
23+
rescue LoadError # rubocop:disable Lint/HandleExceptions
2424
# no rspec available
2525
end

codeship-services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ app:
44
dockerfile: Dockerfile.test
55
volumes:
66
- /var/run/docker.sock:/var/run/docker.sock
7-
7+
encrypted_env_file: codeship.env.encrypted

codeship-steps.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
- type: parallel
22
steps:
3+
- name: rubocop
4+
service: app
5+
command: rubocop -D
36
- name: unit specs
47
service: app
58
command: rake rspec:unit

codeship.env.encrypted

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
eH4zQ1ETS3/AobV/naHtIQvbKRsAEtdlEtLENJxFjJcYEs5qhcf+VKfg0RdcFk3k9JMc73wHYTfmGAisGEYIaL4ZyN1aHdCXSL6RiBjsNgxsJ72I/oq4BGe1V6+m2jOYI845UNF/u70=
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '2'
2+
3+
services:
4+
codeclimate:
5+
image: codeclimate/codeclimate
6+
environment:
7+
- CODECLIMATE_CODE=$PWD
8+
volumes:
9+
- $PWD:/code
10+
- $PWD:$PWD
11+
- /var/run/docker.sock:/var/run/docker.sock
12+
- /tmp/cc:/tmp/cc

config/options.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
- :names:
3+
- :d
4+
:type: :switch
5+
:commands:
6+
- :exec
7+
- :run
8+
:options:
9+
:negatable: false
10+
:desc: 'Detached mode: Run container in the background, print new container name.'
11+
- :names:
12+
- :no-deps
13+
:type: :switch
14+
:commands:
15+
- :run
16+
:options:
17+
:negatable: false
18+
:desc: Don't start linked services.
19+
- :names:
20+
- :service-ports
21+
:type: :switch
22+
:commands:
23+
- :run
24+
:options:
25+
:negatable: false
26+
:desc: Run command with the service's ports enabled and mapped to the host
27+
- :names:
28+
- :privileged
29+
:type: :switch
30+
:commands:
31+
- :exec
32+
:options:
33+
:negatable: false
34+
:desc: Give extended privileges to the process.
35+
- :names:
36+
- :T
37+
:type: :switch
38+
:commands:
39+
- :exec
40+
- :run
41+
:options:
42+
:negatable: false
43+
:desc: Disable pseudo-tty allocation. By default `docker-compose run` allocates
44+
a TTY.
45+
- :names:
46+
- :name
47+
:type: :flag
48+
:commands:
49+
- :run
50+
:options:
51+
:arg_name: NAME
52+
:desc: Assign a name to the container
53+
:multiple: false
54+
:type: &1 !ruby/class 'String'
55+
- :names:
56+
- :entrypoint
57+
:type: :flag
58+
:commands:
59+
- :run
60+
:options:
61+
:arg_name: CMD
62+
:desc: Override the entrypoint of the image.
63+
:multiple: false
64+
:type: *1
65+
- :names:
66+
- :e
67+
:type: :flag
68+
:commands:
69+
- :run
70+
:options:
71+
:arg_name: KEY=VAL
72+
:desc: Set an environment variable
73+
:multiple: true
74+
:type: *1
75+
- :names:
76+
- :u
77+
- :user
78+
:type: :flag
79+
:commands:
80+
- :exec
81+
- :run
82+
:options:
83+
:arg_name: '""'
84+
:desc: Run as specified username or uid
85+
:multiple: false
86+
:type: *1
87+
- :names:
88+
- :p
89+
- :publish
90+
:type: :flag
91+
:commands:
92+
- :run
93+
:options:
94+
:arg_name: "[]"
95+
:desc: Publish a container's port(s) to the host
96+
:multiple: false
97+
:type: !ruby/class 'Array'
98+
- :names:
99+
- :workdir
100+
:type: :flag
101+
:commands:
102+
- :run
103+
:options:
104+
:arg_name: '""'
105+
:desc: Working directory inside the container
106+
:multiple: false
107+
:type: *1
108+
- :names:
109+
- :index
110+
:type: :flag
111+
:commands:
112+
- :exec
113+
:options:
114+
:arg_name: index
115+
:desc: 'index of the container if there are multiple instances of a service [default:
116+
1]'
117+
:multiple: false
118+
:type: *1

lib/nib.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@
1717
require 'nib/setup'
1818
require 'nib/shell'
1919
require 'nib/update'
20+
21+
module Nib
22+
GEM_ROOT = File.expand_path('../..', __FILE__)
23+
24+
module_function
25+
26+
def load_config(command, file_name)
27+
File.read("#{GEM_ROOT}/config/commands/#{command}/#{file_name}")
28+
end
29+
end

0 commit comments

Comments
 (0)