randomized_field 0.1.0 → 1.0.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 (70) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +46 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +24 -0
  5. data/.travis.yml +7 -0
  6. data/Gemfile +5 -0
  7. data/Gemfile.lock +81 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +33 -68
  10. data/Rakefile +4 -35
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/randomized_field.rb +18 -4
  14. data/lib/randomized_field/callback.rb +30 -0
  15. data/lib/randomized_field/generator.rb +23 -0
  16. data/lib/randomized_field/version.rb +1 -2
  17. data/randomized_field.gemspec +49 -0
  18. metadata +133 -144
  19. data/MIT-LICENSE +0 -20
  20. data/lib/randomized_field/base.rb +0 -21
  21. data/lib/randomized_field/defaults.rb +0 -8
  22. data/lib/randomized_field/randomizer.rb +0 -31
  23. data/lib/tasks/randomized_field_tasks.rake +0 -4
  24. data/test/dummy/Rakefile +0 -7
  25. data/test/dummy/app/assets/javascripts/application.js +0 -9
  26. data/test/dummy/app/assets/stylesheets/application.css +0 -7
  27. data/test/dummy/app/controllers/application_controller.rb +0 -3
  28. data/test/dummy/app/helpers/application_helper.rb +0 -2
  29. data/test/dummy/app/models/default_model.rb +0 -3
  30. data/test/dummy/app/models/prefix_model.rb +0 -3
  31. data/test/dummy/app/models/single_character_model.rb +0 -3
  32. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  33. data/test/dummy/config.ru +0 -4
  34. data/test/dummy/config/application.rb +0 -45
  35. data/test/dummy/config/boot.rb +0 -10
  36. data/test/dummy/config/database.yml +0 -25
  37. data/test/dummy/config/environment.rb +0 -5
  38. data/test/dummy/config/environments/development.rb +0 -30
  39. data/test/dummy/config/environments/production.rb +0 -60
  40. data/test/dummy/config/environments/test.rb +0 -39
  41. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  42. data/test/dummy/config/initializers/inflections.rb +0 -10
  43. data/test/dummy/config/initializers/mime_types.rb +0 -5
  44. data/test/dummy/config/initializers/secret_token.rb +0 -7
  45. data/test/dummy/config/initializers/session_store.rb +0 -8
  46. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  47. data/test/dummy/config/locales/en.yml +0 -5
  48. data/test/dummy/config/routes.rb +0 -58
  49. data/test/dummy/db/development.sqlite3 +0 -0
  50. data/test/dummy/db/migrate/20120204224641_create_default_models.rb +0 -9
  51. data/test/dummy/db/migrate/20120204235832_create_prefix_models.rb +0 -9
  52. data/test/dummy/db/migrate/20120205000853_create_single_character_models.rb +0 -9
  53. data/test/dummy/db/schema.rb +0 -34
  54. data/test/dummy/db/test.sqlite3 +0 -0
  55. data/test/dummy/log/development.log +0 -269
  56. data/test/dummy/log/test.log +0 -1186
  57. data/test/dummy/public/404.html +0 -26
  58. data/test/dummy/public/422.html +0 -26
  59. data/test/dummy/public/500.html +0 -26
  60. data/test/dummy/public/favicon.ico +0 -0
  61. data/test/dummy/script/rails +0 -6
  62. data/test/dummy/test/fixtures/default_models.yml +0 -7
  63. data/test/dummy/test/fixtures/prefix_models.yml +0 -7
  64. data/test/dummy/test/fixtures/simple_models.yml +0 -7
  65. data/test/dummy/test/fixtures/single_character_models.yml +0 -7
  66. data/test/dummy/test/unit/default_model_test.rb +0 -7
  67. data/test/dummy/test/unit/prefix_model_test.rb +0 -7
  68. data/test/dummy/test/unit/single_character_model_test.rb +0 -7
  69. data/test/randomized_field_test.rb +0 -69
  70. data/test/test_helper.rb +0 -10
@@ -1,26 +0,0 @@
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>
@@ -1,26 +0,0 @@
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>
@@ -1,26 +0,0 @@
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
@@ -1,6 +0,0 @@
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'
@@ -1,7 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- dummy_field: MyString
5
-
6
- two:
7
- dummy_field: MyString
@@ -1,7 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- dummy_field: MyString
5
-
6
- two:
7
- dummy_field: MyString
@@ -1,7 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- dummy_field: MyString
5
-
6
- two:
7
- dummy_field: MyString
@@ -1,7 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- dummy_field: MyString
5
-
6
- two:
7
- dummy_field: MyString
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class DefaultModelTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PrefixModelTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SingleCharacterModelTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,69 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RandomizedFieldTest < ActiveSupport::TestCase
4
- def setup
5
- @models = {
6
- :default_model => DefaultModel.create,
7
- :prefix_model => PrefixModel.create,
8
- :single_character_model => SingleCharacterModel.create
9
- }
10
- end
11
-
12
- def teardown
13
- @models.each { |(model_name, model)| model.destroy }
14
- end
15
-
16
- test "truth" do
17
- assert_kind_of Module, RandomizedField
18
- assert_kind_of Module, RandomizedField::Base
19
- assert_kind_of Class, RandomizedField::Randomizer
20
- end
21
-
22
- test "DefaultModel should have the default randomized field options set" do
23
- model = @models[:default_model]
24
-
25
- field_name = model.class.randomized_field_name
26
- options = model.class.randomized_field_options
27
-
28
- assert_equal options[:prefix], RandomizedField::DEFAULTS[:prefix]
29
- assert_equal options[:length], RandomizedField::DEFAULTS[:length]
30
- assert_equal options[:valid_characters], RandomizedField::DEFAULTS[:valid_characters]
31
- end
32
-
33
- test "The instance of DefaultModel should have the default random field values set" do
34
- model = @models[:default_model]
35
-
36
- field_name = model.class.randomized_field_name
37
-
38
- assert_respond_to model, field_name
39
- assert model[field_name].present?
40
- assert_equal model[field_name].length, RandomizedField::DEFAULTS[:length]
41
-
42
- assert_match /^#{RandomizedField::DEFAULTS[:prefix]}[#{RandomizedField::DEFAULTS[:valid_characters].join("|")}]+$/,
43
- model[field_name]
44
- end
45
-
46
- test "PrefixModel should have a randomized field with a prefix" do
47
- model = @models[:prefix_model]
48
-
49
- field_name = model.class.randomized_field_name
50
- options = model.class.randomized_field_options
51
-
52
- assert_operator options[:prefix].length, :>, 0
53
- assert_match /^#{options[:prefix]}/, model[field_name]
54
- assert_equal model[field_name].length, options[:prefix].length + options[:length]
55
- end
56
-
57
- test "SingleCharacterModel should have a randomized field containing a single character" do
58
- model = @models[:single_character_model]
59
-
60
- field_name = model.class.randomized_field_name
61
- options = model.class.randomized_field_options
62
-
63
- assert_equal options[:valid_characters].length, 1
64
-
65
- character = options[:valid_characters].first
66
-
67
- assert_equal model[field_name], character*options[:length]
68
- end
69
- end
@@ -1,10 +0,0 @@
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
- Rails.backtrace_cleaner.remove_silencers!
8
-
9
- # Load support files
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }