protokoll 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +69 -0
  3. data/Rakefile +37 -0
  4. data/lib/protokoll/extract_number.rb +25 -0
  5. data/lib/protokoll/protokoll_auto_increment.rb +89 -0
  6. data/lib/protokoll/version.rb +3 -0
  7. data/lib/protokoll.rb +53 -0
  8. data/lib/tasks/protokoll_tasks.rake +4 -0
  9. data/test/dummy/Rakefile +7 -0
  10. data/test/dummy/app/assets/javascripts/application.js +9 -0
  11. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  12. data/test/dummy/app/controllers/application_controller.rb +3 -0
  13. data/test/dummy/app/helpers/application_helper.rb +2 -0
  14. data/test/dummy/app/models/principal.rb +2 -0
  15. data/test/dummy/app/models/protocol.rb +3 -0
  16. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  17. data/test/dummy/config/application.rb +45 -0
  18. data/test/dummy/config/boot.rb +10 -0
  19. data/test/dummy/config/database.yml +25 -0
  20. data/test/dummy/config/environment.rb +5 -0
  21. data/test/dummy/config/environments/development.rb +30 -0
  22. data/test/dummy/config/environments/production.rb +60 -0
  23. data/test/dummy/config/environments/test.rb +42 -0
  24. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  25. data/test/dummy/config/initializers/inflections.rb +10 -0
  26. data/test/dummy/config/initializers/mime_types.rb +5 -0
  27. data/test/dummy/config/initializers/secret_token.rb +7 -0
  28. data/test/dummy/config/initializers/session_store.rb +8 -0
  29. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  30. data/test/dummy/config/locales/en.yml +5 -0
  31. data/test/dummy/config/routes.rb +58 -0
  32. data/test/dummy/config.ru +4 -0
  33. data/test/dummy/db/development.sqlite3 +0 -0
  34. data/test/dummy/db/migrate/20110923024431_create_protocols.rb +9 -0
  35. data/test/dummy/db/migrate/20110923101536_create_principals.rb +9 -0
  36. data/test/dummy/db/schema.rb +28 -0
  37. data/test/dummy/db/seeds.rb +1 -0
  38. data/test/dummy/db/test.sqlite3 +0 -0
  39. data/test/dummy/log/development.log +142 -0
  40. data/test/dummy/log/test.log +58060 -0
  41. data/test/dummy/public/404.html +26 -0
  42. data/test/dummy/public/422.html +26 -0
  43. data/test/dummy/public/500.html +26 -0
  44. data/test/dummy/public/favicon.ico +0 -0
  45. data/test/dummy/script/rails +6 -0
  46. data/test/dummy/test/fixtures/principals.yml +7 -0
  47. data/test/dummy/test/fixtures/protocols.yml +7 -0
  48. data/test/dummy/test/unit/principal_test.rb +7 -0
  49. data/test/dummy/test/unit/protocol_test.rb +7 -0
  50. data/test/protokoll_test.rb +200 -0
  51. data/test/test_helper.rb +13 -0
  52. metadata +162 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ number_format: MyString
