permutations 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/permutations.rb CHANGED
@@ -17,10 +17,10 @@ module Permutations
17
17
  module String
18
18
  # Create multi-level string permutations
19
19
  # "{a,b,c}{1,2,3}".permutations # => ["a1", "a2", "a3", "b1", "b2", "b3", "c1", "c2", "c3"]
20
- def permutations
20
+ def permutations(separator=',')
21
21
  matches = self.scan(/(\{(.*?)\})/)
22
22
  substitutions = matches.map{|match| match[0]}
23
- permutations = matches.map{|match| match[1].split(/\s*,\s*/)}.permutations
23
+ permutations = matches.map{|match| match[1].split(/\s*#{Regexp.escape(separator)}\s*/)}.permutations
24
24
  permutations.map do |permutation|
25
25
  permutated_string = self.dup
26
26
  permutation.each_with_index do |choice, index|
data/permutations.gemspec CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.name = 'permutations'
4
4
  s.summary = "Permutations is a library that allows you to generate permutations from Arrays and Strings."
5
5
  s.description = s.summary
6
- s.version = '0.1.0'
6
+ s.version = '0.1.1'
7
7
  s.date = '2010-01-21'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Wes Oldenbeuving"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: permutations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wes Oldenbeuving