Skip to content

Commit 75772fc

Browse files
authored
Merge pull request #9 from rpotter12/master
Detect all types of dependencies
2 parents 5da33a9 + 537c9c5 commit 75772fc

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
# Names are in alphabetical order, for the sanity of mind.
66

77
1. Balasankar C <balasankarc@autistici.org>
8+
2. Rohit Potter <rohitpotter12@gmail.com>

gemfileparser/__init__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ def __init__(self):
4747
group_block_regex = re.compile(
4848
r"group[ ]?:[ ]?(?P<groupblock>.*?) do")
4949
add_dvtdep_regex = re.compile(
50-
r".*add_development_dependency (?P<line>.*)")
50+
r".*add_development_dependency(?P<line>.*)")
5151
add_rundep_regex = re.compile(
52-
r".*add_runtime_dependency (?P<line>.*)")
52+
r".*add_runtime_dependency(?P<line>.*)")
53+
add_dep_regex = re.compile(
54+
r".*dependency(?P<line>.*)")
5355

5456
def __init__(self, filepath, appname=''):
5557
self.filepath = filepath # Required when calls to gemspec occurs
@@ -58,12 +60,13 @@ def __init__(self, filepath, appname=''):
5860
self.dependencies = {
5961
'development': [],
6062
'runtime': [],
63+
'dependency': [],
6164
'test': [],
6265
'production': [],
6366
'metrics': []
6467
}
6568
self.contents = self.gemfile.readlines()
66-
if filepath.endswith('gemspec'):
69+
if filepath.endswith(('.gemspec', '.podspec')):
6770
self.gemspec = True
6871
else:
6972
self.gemspec = False
@@ -96,6 +99,11 @@ def parse_line(self, line):
9699
for column in line:
97100
stripped_column = column.replace("'", "")
98101
stripped_column = stripped_column.replace('"', "")
102+
stripped_column = stripped_column.replace("%q<", "")
103+
stripped_column = stripped_column.replace("(", "")
104+
stripped_column = stripped_column.replace(")", "")
105+
stripped_column = stripped_column.replace("[", "")
106+
stripped_column = stripped_column.replace("]", "")
99107
stripped_column = stripped_column.strip()
100108
column_list.append(stripped_column)
101109
dep = self.Dependency()
@@ -165,6 +173,10 @@ def parse_gemspec(self, path=''):
165173
match = GemfileParser.add_rundep_regex.match(line)
166174
if match:
167175
GemfileParser.global_group = 'runtime'
176+
else:
177+
match = GemfileParser.add_dep_regex.match(line)
178+
if match:
179+
GemfileParser.global_group = 'dependency'
168180
if match:
169181
line = match.group('line')
170182
self.parse_line(line)
@@ -176,4 +188,4 @@ def parse(self):
176188
if self.gemspec:
177189
return self.parse_gemspec()
178190
else:
179-
return self.parse_gemfile()
191+
return self.parse_gemfile()

0 commit comments

Comments
 (0)