rubocop_method_order 0.1.0.beta → 0.1.0.beta.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7211b5b76bc5400d2ced58be282733407e318266a1a7901337a9438c4491400a
4
- data.tar.gz: 02a3d41c3a68f824a3571dffe4ae2e8c941f160775781759f26a3b1e7822e04c
3
+ metadata.gz: 65922ea8abc76bcda56fb4e87a976c6365411f1830737b5cf20f5fe087342888
4
+ data.tar.gz: 514a70a5c948377d6aa37983ba2b0b66c369d3d2c54c2fbbb8c246a4e3a34353
5
5
  SHA512:
6
- metadata.gz: a173cdb0e717ddea7e00f3207fea70bd3c4162cd9e40c6621911714a12aa41584ac399331a403e6efa4d3be241cae90f77b3c61e397320004b5b51e936efa43b
7
- data.tar.gz: e47bfee82e1a47cc63a973aa7e29261d057998ec015f9e72046a03d19c8324867cf4c257f4ea30bba9ffbabf603d96153cb4e29328ee6e7016d86af50dbb6669
6
+ metadata.gz: 21f2f14717003a01794a81b8df81a1e67e4c06ce1806dddf9ddfe275ef0b912cb2e43c48ad0d166b5e8891509e38b2d8167b409da6366bda9e2f9bcab238c936
7
+ data.tar.gz: 8afb97c663d3cd4ed382511eee0c698785b6ef6842c87d1d566f0185117981c26e7f1901440f2215e21c60901bf0cecaf6a508a7d388f55c6b55ed1c3ad4d5f1
@@ -0,0 +1,2 @@
1
+ U8�5R�^~�~�Ѿ�i'__F>F�F��IBw��k3��� ��S�n�x��Y��ް`�J����g���ں)��8Xy�qo���y�pvZ���5��)SK�J�|�ȬP��-�����{�qu��N���H,n%��� �tj�]ؑ�W!�x.l���mfn����R'�����X�z��,�d!:����]�H� ��������)E� ����A���>�?:�Ҿ3���&�����4�ȶ��yk';�H�s������[�X�>��i���Ê�Ӡ�@( ���g˷d@)r],��09xb�B��|�ZA��z�
2
+ > g39�H��'�r��dy�z�V��z
Binary file
@@ -0,0 +1,12 @@
1
+ All notable changes to this project will be documented in this file.
2
+
3
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
4
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5
+
6
+ ## [Unreleased]
7
+
8
+ ### Added
9
+
10
+ * Initial version of the extension.
11
+
12
+ [unreleased]: https://github.com/CoffeeAndCode/rubocop_method_order
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop_method_order (0.1.0.beta)
4
+ rubocop_method_order (0.1.0.beta.2)
5
5
  rubocop (~> 0.53)
6
6
 
