unparser 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd330877f92585ef66cfd283dba22e1d6202446c
4
- data.tar.gz: ec9dbaaf5b7e460bc19e2f6564e25e016b4149c8
3
+ metadata.gz: 7b6b34a335d81e60393e168fed525e222b2c5300
4
+ data.tar.gz: dafb68722a32c72bd1200db7b92a1a6477f54c95
5
5
  SHA512:
6
- metadata.gz: 2ac84d618bb92e5b9ec2f8360378c820f55545f993532febac3b5b4715cf85e16ccc88271fad3a2c6a8efa34e5297432799b0cc31481396807799c415ecab7b0
7
- data.tar.gz: 45bc61077ae22a0c74538fda91621319ea99ace383338a5e6a6f90f66eb5e02ed88938f07f2d5f95999b1ed2372f68c8ddddc9009b23ea1df493854d6d52de90
6
+ metadata.gz: 77fda7c1b4c35dfad959a0a9c47bc9f5cdaae335fb3d302bb4b3f0e683c9733e6c6005ffe2495f0c91c0bf5d39e1b173bf99e1c918d13ef6f622d73079e4c534
7
+ data.tar.gz: b0252bbfb29b1c29b7e1de2fc7dd3719288c5b8227684558e7db7bc2c2cb347863123a10131a52c8ea6c2261a88879d6d64aec347189f68b09a7356a8e03531d
data/Changelog.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.1.5 2013-11-01
2
+
3
+ * Fix crash with comment reproduction.
4
+
1
5
  # v0.1.4 2013-11-01
2
6
 
3
7
  * Code cleanups.
data/config/rubocop.yml CHANGED
@@ -41,6 +41,9 @@ AccessControl:
41
41
  LineLength:
42
42
  Max: 113 # TODO: lower to 79 once the rubocop branch in shared/Gemfile is removed
43
43
 
44
+ ClassLength:
45
+ Max: 196
46
+
44
47
  # Disabled because of indenting with private keyword in class bodies.
45
48
  IndentationWidth:
46
49
  Enabled: false
@@ -67,7 +67,7 @@ module Unparser
67
67
  #
68
68
  def take_before(node, source_part)
69
69
  location = node.location
70
- if location
70
+ if location.respond_to?(source_part)
71
71
  range = location.public_send(source_part)
72
72
  take_while { |comment| comment.location.expression.end_pos <= range.begin_pos }
73
73
  else
@@ -3,23 +3,45 @@ require 'parser/current'
3
3
 
4
4
  describe Unparser::Comments, '#take_before' do
5
5
 
6
- let(:ast_and_comments) do
7
- Parser::CurrentRuby.parse_with_comments(<<-RUBY)
8
- def hi # EOL 1
9
- # comment
10
- end # EOL 2
11
- RUBY
12
- end
13
6
  let(:ast) { ast_and_comments[0] }
14
7
  let(:comments) { ast_and_comments[1] }
15
8
  let(:object) { described_class.new(comments) }
16
9
 
17
- it 'should return no comments none are before the node' do
18
- expect(object.take_before(ast, :expression)).to eql([])
10
+ context 'usual case' do
11
+
12
+ let(:ast_and_comments) do
13
+ Parser::CurrentRuby.parse_with_comments(<<-RUBY)
14
+ def hi # EOL 1
15
+ # comment
16
+ end # EOL 2
17
+ RUBY
18
+ end
19
+
20
+ it 'should return no comments none are before the node' do
21
+ expect(object.take_before(ast, :expression)).to eql([])
22
+ end
23
+
24
+ it 'should only the comments that are before the specified part of the node' do
25
+ expect(object.take_before(ast, :end)).to eql(comments.first(2))
26
+ expect(object.take_all).to eql([comments[2]])
27
+ end
19
28
  end
20
29
 
21
- it 'should only the comments that are before the specified part of the node' do
22
- expect(object.take_before(ast, :end)).to eql(comments.first(2))
23
- expect(object.take_all).to eql([comments[2]])
30
+ context 'when node does not respond to source part' do
31
+
32
+ let(:ast_and_comments) do
33
+ Parser::CurrentRuby.parse_with_comments(<<-RUBY)
34
+ expression ? :foo : :bar # EOL 1
35
+ # EOL 2
36
+ RUBY
37
+ end
38
+
39
+ it 'should return no comments none are before the node' do
40
+ expect(object.take_before(ast, :expression)).to eql([])
41
+ end
42
+
43
+ it 'should only the comments that are before the specified part of the node' do
44
+ expect(object.take_before(ast, :end)).to eql([])
45
+ end
24
46
  end
25
47
  end
data/unparser.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'unparser'
5
- s.version = '0.1.4'
5
+ s.version = '0.1.5'
6
6
 
7
7
  s.authors = ['Markus Schirp']
8
8
  s.email = 'mbj@schir-dso.com'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-01 00:00:00.000000000 Z
11
+ date: 2013-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser