cane-hashcheck 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/CONTRIBUTING.md +13 -0
- data/README.md +9 -6
- data/lib/cane/hashcheck/hash_check.rb +8 -3
- data/lib/cane/hashcheck/version.rb +1 -1
- data/spec/cane/hash_check_spec.rb +6 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 471602330607cb2c010871102bb8b1e0976f8016
|
4
|
+
data.tar.gz: bbe149977d4ffdf1a687a14eab430ce795631687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77db1bab7a24f90fefb95316be7ef472659d5ec246bffaebebbdd912df542aab385f8abe7d596c873fe5edf06420062ac01819b4405d4dc9b303c8cdee162012
|
7
|
+
data.tar.gz: e8703364ab7e7169b728a67d513467bb48172e18f36524fd69eec7180fb003686989dc0c74284f239efd0cc5215a162cacf9345f3d7887f7c4cc1c54d9494165
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
#v1.2.0
|
4
|
+
*2013-06-14*
|
5
|
+
|
6
|
+
[\[8 commits\]](https://github.com/chrishunt/cane-hashcheck/compare/v1.1.0...v1.2.0)
|
7
|
+
|
8
|
+
- Hash rockets without whitespace are invalid
|
9
|
+
- Hash rockets valid in namespaced rescue
|
10
|
+
|
11
|
+
##v1.1.0
|
12
|
+
*2013-05-15*
|
13
|
+
|
14
|
+
[\[2 commits\]](https://github.com/chrishunt/cane-hashcheck/compare/v1.0.0...v1.1.0)
|
15
|
+
|
16
|
+
- Allow whitespace around hash rocket when valid
|
17
|
+
|
18
|
+
##v1.0.0
|
19
|
+
*2013-05-15*
|
20
|
+
|
21
|
+
[\[7 commits\]](https://github.com/chrishunt/cane-hashcheck/compare/v0.9.0...v1.0.0)
|
22
|
+
|
23
|
+
- Allow hash rocket when key is double quoted
|
24
|
+
- Allow hash rockets when keys are Integers
|
25
|
+
|
26
|
+
##v0.9.0
|
27
|
+
*2013-04-30*
|
28
|
+
|
29
|
+
- Initial release
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
Want to contribute? Awesome! Thank you so much.
|
4
|
+
|
5
|
+
## How?
|
6
|
+
|
7
|
+
1. [Fork it](https://help.github.com/articles/fork-a-repo)
|
8
|
+
2. Create a feature branch (`git checkout -b my-new-feature`)
|
9
|
+
3. Commit changes, **with tests** (`git commit -am 'Add some feature'`)
|
10
|
+
4. Run the tests (`bundle exec rake`)
|
11
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
12
|
+
6. Create new [Pull
|
13
|
+
Request](https://help.github.com/articles/using-pull-requests)
|
data/README.md
CHANGED
@@ -75,10 +75,13 @@ See the [cane project](https://github.com/square/cane) for general usage
|
|
75
75
|
instructions.
|
76
76
|
|
77
77
|
## Contributing
|
78
|
+
Please see the [Contributing
|
79
|
+
Document](https://github.com/chrishunt/cane-hashcheck/blob/master/CONTRIBUTING.md)
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
## Changelog
|
82
|
+
Please see the [Changelog
|
83
|
+
Document](https://github.com/chrishunt/cane-hashcheck/blob/master/CHANGELOG.md)
|
84
|
+
|
85
|
+
## License
|
86
|
+
Copyright (C) 2013 Chris Hunt, [MIT
|
87
|
+
License](https://github.com/chrishunt/cane-hashcheck/blob/master/LICENSE.txt)
|
@@ -1,6 +1,6 @@
|
|
1
|
+
# Creates violations for hashes using pre-Ruby 1.9 hash syntax. Hash rockets
|
2
|
+
# are allowed only if the key is a 'string' or CONSTANT.
|
1
3
|
module Cane
|
2
|
-
# Creates violations for hashes using pre-Ruby 1.9 hash syntax. Hash rockets
|
3
|
-
# are allowed only if the key is a 'string' or CONSTANT.
|
4
4
|
HashCheck = Struct.new(:options) do
|
5
5
|
|
6
6
|
DESCRIPTION = 'Ruby 1.9 hash syntax violation'
|
@@ -49,11 +49,16 @@ module Cane
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def invalid?(line)
|
52
|
-
line =~
|
52
|
+
line =~ hash_rocket_regex
|
53
53
|
end
|
54
54
|
|
55
55
|
def file_names
|
56
56
|
Dir[ options.fetch(:hash_glob){ DEFAULT_GLOB } ]
|
57
57
|
end
|
58
|
+
|
59
|
+
# http://rubular.com/r/p8AoYTwOWO
|
60
|
+
def hash_rocket_regex
|
61
|
+
/(?:[^:]:\w+)\s*=>\s*/
|
62
|
+
end
|
58
63
|
end
|
59
64
|
end
|
@@ -22,17 +22,20 @@ describe Cane::HashCheck do
|
|
22
22
|
:not => :valid,
|
23
23
|
TOTALLY => :valid,
|
24
24
|
LOTS_OF => :whitespace_is_valid,
|
25
|
-
18
|
25
|
+
18 =>, 1 # this is valid, hash rockets are required for ints
|
26
|
+
:no_whitespace=>:still_not_valid
|
26
27
|
}
|
27
28
|
{
|
28
29
|
'also' => 'valid',
|
29
30
|
"and also" => 'valid'
|
30
31
|
}
|
32
|
+
|
33
|
+
rescue Foobar::Test => valid
|
31
34
|
RUBY
|
32
35
|
end
|
33
36
|
|
34
37
|
it 'has a violation for each invalid hash rocket' do
|
35
|
-
expect(subject.violations.count).to eq
|
38
|
+
expect(subject.violations.count).to eq 3
|
36
39
|
end
|
37
40
|
|
38
41
|
it 'puts the offending file name in the violation' do
|
@@ -44,6 +47,7 @@ describe Cane::HashCheck do
|
|
44
47
|
it 'puts the offending line number in the violation' do
|
45
48
|
expect(subject.violations[0][:line]).to eq 2
|
46
49
|
expect(subject.violations[1][:line]).to eq 5
|
50
|
+
expect(subject.violations[2][:line]).to eq 9
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cane-hashcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,6 +74,8 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
|
+
- CHANGELOG.md
|
78
|
+
- CONTRIBUTING.md
|
77
79
|
- Gemfile
|
78
80
|
- LICENSE.txt
|
79
81
|
- README.md
|