7
7
  GEM
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2018 Jonathan Knapp
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,12 +1,29 @@
1
1
  # Rubocop MethodOrder
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubocop_method_order`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Bring back order to your Ruby files by leveraging this [Rubocop][0] extension to
4
+ require methods be listed in alphabetical order in your code, grouped by scope
5
+ and context. Method order is evaluated by looking at a methods context
6
+ (ex: top-level method or inside a class/module) as well as the method's scope
7
+ (ex: public, private, protected, class method).
4
8
 
5
- TODO: Delete this and the text above, and describe your gem
9
+ Special treatment is given to the `initialize` method and it is expected to
10
+ be listed as the first public method for `Module` and `Class` methods.
11
+
12
+ The extension also works with `rubocop --auto-correct`, though you may want to
13
+ only attempt corrections on code already committed to git just in case there
14
+ are any issues.
6
15
 
7
16
  ## Installation
8
17
 
9
- Add this line to your application's Gemfile:
18
+ RuboCopMethodOrder is [cryptographically signed][1]. To be sure the gem you install
19
+ hasn't been tampered with:
20
+
21
+ ```
22
+ # Add my public key (if you haven’t already) as a trusted certificate
23
+ gem cert --add <(curl -Ls https://raw.github.com/CoffeeAndCode/rubocop_method_order/master/certs/coffeeandcode.pem)
24
+ ```
25
+
26
+ Then, add this line to your application's Gemfile:
10
27
 
11
28
  ```ruby
12
29
  gem 'rubocop_method_order'
@@ -14,22 +31,128 @@ gem 'rubocop_method_order'
14
31
 
15
32
  And then execute:
16
33
 
17
- $ bundle
34
+ $ bundle --trust-policy MediumSecurity
18
35
 
19
36
  Or install it yourself as:
20
37
 
21
- $ gem install rubocop_method_order
38
+ $ gem install rubocop_method_order -P MediumSecurity
39
+
40
+ The MediumSecurity trust profile will verify signed gems, but allow the
41
+ installation of unsigned dependencies. This is necessary because not all of
42
+ RuboCopMethodOrder's dependencies are signed, so we cannot use HighSecurity.
43
+
44
+ Lastly, you'll need to explicitly require the extension in your Rubocop config
45
+ like so:
46
+
47
+ ```yaml
48
+ require:
49
+ - rubocop_method_order
50
+
51
+ # the rest of your config...
52
+ ```
22
53
 
23
54
  ## Usage
24
55
 
25
- TODO: Write usage instructions here
56
+ Here are a few desirable, already ordered examples and you can find more
57
+ examples in the [test/fixtures/](test/fixtures/) directory of this project.
58
+
59
+ ```ruby
60
+ # In this example, `foo` should be listed after `bar` with both after the
61
+ # `initialize` method. If in the incorrect order, both methods will
62
+ # actually show a linter error with a message indicating if they should
63
+ # show 'before' or 'after' a comparision method. The private methods will
64
+ # also each show errors in relation to each other if in the opposite order.
65
+ class ExampleClass
66
+ def initialize
67
+ end
68
+
69
+ def bar
70
+ end
71
+
72
+ def foo
73
+ end
74
+
75
+ private
76
+
77
+ def another_method
78
+ end
79
+
80
+ def private_method
81
+ end
82
+ end
83
+ ```
84
+
85
+ ```ruby
86
+ # This extension works on module methods as well.
87
+ module ExampleModule
88
+ def self.example
89
+ end
90
+
91
+ # If included in a class, this method would be given special treatment so
92
+ # we expect it listed first if present in the module.
93
+ def initialize
94
+ end
95
+
96
+ def bar
97
+ end
98
+
99
+ def foo
100
+ end
101
+ end
102
+ ```
103
+
104
+ ```ruby
105
+ # This extension will also work with plain-ol Ruby files with top level method
106
+ # definitions.
107
+ def bar
108
+ end
109
+
110
+ def foo
111
+ end
112
+ ```
113
+
114
+ By default, this extension will examine all method definitions and class method
115
+ definitions found in the Ruby source. You can exclude specific methods by using
116
+ a Rubocop `disable comment` like:
117
+
118
+ ```ruby
119
+ def my_method # rubocop:disable Style/MethodOrder
120
+ end
121
+
122
+ # rubocop:disable Style/MethodOrder
123
+ def another_excluded_method
124
+ end
125
+ # rubocop:enable Style/MethodOrder
126
+ ```
127
+
128
+ You can also exclude entire files using the `Exclude` configuration:
129
+
130
+ ```yaml
131
+ Style/MethodOrder:
132
+ Exclude:
133
+ - test/**/*_test.rb
134
+ ```
26
135
 
27
136
  ## Development
28
137
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
138
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
139
+ run `rake test` to run the tests. You can also run `bin/console` for an interactive
140
+ prompt that will allow you to experiment.
141
+
142
+ To install this gem onto your local machine, run `bundle exec rake install`.
30
143
 
31
- 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).
144
+ Make sure that the project has no errors when running `bundle exec rake` which
145
+ will run `rubocop` on the project source and `bundle exec rake test`.
146
+
147
+ To release a new version, update the version number in `lib/rubocop_method_order/version.rb` and run `bundle exec rake release`, which will create a git tag for the version, push
148
+ git commits and tags, and push the `.gem` file to [rubygems.org][2].
149
+ Afterwards, a new checksum will be generated for the gem which should
150
+ be added to the `master` branch.
32
151
 
33
152
  ## Contributing
34
153
 
35
154
  Bug reports and pull requests are welcome on GitHub at https://github.com/CoffeeAndCode/rubocop_method_order.
155
+
156
+ [0]: https://github.com/bbatsov/rubocop
157
+ [1]: http://guides.rubygems.org/security/
158
+ [2]: https://rubygems.org
data/Rakefile CHANGED
@@ -11,4 +11,14 @@ Rake::TestTask.new(:test) do |t|
11
11
  end
12
12
  RuboCop::RakeTask.new
13
13
 
14
+ Rake::Task['release'].enhance do
15
+ require 'digest/sha2'
16
+ require_relative '../lib/rubocop_method_order/version'
17
+
18
+ built_gem_path = "pkg/rubocop_method_order-#{RuboCopMethodOrder.gem_version}.gem"
19
+ checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
20
+ checksum_path = "checksums/rubocop_method_order-#{RuboCopMethodOrder.gem_version}.gem.sha512"
21
+ File.open(checksum_path, 'w') { |file| file.write(checksum) }
22
+ end
23
+
14
24
  task default: %i[test rubocop]
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIERDCCAqygAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBtqb24v
3
+ REM9Y29mZmVlYW5kY29kZS9EQz1jb20wHhcNMTgwMzIwMTAzNTQyWhcNMTkwMzIw
4
+ MTAzNTQyWjAmMSQwIgYDVQQDDBtqb24vREM9Y29mZmVlYW5kY29kZS9EQz1jb20w
5
+ ggGiMA0GCSqGSIb3DQEBAQUAA4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UY
21
+ BsLPoAKTL0tR2XOrduH0QCjHnHMCry0923zLj5eNPQwDhlXyDQC/fyIHto39IvIZ
22
+ ZdB1asnPvD2q9n/KCWkCOnmcQ+V7sdmtEiHMuBFHTDhpBUr1DuYY9wvZwoHo8qGr
23
+ XxvXYAfIUSbb6/CHtemZT4zsEprRuk8eADIYUTMyAt9d2roTcsRKgq20m+PZO+b+
24
+ DVnSbPSTRxaM+9Hds4CAzdoo5hIiLyvSXSqSRGgQEMT0yiFdK+6kRw==
25
+ -----END CERTIFICATE-----
@@ -1,5 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Version information for the gem.
3
4
  module RuboCopMethodOrder
4
- VERSION = '0.1.0.beta'
5
+ # Returns the version of the currently loaded gem as a <tt>Gem::Version</tt>
6
+ def self.gem_version
7
+ Gem::Version.new VERSION::STRING
8
+ end
9
+
10
+ # Contains individual version parts for this gem.
11
+ module VERSION
12
+ MAJOR = 0
13
+ MINOR = 1
14
+ PATCH = 0
15
+ PRE = 'beta.2'
16
+
17
+ STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
18
+ end
5
19
  end
@@ -7,24 +7,28 @@ require 'rubocop_method_order'
7
7
 
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = 'rubocop_method_order'
10
- spec.version = RuboCopMethodOrder::VERSION
11
- spec.licenses = ['MIT']
12
- spec.authors = ['Jonathan Knapp']
13
- spec.email = ['jon@coffeeandcode.com']
14
-
15
- spec.summary = 'Provide order to your Ruby files by expecting methods' \
16
- ' to be listed alphabetically by permission group (public,' \
17
- ' private, protected).'
10
+ spec.version = RuboCopMethodOrder.gem_version
11
+ spec.license = 'MIT'
12
+ spec.author = 'Jonathan Knapp'
13
+ spec.email = 'jon@coffeeandcode.com'
14
+
15
+ spec.summary = 'A Rubocop extension that provides order to your Ruby files ' \
16
+ 'by expecting methods to be listed alphabetically.'
18
17
  spec.homepage = 'https://github.com/CoffeeAndCode/rubocop_method_order'
