protokoll 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.rdoc +28 -1
- data/lib/generators/protokoll/migration/migration_generator.rb +24 -0
- data/lib/generators/protokoll/migration/templates/create_custom_auto_increments.rb +15 -0
- data/lib/protokoll/counter.rb +33 -0
- data/lib/protokoll/formater.rb +79 -0
- data/lib/protokoll/models/custom_auto_increment.rb +8 -0
- data/lib/protokoll/protokoll.rb +34 -0
- data/lib/protokoll/version.rb +1 -1
- data/lib/protokoll.rb +4 -37
- data/test/dummy/app/models/call_defined_in_tests.rb +7 -0
- data/test/dummy/app/models/protocol_defined_in_tests.rb +7 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20120222164124_create_custom_auto_increments.rb +15 -0
- data/test/dummy/db/schema.rb +16 -7
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +424 -0
- data/test/dummy/log/test.log +212148 -0
- data/test/protokoll_test.rb +251 -121
- metadata +21 -20
- data/lib/protokoll/auto_increment.rb +0 -95
- data/lib/protokoll/class_variable.rb +0 -13
- data/lib/protokoll/extract_number.rb +0 -25
- data/test/dummy/app/models/call.rb +0 -3
- data/test/dummy/app/models/principal.rb +0 -2
- data/test/dummy/app/models/protocol.rb +0 -3
- data/test/dummy/db/migrate/20110923101536_create_principals.rb +0 -9
@@ -1,25 +0,0 @@
|
|
1
|
-
module Protokoll
|
2
|
-
module ExtractNumber
|
3
|
-
def self.create_number_mask(format)
|
4
|
-
format.split("").map do |i|
|
5
|
-
(i == "#") ? 1 : 0
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.extract_using_mask(db_number, mask)
|
10
|
-
result = db_number.split("").select.with_index do |n, i|
|
11
|
-
n if mask[i] == 1
|
12
|
-
end
|
13
|
-
result.join.to_i
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.number(str, pattern)
|
17
|
-
mask = create_number_mask( expand_pattern(pattern) )
|
18
|
-
extract_using_mask(str, mask)
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.expand_pattern(pattern)
|
22
|
-
pattern.sub("%Y", "0000")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|