5
+
6
+ two:
7
+ number_format: MyString
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ number: MyString
5
+
6
+ two:
7
+ number: MyString
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class PrincipalTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ProtocolTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,200 @@
1
+ require 'test_helper'
2
+
3
+ class ProtokollTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ time = Time.local(2011, 9, 25, 12, 0, 0)
7
+ Timecop.travel(time)
8
+
9
+ Protocol.protokoll_count = 0
10
+ end
11
+
12
+ test "first using # should get 1" do
13
+ Protocol.protokoll_pattern = "#"
14
+
15
+ protocol = Protocol.create
16
+ assert_equal "1", protocol.number
17
+ end
18
+
19
+ test "second protocol on DB should have number should equals 2" do
20
+ Protocol.protokoll_pattern = "#"
21
+
22
+ Protocol.create
23
+ protocol = Protocol.create
24
+ assert_equal "2", protocol.number
25
+ end
26
+
27
+ test "third protocol on DB should have number should equals 3" do
28
+ Protocol.protokoll_pattern = "#"
29
+
30
+ protocol1 = Protocol.create
31
+ protocol2 = Protocol.create
32
+ protocol3 = Protocol.create
33
+ assert_equal "3", protocol3.number
34
+ end
35
+
36
+ test "first using format A# should get A1" do
37
+ Protocol.protokoll_pattern = "A#"
38
+
39
+ protocol1 = Protocol.create
40
+ assert_equal "A1", protocol1.number
41
+ end
42
+
43
+ test "second using format A# should get A2" do
44
+ Protocol.protokoll_pattern = "A#"
45
+
46
+ protocol1 = Protocol.create
47
+ protocol2 = Protocol.create
48
+ assert_equal "A2", protocol2.number
49
+ end
50
+
51
+ test "first using format A## should get A01" do
52
+ Protocol.protokoll_pattern = "A##"
53
+
54
+ protocol1 = Protocol.create
55
+ assert_equal "A01", protocol1.number
56
+ end
57
+
58
+ test "second using format A## should get A02" do
59
+ Protocol.protokoll_pattern = "A##"
60
+
61
+ protocol1 = Protocol.create
62
+ protocol2 = Protocol.create
63
+ assert_equal "A02", protocol2.number
64
+ end
65
+
66
+ test "third using format A## should get A03" do
67
+ Protocol.protokoll_pattern = "A##"
68
+
69
+ protocol1 = Protocol.create
70
+ protocol2 = Protocol.create
71
+ protocol3 = Protocol.create
72
+ assert_equal "A03", protocol3.number
73
+ end
74
+
75
+ test "first use of %y# should get 111" do
76
+ Protocol.protokoll_pattern = "%y#"
77
+
78
+ protocol1 = Protocol.create
79
+ assert_equal "111", protocol1.number
80
+ end
81
+
82
+ test "second use of %y## should get 1101" do
83
+ Protocol.protokoll_pattern = "%y##"
84
+
85
+ protocol1 = Protocol.create
86
+ assert_equal "1101", protocol1.number
87
+ end
88
+
89
+ test "first use of %y%m## should get 110901" do
90
+ Protocol.protokoll_pattern = "%y%m##"
91
+
92
+ protocol1 = Protocol.create
93
+ assert_equal "110901", protocol1.number
94
+ end
95
+
96
+ test "second use of %y%m## on next month after should get 111001" do
97
+ Protocol.protokoll_pattern = "%y%m##"
98
+
99
+ protocol1 = Protocol.create
100
+
101
+ Timecop.travel(Time.now + 1.month)
102
+
103
+ protocol2 = Protocol.create
104
+
105
+ assert_equal "111001", protocol2.number
106
+ end
107
+
108
+ test "%y%m%H#### should get 1109120001" do
109
+ Protocol.protokoll_pattern = "%y%m%H####"
110
+
111
+ protocol1 = Protocol.create
112
+
113
+ assert_equal "1109120001", protocol1.number
114
+ end
115
+
116
+ test "%y## on next year should get 1201" do
117
+ Protocol.protokoll_pattern = "%y##"
118
+
119
+ protocol1 = Protocol.create
120
+ time = Time.local(2012, 9, 25, 12, 3, 0)
121
+ Timecop.travel(time)
122
+
123
+ protocol2 = Protocol.create
124
+
125
+ assert_equal "1201", protocol2.number
126
+ end
127
+
128
+ test "500.time create using %y%m%H#### should get 1109120500" do
129
+ Protocol.protokoll_pattern = "%y%m%H####"
130
+
131
+ 500.times { Protocol.create }
132
+
133
+ assert_equal "1109120500", Protocol.last.number
134
+ end
135
+
136
+ test "PROT%H%m%y#### should get PROT%H%m%y0001" do
137
+ Protocol.protokoll_pattern = "PROT%H%m%y####"
138
+
139
+ protocol1 = Protocol.create
140
+
141
+ assert_equal "PROT1209110001", protocol1.number
142
+ end
143
+
144
+ test "PROT%Y%m%H#### should get PROT201109120001" do
145
+ Protocol.protokoll_pattern = "PROT%Y%m%H####"
146
+
147
+ protocol1 = Protocol.create
148
+
149
+ assert_equal "PROT201109120001", protocol1.number
150
+ end
151
+
152
+ test "use of sufix ####PROTO should get 0001PROTO" do
153
+ Protocol.protokoll_pattern = "####PROTO"
154
+
155
+ protocol1 = Protocol.create
156
+
157
+ assert_equal "0001PROTO", protocol1.number
158
+ end
159
+
160
+ test "use of sufix %Y%M####PROTO on 12:03 should get 2011030001PROTO" do
161
+ Protocol.protokoll_pattern = "%Y%M####PROTO"
162
+
163
+ time = Time.local(2011, 9, 25, 12, 3, 0)
164
+ Timecop.travel(time)
165
+
166
+ protocol1 = Protocol.create
167
+
168
+ assert_equal "2011030001PROTO", protocol1.number
169
+ end
170
+
171
+ test "use of sufix %Y%M####PROTO on 12:15 should get 2011150001PROTO" do
172
+ Protocol.protokoll_pattern = "%Y%M####PROTO"
173
+
174
+ time = Time.local(2011, 9, 25, 12, 15, 0)
175
+ Timecop.travel(time)
176
+
177
+ protocol1 = Protocol.create
178
+
179
+ assert_equal "2011150001PROTO", protocol1.number
180
+ end
181
+
182
+ # test "Start application with populated db." do
183
+ # Protocol.protokoll_pattern = "%Y%M####PROTO"
184
+ #
185
+ # Protocol.create
186
+ # Protocol.create
187
+ # Protocol.create
188
+ #
189
+ # # restart application
190
+ # class << Protocol
191
+ # remove_method :protokoll
192
+ # end
193
+ #
194
+ # protocol = Protocol.create
195
+ #
196
+ # assert_equal "2011090004PROTO", protocol.number
197
+ # end
198
+ end
199
+
200
+
@@ -0,0 +1,13 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ require 'rubygems'
8
+ require "timecop"
9
+
10
+ Rails.backtrace_cleaner.remove_silencers!
11
+
12
+ # Load support files
13
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: protokoll
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Celso Dantas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-27 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70268384137840 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70268384137840
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &70268384137420 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70268384137420
36
+ description: ! 'Enable the creation of autoincrement Time based string on a model.
37
+ Ex: 2011001, 2011002...'
38
+ email:
39
+ - celsodantas@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - lib/protokoll/extract_number.rb
45
+ - lib/protokoll/protokoll_auto_increment.rb
46
+ - lib/protokoll/version.rb
47
+ - lib/protokoll.rb
48
+ - lib/tasks/protokoll_tasks.rake
49
+ - MIT-LICENSE
50
+ - Rakefile
51
+ - README.rdoc
52
+ - test/dummy/app/assets/javascripts/application.js
53
+ - test/dummy/app/assets/stylesheets/application.css
54
+ - test/dummy/app/controllers/application_controller.rb
55
+ - test/dummy/app/helpers/application_helper.rb
56
+ - test/dummy/app/models/principal.rb
57
+ - test/dummy/app/models/protocol.rb
58
+ - test/dummy/app/views/layouts/application.html.erb
59
+ - test/dummy/config/application.rb
60
+ - test/dummy/config/boot.rb
61
+ - test/dummy/config/database.yml
62
+ - test/dummy/config/environment.rb
63
+ - test/dummy/config/environments/development.rb
64
+ - test/dummy/config/environments/production.rb
65
+ - test/dummy/config/environments/test.rb
66
+ - test/dummy/config/initializers/backtrace_silencers.rb
67
+ - test/dummy/config/initializers/inflections.rb
68
+ - test/dummy/config/initializers/mime_types.rb
69
+ - test/dummy/config/initializers/secret_token.rb
70
+ - test/dummy/config/initializers/session_store.rb
71
+ - test/dummy/config/initializers/wrap_parameters.rb
72
+ - test/dummy/config/locales/en.yml
73
+ - test/dummy/config/routes.rb
74
+ - test/dummy/config.ru
75
+ - test/dummy/db/development.sqlite3
76
+ - test/dummy/db/migrate/20110923024431_create_protocols.rb
77
+ - test/dummy/db/migrate/20110923101536_create_principals.rb
78
+ - test/dummy/db/schema.rb
79
+ - test/dummy/db/seeds.rb
80
+ - test/dummy/db/test.sqlite3
81
+ - test/dummy/log/development.log
82
+ - test/dummy/log/test.log
83
+ - test/dummy/public/404.html
84
+ - test/dummy/public/422.html
85
+ - test/dummy/public/500.html
86
+ - test/dummy/public/favicon.ico
87
+ - test/dummy/Rakefile
88
+ - test/dummy/script/rails
89
+ - test/dummy/test/fixtures/principals.yml
90
+ - test/dummy/test/fixtures/protocols.yml
91
+ - test/dummy/test/unit/principal_test.rb
92
+ - test/dummy/test/unit/protocol_test.rb
93
+ - test/protokoll_test.rb
94
+ - test/test_helper.rb
95
+ homepage: https://github.com/celsodantas/protokoll
96
+ licenses: []
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 1.8.10
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: A simple Rails gem to create custom autoincrement values to a database column
119
+ test_files:
120
+ - test/dummy/app/assets/javascripts/application.js
121
+ - test/dummy/app/assets/stylesheets/application.css
122
+ - test/dummy/app/controllers/application_controller.rb
123
+ - test/dummy/app/helpers/application_helper.rb
124
+ - test/dummy/app/models/principal.rb
125
+ - test/dummy/app/models/protocol.rb
126
+ - test/dummy/app/views/layouts/application.html.erb
127
+ - test/dummy/config/application.rb
128
+ - test/dummy/config/boot.rb
129
+ - test/dummy/config/database.yml
130
+ - test/dummy/config/environment.rb
131
+ - test/dummy/config/environments/development.rb
132
+ - test/dummy/config/environments/production.rb
133
+ - test/dummy/config/environments/test.rb
134
+ - test/dummy/config/initializers/backtrace_silencers.rb
135
+ - test/dummy/config/initializers/inflections.rb
136
+ - test/dummy/config/initializers/mime_types.rb
137
+ - test/dummy/config/initializers/secret_token.rb
138
+ - test/dummy/config/initializers/session_store.rb
139
+ - test/dummy/config/initializers/wrap_parameters.rb
140
+ - test/dummy/config/locales/en.yml
141
+ - test/dummy/config/routes.rb
142
+ - test/dummy/config.ru
143
+ - test/dummy/db/development.sqlite3
144
+ - test/dummy/db/migrate/20110923024431_create_protocols.rb
145
+ - test/dummy/db/migrate/20110923101536_create_principals.rb
146
+ - test/dummy/db/schema.rb
147
+ - test/dummy/db/seeds.rb
148
+ - test/dummy/db/test.sqlite3
149
+ - test/dummy/log/development.log
150
+ - test/dummy/log/test.log
151
+ - test/dummy/public/404.html
152
+ - test/dummy/public/422.html
153
+ - test/dummy/public/500.html
154
+ - test/dummy/public/favicon.ico
155
+ - test/dummy/Rakefile
156
+ - test/dummy/script/rails
157
+ - test/dummy/test/fixtures/principals.yml
158
+ - test/dummy/test/fixtures/protocols.yml
159
+ - test/dummy/test/unit/principal_test.rb
160
+ - test/dummy/test/unit/protocol_test.rb
161
+ - test/protokoll_test.rb
162
+ - test/test_helper.rb