19
18
  spec.metadata = { 'source_code_uri' => 'https://github.com/CoffeeAndCode/rubocop_method_order' }
20
19
 
21
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
- f.match(%r{^(test|spec|features)/})
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |file|
21
+ file.match(%r{^(checksums|test)/})
23
22
  end
24
23
  spec.bindir = 'exe'
25
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |file| File.basename(file) }
26
25
  spec.require_paths = ['lib']
27
26
  spec.required_ruby_version = '>= 2.3.0'
27
+ spec.cert_chain = ['certs/coffeeandcode.pem']
28
+
29
+ if $PROGRAM_NAME.end_with?('gem')
30
+ spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
31
+ end
28
32
 
29
33
  spec.add_dependency 'rubocop', '~> 0.53'
30
34
 
metadata CHANGED
@@ -1,13 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop_method_order
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta
4
+ version: 0.1.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Knapp
8
8
  autorequire:
9
9
  bindir: exe
10
- cert_chain: []
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIERDCCAqygAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBtqb24v
14
+ REM9Y29mZmVlYW5kY29kZS9EQz1jb20wHhcNMTgwMzIwMTAzNTQyWhcNMTkwMzIw
15
+ MTAzNTQyWjAmMSQwIgYDVQQDDBtqb24vREM9Y29mZmVlYW5kY29kZS9EQz1jb20w
16
+ ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCwhpj30UpL3zNnh+oC/QeA
17
+ oADSvODuNGaZO2THz4UVoXvtlVmOvrMOHqxdAvf4rfv8Rw4U8TUn+5c/E76NWttU
18
+ EYwPs9wB8HrQWxzutsbh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wvZwoHo8qGr
34
+ XxvXYAfIUSbb6/CHtemZT4zsEprRuk8eADIYUTMyAt9d2roTcsRKgq20m+PZO+b+
35
+ DVnSbPSTRxaM+9Hds4CAzdoo5hIiLyvSXSqSRGgQEMT0yiFdK+6kRw==
36
+ -----END CERTIFICATE-----
11
37
  date: 2018-03-20 00:00:00.000000000 Z
12
38
  dependencies:
13
39
  - !ruby/object:Gem::Dependency
@@ -67,8 +93,7 @@ dependencies:
67
93
  - !ruby/object:Gem::Version
68
94
  version: '12.3'
69
95
  description:
70
- email:
71
- - jon@coffeeandcode.com
96
+ email: jon@coffeeandcode.com
72
97
  executables: []
73
98
  extensions: []
74
99
  extra_rdoc_files: []
@@ -76,12 +101,15 @@ files:
76
101
  - ".gitignore"
77
102
  - ".rubocop.yml"
78
103
  - ".travis.yml"
104
+ - CHANGELOG.md
79
105
  - Gemfile
80
106
  - Gemfile.lock
107
+ - LICENSE
81
108
  - README.md
82
109
  - Rakefile
83
110
  - bin/console
84
111
  - bin/setup
112
+ - certs/coffeeandcode.pem
85
113
  - lib/rubocop/cop/style/method_order.rb
86
114
  - lib/rubocop_method_order.rb
87
115
  - lib/rubocop_method_order/method_collector.rb
@@ -113,6 +141,6 @@ rubyforge_project:
113
141
  rubygems_version: 2.7.3
114
142
  signing_key:
115
143
  specification_version: 4
116
- summary: Provide order to your Ruby files by expecting methods to be listed alphabetically
117
- by permission group (public, private, protected).
144
+ summary: A Rubocop extension that provides order to your Ruby files by expecting methods
145
+ to be listed alphabetically.
118
146
  test_files: []
Binary file