blue_steel 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5380af4e3107116fccabf7cdf28f97e6e579f8bf
4
+ data.tar.gz: 7246764080dc351c0f0a0ca840a8e74ce7705d90
5
+ SHA512:
6
+ metadata.gz: bca8b7184a076d00d9411d9125c1a5f13089f8cc5124f5d78a3f752b2a494c6ec8500a5d9e56e5c9c4620e45fab196ad1d5116c2003ba5d60b6d1c76251ee619
7
+ data.tar.gz: 711a4abcb66fcba2901bdc5e8e2f4683f7a4a442809bce0ef423c86253d262740a6bb679f2eda6e6a7b5d432c0091dc7dbd2d36327d79f32f065a6c10867ac5c
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Coding In Style
2
+
3
+ We all recognize that style matters, and particularly that having _a_ consistent
4
+ style matters more than _my_ or _your_ particular preference for a style (See
5
+ Sandi Metz's _Looks Matter_). This repository contains the Apartment List style.
6
+
7
+ # Installation
8
+
9
+ See each directory for installation in that language:
10
+ - [Ruby](/ruby)
11
+
12
+ # Changing Style
13
+
14
+ Thrash is anathema to consistency, so we are making it very difficult to change
15
+ styles. Consider it a Constitution. We all agreed on it hundreds of years ago,
16
+ and though everyone has some gripes with it, it's pretty good and we're leaving
17
+ it alone.
18
+
19
+ Since we're intentionally making it difficult to change, I'm only going to give
20
+ you one criterion to consider when you want to propose a change:
21
+
22
+ 1. The style is probably not going to change, and that's ok!
data/ruby/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Installation
2
+
3
+ 1. Add these gems to your `Gemfile`, most likely just in the `development`
4
+ group:
5
+
6
+ - [`rubocop`](https://github.com/bbatsov/rubocop) - The base rules, more or
7
+ less agreed upon by the Ruby community.
8
+ - [`rubocop-rspec`](https://github.com/backus/rubocop-rspec) - More
9
+ customized rules for the `spec/` directory, where RSpec's DSL is more
10
+ valuable than "normal" Ruby style.
11
+ - [`rubocop-git`](https://github.com/m4i/rubocop-git) - This lets you run
12
+ style checks on just your changes, so you're not responsible for a whole
13
+ history of accumulated style mishaps.
14
+
15
+ 2. Copy the minimal Rubocop configuration to your repository:
16
+
17
+ ```
18
+ cp style/ruby/sample.yml my_app/.rubocop.yml
19
+ ```
20
+
21
+ This file does little more than inherit from `global.yml`, which allows us
22
+ to configure and change global style in a single place.
23
+
24
+ 3. Add this pattern to your repo's `.gitignore`:
25
+
26
+ ```
27
+ .rubocop-http*yml
28
+ ```
29
+
30
+ When Rubocop inherits from a URL, it downloads and caches the file locally
31
+ so you don't have to hit the network every time. There's no need for that
32
+ cache to be committed to the repository or clutter `git status`.
33
+
34
+ 4. Install the Rake tasks:
35
+
36
+ ```
37
+ cp style/ruby/lib/tasks/style.rake my_app/lib/tasks/
38
+ ```
39
+
40
+ This provides you three Rake tasks:
41
+ - `style:branch` - Runs style checks only on your diff from `master`
42
+ - `style:all` - Runs all style checks
43
+ - `style:count` - Prints counts of all style violations
44
+
45
+ 5. Set your `Rakefile` default to include style checks:
46
+
47
+ ```
48
+ task default: %i[spec style:branch]
49
+ ```
50
+
51
+ Style checks will only run if specs passed, so you don't have to worry about
52
+ pretty code until you have working code.
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1 @@
1
+ inherit_from: global.yml
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in blue_steel.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Cameron Irmas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # BlueSteel
2
+
3
+ We all recognize that style matters, and particularly that having _a_ consistent
4
+ style matters more than _my_ or _your_ particular preference for a style (See
5
+ Sandi Metz's _Looks Matter_). This repository contains the Apartment List style.
6
+
7
+ ### Changing Style
8
+
9
+ Thrash is anathema to consistency, so we are making it very difficult to change
10
+ styles. Consider it a Constitution. We all agreed on it hundreds of years ago,
11
+ and though everyone has some gripes with it, it's pretty good and we're leaving
12
+ it alone.
13
+
14
+ Since we're intentionally making it difficult to change, I'm only going to give
15
+ you one criterion to consider when you want to propose a change:
16
+
17
+ 1. The style is probably not going to change, and that's ok!
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'blue_steel'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install blue_steel
34
+
35
+ ## Usage
36
+
37
+ TODO: Write usage instructions here
38
+
39
+ ## Development
40
+
41
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
+
43
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/blue_steel.
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ load 'lib/tasks/style.rake'
3
+ task default: %i[style:branch]
4
+
5
+ task :environment do
6
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "blue_steel"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "blue_steel/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "blue_steel"
8
+ spec.version = BlueSteel::VERSION
9
+ spec.authors = ["Cameron Irmas"]
10
+ spec.email = ["cirmas@apartmentlist.com"]
11
+
12
+ spec.summary = %q{Apartment List's internal coding style guide}
13
+ spec.homepage = "https://github.com/apartmentlist/style/tree/master/ruby/blue_steel"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "rubocop-git", "~> 0.1"
24
+ spec.add_dependency "rubocop-rspec", "~> 1.15"
25
+ spec.add_dependency "rubocop", "~> 0.36"
26
+ spec.add_development_dependency "bundler", "~> 1.15"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
@@ -0,0 +1,81 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ # Ruby files that are otherwise missed, since default is just *.rb
5
+ Include:
6
+ - config.ru
7
+ - Gemfile
8
+ - Rakefile
9
+ # Files that aren't helpful to check, even if they're Ruby
10
+ Exclude:
11
+ - 'db/schema.rb'
12
+ - 'node_modules/**/*'
13
+
14
+ CollectionMethods:
15
+ PreferredMethods:
16
+ collect: map
17
+ inject: reduce
18
+ # Avoid confusion with ActiveRecord methods
19
+ find_all: select
20
+ find: detect
21
+
22
+ FileName:
23
+ Exclude:
24
+ - Guardfile # Like Rakefile
25
+
26
+ # Default is 79, a whole 1.25% reduction in usable space!
27
+ LineLength:
28
+ Max: 80
29
+
30
+ # RSpec's DSL leads to long blocks, and that's ok
31
+ Metrics/BlockLength:
32
+ ExcludedMethods: ['context', 'describe', 'shared_examples']
33
+
34
+ # Don't require underscores in long numbers, eg. 123_456_789.
35
+ # We often have IDs, not "numbers".
36
+ NumericLiterals:
37
+ Enabled: false
38
+
39
+ # We've set RSpec to infer_spec_type_from_file_location!, but RuboCop doesn't
40
+ # have access to that config. Rather than have to tag everything `type: :view`,
41
+ # just ignore the cop for those specs.
42
+ RSpec/DescribeClass:
43
+ Exclude:
44
+ - spec/views/**/*_spec.rb
45
+
46
+ # The default is not_to, but we've historically used to_not basically 100% of
47
+ # the time. There doesn't appear to be a particular reason one is better, and
48
+ # it's not worth changing.
49
+ RSpec/NotToNot:
50
+ EnforcedStyle: to_not
51
+
52
+ # Don't force single line blocks to name their block arguments things like
53
+ # |a, e| for accumulator, element. Eg:
54
+ #
55
+ # things.reduce { |a, e| ... }
56
+ #
57
+ # We have more semantic context than Rubocop, so there's no reason it should be
58
+ # dictating our variable names.
59
+ SingleLineBlockParams:
60
+ Enabled: false
61
+
62
+ # Migrations are particularly self-explanatory, so there's very little reason to
63
+ # write class documentation for them.
64
+ Style/Documentation:
65
+ Exclude:
66
+ - db/migrate/*.rb
67
+
68
+ Style/PercentLiteralDelimiters:
69
+ PreferredDelimiters:
70
+ # Prefer [] for things that are arrays
71
+ '%i': '[]'
72
+ '%I': '[]'
73
+ '%w': '[]'
74
+ '%W': '[]'
75
+ # Prefer () otherwise
76
+ '%': '()'
77
+ '%q': '()'
78
+ '%Q': '()'
79
+ '%r': '()'
80
+ '%s': '()'
81
+ '%x': '()'
@@ -0,0 +1,9 @@
1
+ # Allows Rails to load the style tasks
2
+ module BlueSteel
3
+ # Inherits from Railtie
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load 'tasks/style.rake'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module BlueSteel
2
+ VERSION = '0.1.1'.freeze
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'blue_steel/version'
2
+ require 'blue_steel/railtie' if defined?(Rails)
3
+
4
+ # Top level module
5
+ module BlueSteel
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # No need to have Rubocop in production, so be careful loading it.
4
+ begin
5
+ require 'rubocop/git/cli'
6
+ rescue LoadError
7
+ puts <<-MSG
8
+ Warning: RuboCop::Git is not available.
9
+ Run `gem install rubocop-git` or add it to your Gemfile
10
+ MSG
11
+ end
12
+
13
+ namespace :style do
14
+ desc 'Run style checks for the entire repository'
15
+ task all: :environment do
16
+ system('rubocop --display-cop-names')
17
+ end
18
+
19
+ desc 'Run style checks on your diff from `master`'
20
+ task branch: :environment do
21
+ RuboCop::Git::CLI.new.run(%w[--display-cop-names master])
22
+ end
23
+
24
+ desc 'Print total violation counts'
25
+ task count: :environment do
26
+ puts `
27
+ rubocop --display-cop-names |
28
+ grep -oE '[CW]: [^:]+' | # Extract "C: Thing/YouBroke"
29
+ sort |
30
+ uniq -c |
31
+ sort -rn
32
+ `
33
+ end
34
+ end
data/ruby/global.yml ADDED
@@ -0,0 +1,87 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ # Ruby files that are otherwise missed, since default is just *.rb
5
+ Include:
6
+ - config.ru
7
+ - Gemfile
8
+ - Rakefile
9
+ # Files that aren't helpful to check, even if they're Ruby
10
+ Exclude:
11
+ - 'db/schema.rb'
12
+ - 'node_modules/**/*'
13
+
14
+ CollectionMethods:
15
+ PreferredMethods:
16
+ collect: map
17
+ inject: reduce
18
+ # Avoid confusion with ActiveRecord methods
19
+ find_all: select
20
+ find: detect
21
+
22
+ FileName:
23
+ Exclude:
24
+ - Guardfile # Like Rakefile
25
+
26
+ # Default is 79, a whole 1.25% reduction in usable space!
27
+ LineLength:
28
+ Max: 80
29
+
30
+ # RSpec's DSL leads to long blocks, and that's ok
31
+ Metrics/BlockLength:
32
+ ExcludedMethods: ['context', 'describe', 'shared_examples']
33
+
34
+ # Don't require underscores in long numbers, eg. 123_456_789.
35
+ # We often have IDs, not "numbers".
36
+ NumericLiterals:
37
+ Enabled: false
38
+
39
+ # We've set RSpec to infer_spec_type_from_file_location!, but RuboCop doesn't
40
+ # have access to that config. Rather than have to tag everything `type: :view`,
41
+ # just ignore the cop for those specs.
42
+ RSpec/DescribeClass:
43
+ Exclude:
44
+ - spec/views/**/*_spec.rb
45
+
46
+ # The default is not_to, but we've historically used to_not basically 100% of
47
+ # the time. There doesn't appear to be a particular reason one is better, and
48
+ # it's not worth changing.
49
+ RSpec/NotToNot:
50
+ EnforcedStyle: to_not
51
+
52
+ # Don't force single line blocks to name their block arguments things like
53
+ # |a, e| for accumulator, element. Eg:
54
+ #
55
+ # things.reduce { |a, e| ... }
56
+ #
57
+ # We have more semantic context than Rubocop, so there's no reason it should be
58
+ # dictating our variable names.
59
+ SingleLineBlockParams:
60
+ Enabled: false
61
+
62
+ # Migrations are particularly self-explanatory, so there's very little reason to
63
+ # write class documentation for them.
64
+ Style/Documentation:
65
+ Exclude:
66
+ - db/migrate/*.rb
67
+
68
+ # This requires us to parenthesize simple things like (a % 10).zero?, which
69
+ # we've never done and find cumbersome without improving clarity. The community
70
+ # doesn't appear to have a clear reason why one is superior.
71
+ Style/NumericPredicate:
72
+ Enabled: false
73
+
74
+ Style/PercentLiteralDelimiters:
75
+ PreferredDelimiters:
76
+ # Prefer [] for things that are arrays
77
+ '%i': '[]'
78
+ '%I': '[]'
79
+ '%w': '[]'
80
+ '%W': '[]'
81
+ # Prefer () otherwise
82
+ '%': '()'
83
+ '%q': '()'
84
+ '%Q': '()'
85
+ '%r': '()'
86
+ '%s': '()'
87
+ '%x': '()'
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # No need to have Rubocop in production, so be careful loading it.
4
+ begin
5
+ require 'rubocop/git/cli'
6
+ rescue LoadError
7
+ puts <<-MSG
8
+ Warning: RuboCop::Git is not available.
9
+ Run `gem install rubocop-git` or add it to your Gemfile
10
+ MSG
11
+ end
12
+
13
+ namespace :style do
14
+ desc 'Run style checks for the entire repository'
15
+ task all: :environment do
16
+ system('rubocop --display-cop-names')
17
+ end
18
+
19
+ desc 'Run style checks on your diff from `master`'
20
+ task branch: :environment do
21
+ RuboCop::Git::CLI.new.run(%w[--display-cop-names master])
22
+ end
23
+
24
+ desc 'Print total violation counts'
25
+ task count: :environment do
26
+ puts `
27
+ rubocop --display-cop-names |
28
+ grep -oE '[CW]: [^:]+' | # Extract "C: Thing/YouBroke"
29
+ sort |
30
+ uniq -c |
31
+ sort -rn
32
+ `
33
+ end
34
+ end
data/ruby/sample.yml ADDED
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/apartmentlist/style/master/ruby/global.yml
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blue_steel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Cameron Irmas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop-git
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.36'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.36'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.15'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.15'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description:
84
+ email:
85
+ - cirmas@apartmentlist.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - README.md
91
+ - ruby/README.md
92
+ - ruby/blue_steel/.gitignore
93
+ - ruby/blue_steel/.rubocop.yml
94
+ - ruby/blue_steel/Gemfile
95
+ - ruby/blue_steel/LICENSE.txt
96
+ - ruby/blue_steel/README.md
97
+ - ruby/blue_steel/Rakefile
98
+ - ruby/blue_steel/bin/console
99
+ - ruby/blue_steel/bin/setup
100
+ - ruby/blue_steel/blue_steel.gemspec
101
+ - ruby/blue_steel/global.yml
102
+ - ruby/blue_steel/lib/blue_steel.rb
103
+ - ruby/blue_steel/lib/blue_steel/railtie.rb
104
+ - ruby/blue_steel/lib/blue_steel/version.rb
105
+ - ruby/blue_steel/lib/tasks/style.rake
106
+ - ruby/global.yml
107
+ - ruby/lib/tasks/style.rake
108
+ - ruby/sample.yml
109
+ homepage: https://github.com/apartmentlist/style/tree/master/ruby/blue_steel
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.6.12
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Apartment List's internal coding style guide
133
+ test_files: []