Skip to content

Commit

Permalink
Fix parser with subpaths
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Mar 21, 2011
1 parent 5568da4 commit b45e83e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/rip/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def self.parse(text)
end

def to_s
"#{name} (#{version})"
if path.nil? || path == "/"
"#{name} (#{version})"
else
"#{name} #{path} (#{version})"
end
end

def inspect
Expand Down
14 changes: 10 additions & 4 deletions lib/rip/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ def parse_package(line)

return nil if line.empty?

source, tweedle, version, *_ = line.split(' ')
args = line.split(' ')

package = {}
package[:source] = source

if version || tweedle
package[:version] = version ? "#{tweedle} #{version}" : tweedle
package[:source] = args[0]

if args[1] && args[1] =~ /^\//
package[:path] = args[1]
package[:version] = args[2] if args[2]
elsif args[1] && args[2]
package[:version] = "#{args[1]} #{args[2]}"
else
package[:version] = args[1] if args[1]
end

package
Expand Down

0 comments on commit b45e83e

Please sign in to comment.