getcomments 0.0.1 → 0.1.0

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
- SHA1:
3
- metadata.gz: 01cd40028f263855c57e550e4c2578ecc7859ce1
4
- data.tar.gz: e4eb10535f97759162a02144138bc24a0b196c17
2
+ SHA256:
3
+ metadata.gz: 81f3c63a29fc5da2d5720ed6ffd18a3f7b0839c0e225ddb54c0f8fb0cbdc1461
4
+ data.tar.gz: d2f56c1df54c246104cd1feeeb23bd58d48c3aeb35ea4c3c86dba2d18f10ba44
5
5
  SHA512:
6
- metadata.gz: 20cb117d9bf0af5f9af33bf59ccf01651c33eccb75aaba462f5bd8a2b0adf7d73f5a9f8e1f1c979e50cdc8aa08ba8f06dc8e899bc2eedb3f9b13767481e14816
7
- data.tar.gz: 0a705f0c77c0406cb5be02f4fe6c75edd81fde797ccaaad27c63dd7c736db6e85539f12bbe179309ed6ef1e76511c698a8597f1f4d6c17922b8f7219d84cefb5
6
+ metadata.gz: 6b38b6258c8c5ea428253c33fa9ecad90649b522f8e33cf2cb4ad0b31a525c1aaaa90737475c857b1c77c2bc4599a0ac07a078971711da81f0a48484301e74b6
7
+ data.tar.gz: 38eaf21fb04cd582938abfcd932e2b376ad66fee466222e6c45bcbdc575d48808b8403f67feef72ed67c7e273ac3f8b0e0d0c942b8ed7ade80a0b157e5fa34fa
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  GetComments - Extract Comments from Ruby Code
2
2
  ==================================================
3
3
 
4
- [![Gem](https://img.shields.io/gem/v/getcomments.svg?style=flat-square)](https://rubygems.org/gems/getcomments)
5
- [![Travis](https://img.shields.io/travis/DannyBen/getcomments.svg?style=flat-square)](https://travis-ci.org/DannyBen/getcomments)
6
- [![Code Climate](https://img.shields.io/codeclimate/github/DannyBen/getcomments.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/getcomments)
7
- [![Gemnasium](https://img.shields.io/gemnasium/DannyBen/getcomments.svg?style=flat-square)](https://gemnasium.com/DannyBen/getcomments)
4
+ [![Gem Version](https://badge.fury.io/rb/getcomments.svg)](https://badge.fury.io/rb/getcomments)
5
+ [![Build Status](https://travis-ci.com/DannyBen/getcomments.svg?branch=master)](https://travis-ci.com/DannyBen/getcomments)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/bcf41ae9f2c8ebd59f4d/maintainability)](https://codeclimate.com/github/DannyBen/getcomments/maintainability)
7
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/bcf41ae9f2c8ebd59f4d/test_coverage)](https://codeclimate.com/github/DannyBen/getcomments/test_coverage)
8
8
 
9
9
  ---
10
10
 
@@ -36,9 +36,9 @@ comments = GetComments::Read.from 'filename.rb'
36
36
  p comments
37
37
 
38
38
  # => {
39
- "module TestModule" => "This is the module comment",
40
- "class TestClass" => "This is the class comment",
41
- "def some_method" => "This is a multiline\nmethod comment"
42
- }
39
+ # "module TestModule" => "This is the module comment",
40
+ # "class TestClass" => "This is the class comment",
41
+ # "def some_method" => "This is a multiline\nmethod comment"
42
+ # }
43
43
 
44
44
  ```
@@ -1,6 +1,7 @@
1
1
  module GetComments
2
2
  class Read
3
3
  attr_reader :filename
4
+ attr_accessor :comment_index
4
5
 
5
6
  def self.from(filename)
6
7
  new(filename).get
@@ -8,6 +9,7 @@ module GetComments
8
9
 
9
10
  def initialize(filename)
10
11
  @filename = filename
12
+ @comment_index = 0
11
13
  end
12
14
 
13
15
  def get
@@ -20,12 +22,15 @@ module GetComments
20
22
  if line[0] == '#'
21
23
  last_comment << line.gsub(/^# ?/, '')
22
24
  elsif !last_comment.empty?
23
- key = get_key line
24
- result[key] = last_comment.join("\n") if key
25
+ result[get_key line] = last_comment.join("\n")
25
26
  last_comment = []
26
27
  end
27
28
  end
28
29
 
30
+ unless last_comment.empty?
31
+ result[get_key] = last_comment.join("\n")
32
+ end
33
+
29
34
  result
30
35
  end
31
36
 
@@ -35,14 +40,13 @@ module GetComments
35
40
  @lines ||= File.readlines filename
36
41
  end
37
42
 
38
- def get_key(line)
39
- key = nil
40
-
43
+ def get_key(line='')
41
44
  if match = line.match(/^([\w_]+ [\w\:]+)/)
42
- key = match.captures.first
45
+ match.captures.first
46
+ else
47
+ self.comment_index += 1
48
+ "comment_#{comment_index}"
43
49
  end
44
-
45
- key
46
50
  end
47
51
  end
48
52
  end
@@ -1,3 +1,3 @@
1
1
  module GetComments
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,127 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getcomments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-04 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: runfile
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.8'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.8'
27
- - !ruby/object:Gem::Dependency
28
- name: runfile-tasks
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.4'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.4'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.5'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.5'
55
- - !ruby/object:Gem::Dependency
56
- name: rdoc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '5.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '5.0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.10'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.10'
83
- - !ruby/object:Gem::Dependency
84
- name: pry-doc
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0.10'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0.10'
97
- - !ruby/object:Gem::Dependency
98
- name: simplecov
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0.13'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0.13'
111
- - !ruby/object:Gem::Dependency
112
- name: yard
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.8'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0.8'
11
+ date: 2019-01-11 00:00:00.000000000 Z
12
+ dependencies: []
125
13
  description: Extract comments from a Ruby source file
126
14
  email: db@dannyben.com
127
15
  executables: []
@@ -144,7 +32,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
32
  requirements:
145
33
  - - ">="
146
34
  - !ruby/object:Gem::Version
147
- version: 2.0.0
35
+ version: 2.2.2
148
36
  required_rubygems_version: !ruby/object:Gem::Requirement
149
37
  requirements:
150
38
  - - ">="
@@ -152,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
40
  version: '0'
153
41
  requirements: []
154
42
  rubyforge_project:
155
- rubygems_version: 2.6.6
43
+ rubygems_version: 2.7.6
156
44
  signing_key:
157
45
  specification_version: 4
158
46
  summary: Extract comments from a Ruby source file