scratch 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 (66) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/scratch/application.js +15 -0
  5. data/app/assets/stylesheets/scratch/application.css +13 -0
  6. data/app/controllers/scratch/application_controller.rb +4 -0
  7. data/app/helpers/scratch/application_helper.rb +4 -0
  8. data/app/views/layouts/scratch/application.html.erb +14 -0
  9. data/config/routes.rb +2 -0
  10. data/lib/scratch.rb +12 -0
  11. data/lib/scratch/concerns.rb +3 -0
  12. data/lib/scratch/concerns/nilify.rb +21 -0
  13. data/lib/scratch/concerns/normalize.rb +72 -0
  14. data/lib/scratch/concerns/stripify.rb +19 -0
  15. data/lib/scratch/core_ext.rb +3 -0
  16. data/lib/scratch/core_ext/array.rb +10 -0
  17. data/lib/scratch/core_ext/hash.rb +30 -0
  18. data/lib/scratch/engine.rb +14 -0
  19. data/lib/scratch/options.rb +12 -0
  20. data/lib/scratch/version.rb +3 -0
  21. data/lib/tasks/scratch_tasks.rake +4 -0
  22. data/test/dummy/README.rdoc +261 -0
  23. data/test/dummy/Rakefile +7 -0
  24. data/test/dummy/app/assets/javascripts/application.js +15 -0
  25. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  26. data/test/dummy/app/controllers/application_controller.rb +3 -0
  27. data/test/dummy/app/helpers/application_helper.rb +2 -0
  28. data/test/dummy/app/models/nilify_test_model.rb +7 -0
  29. data/test/dummy/app/models/stripify_test_model.rb +6 -0
  30. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  31. data/test/dummy/config.ru +4 -0
  32. data/test/dummy/config/application.rb +61 -0
  33. data/test/dummy/config/boot.rb +10 -0
  34. data/test/dummy/config/database.yml +25 -0
  35. data/test/dummy/config/environment.rb +5 -0
  36. data/test/dummy/config/environments/development.rb +37 -0
  37. data/test/dummy/config/environments/production.rb +67 -0
  38. data/test/dummy/config/environments/test.rb +37 -0
  39. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  40. data/test/dummy/config/initializers/inflections.rb +15 -0
  41. data/test/dummy/config/initializers/mime_types.rb +5 -0
  42. data/test/dummy/config/initializers/secret_token.rb +7 -0
  43. data/test/dummy/config/initializers/session_store.rb +8 -0
  44. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  45. data/test/dummy/config/locales/en.yml +5 -0
  46. data/test/dummy/config/routes.rb +4 -0
  47. data/test/dummy/db/development.sqlite3 +0 -0
  48. data/test/dummy/db/migrate/20120226002304_create_nilify_test_models.rb +9 -0
  49. data/test/dummy/db/migrate/20120226052737_create_stripify_test_models.rb +8 -0
  50. data/test/dummy/db/schema.rb +27 -0
  51. data/test/dummy/db/test.sqlite3 +0 -0
  52. data/test/dummy/log/development.log +115 -0
  53. data/test/dummy/log/test.log +282 -0
  54. data/test/dummy/public/404.html +26 -0
  55. data/test/dummy/public/422.html +26 -0
  56. data/test/dummy/public/500.html +25 -0
  57. data/test/dummy/public/favicon.ico +0 -0
  58. data/test/dummy/script/rails +6 -0
  59. data/test/integration/navigation_test.rb +10 -0
  60. data/test/test_helper.rb +10 -0
  61. data/test/unit/concerns/nilify_test.rb +34 -0
  62. data/test/unit/concerns/stripify_test.rb +25 -0
  63. data/test/unit/core_ext/array_test.rb +37 -0
  64. data/test/unit/core_ext/hash_test.rb +29 -0
  65. data/test/unit/scratch_test.rb +7 -0
  66. metadata +182 -0
@@ -0,0 +1,25 @@
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
+ </div>
24
+ </body>
25
+ </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,10 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ end
10
+
@@ -0,0 +1,10 @@
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 }
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../../test_helper.rb'
4
+
5
+ class Scratch::Concerns::NilifyTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @entity = NilifyTestModel.new foo: '', bar: '', baz: 1
9
+ end
10
+
11
+ def teardown
12
+ @entity.delete
13
+ end
14
+
15
+ def test_callbacks_methods_are_defined
16
+ assert @entity.respond_to? :nilify_before_validation_if_blank?
17
+ assert @entity.respond_to? :nilify_before_save_if_odd?
18
+ end
19
+
20
+ def test_effect_of_triggering_validation_callback
21
+ @entity.valid?
22
+ assert_equal '' , @entity.foo
23
+ assert_equal nil , @entity.bar
24
+ assert_equal 1 , @entity.baz
25
+ end
26
+
27
+ def test_effect_of_triggering_save_callback
28
+ @entity.save
29
+ assert_equal '' , @entity.foo
30
+ assert_equal nil , @entity.bar
31
+ assert_equal nil , @entity.baz
32
+ end
33
+
34
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../../test_helper.rb'
4
+
5
+ class Scratch::Concerns::StripifyTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @entity = StripifyTestModel.new foo: ' ', bar: ' '
9
+ end
10
+
11
+ def teardown
12
+ @entity.delete
13
+ end
14
+
15
+ def test_callbacks_methods_are_defined
16
+ assert @entity.respond_to? :stripify_before_validation
17
+ end
18
+
19
+ def test_effect_of_triggering_validation_callback
20
+ @entity.valid?
21
+ assert_equal ' ' , @entity.foo
22
+ assert_equal '' , @entity.bar
23
+ end
24
+
25
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../../test_helper.rb'
4
+
5
+ class Scratch::CoreExt::ArrayTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @sep = $,
9
+ $, = ', '
10
+ end
11
+
12
+ def teardown
13
+ $, = @sep
14
+ end
15
+
16
+ def test_strip_join_ignore_nils
17
+ assert_equal '2, 3', [nil, 2, 3].strip_join
18
+ assert_equal '1, 3', [1, nil, 3].strip_join
19
+ assert_equal '1, 2', [1, 2, nil].strip_join
20
+ end
21
+
22
+ def test_strip_join_ignore_empty_strings
23
+ assert_equal '2, 3', ['', 2, 3].strip_join
24
+ assert_equal '1, 3', [1, '', 3].strip_join
25
+ assert_equal '1, 2', [1, 2, ''].strip_join
26
+ end
27
+
28
+ def test_strip_join_strip_strings
29
+ assert_equal 'foo', [' foo '].strip_join
30
+ end
31
+
32
+ def test_strip_join_behave_as_join
33
+ a = (1..1000000).to_a
34
+ assert_equal a.join, a.strip_join
35
+ end
36
+
37
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../../test_helper.rb'
4
+
5
+ class Scratch::CoreExt::HashTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @h = { a: [1, 2, 3], b: [4, 5] }
9
+ @is = { 1 => :a, 2 => :a, 3 => :a, 4 => :b, 5 => :b }
10
+ end
11
+
12
+ def test_fetch_or
13
+ assert_equal :a, @is.fetch_or(1)
14
+ assert_equal :b, @is.fetch_or(7, 6, 5)
15
+ assert_equal :c, @is.fetch_or(9, 8, default: :c)
16
+ assert_raise(KeyError) { @is.fetch_or(10) }
17
+ end
18
+
19
+ def test_invert_splat
20
+ assert_equal @is, @h.invert_splat
21
+ end
22
+
23
+ def test_invert_splat
24
+ h = @h.merge c: 6
25
+ is = @is.merge 6 => :c
26
+ assert_equal is, h.invert_splat
27
+ end
28
+
29
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ScratchTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, Scratch
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scratch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nicolas Buduroi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &21429620 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *21429620
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &21428600 !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: *21428600
36
+ description: A plugin to relieve from some Rails itches.
37
+ email:
38
+ - nbuduroi@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - app/helpers/scratch/application_helper.rb
44
+ - app/assets/stylesheets/scratch/application.css
45
+ - app/assets/javascripts/scratch/application.js
46
+ - app/views/layouts/scratch/application.html.erb
47
+ - app/controllers/scratch/application_controller.rb
48
+ - config/routes.rb
49
+ - lib/scratch.rb
50
+ - lib/scratch/concerns/nilify.rb
51
+ - lib/scratch/concerns/normalize.rb
52
+ - lib/scratch/concerns/stripify.rb
53
+ - lib/scratch/core_ext.rb
54
+ - lib/scratch/version.rb
55
+ - lib/scratch/core_ext/array.rb
56
+ - lib/scratch/core_ext/hash.rb
57
+ - lib/scratch/concerns.rb
58
+ - lib/scratch/options.rb
59
+ - lib/scratch/engine.rb
60
+ - lib/tasks/scratch_tasks.rake
61
+ - MIT-LICENSE
62
+ - Rakefile
63
+ - README.rdoc
64
+ - test/unit/concerns/nilify_test.rb
65
+ - test/unit/concerns/stripify_test.rb
66
+ - test/unit/core_ext/array_test.rb
67
+ - test/unit/core_ext/hash_test.rb
68
+ - test/unit/scratch_test.rb
69
+ - test/dummy/log/test.log
70
+ - test/dummy/log/development.log
71
+ - test/dummy/README.rdoc
72
+ - test/dummy/config/environments/production.rb
73
+ - test/dummy/config/environments/test.rb
74
+ - test/dummy/config/environments/development.rb
75
+ - test/dummy/config/locales/en.yml
76
+ - test/dummy/config/boot.rb
77
+ - test/dummy/config/application.rb
78
+ - test/dummy/config/routes.rb
79
+ - test/dummy/config/environment.rb
80
+ - test/dummy/config/database.yml
81
+ - test/dummy/config/initializers/session_store.rb
82
+ - test/dummy/config/initializers/mime_types.rb
83
+ - test/dummy/config/initializers/backtrace_silencers.rb
84
+ - test/dummy/config/initializers/wrap_parameters.rb
85
+ - test/dummy/config/initializers/inflections.rb
86
+ - test/dummy/config/initializers/secret_token.rb
87
+ - test/dummy/public/404.html
88
+ - test/dummy/public/500.html
89
+ - test/dummy/public/422.html
90
+ - test/dummy/public/favicon.ico
91
+ - test/dummy/Rakefile
92
+ - test/dummy/script/rails
93
+ - test/dummy/config.ru
94
+ - test/dummy/db/development.sqlite3
95
+ - test/dummy/db/schema.rb
96
+ - test/dummy/db/test.sqlite3
97
+ - test/dummy/db/migrate/20120226002304_create_nilify_test_models.rb
98
+ - test/dummy/db/migrate/20120226052737_create_stripify_test_models.rb
99
+ - test/dummy/app/models/nilify_test_model.rb
100
+ - test/dummy/app/models/stripify_test_model.rb
101
+ - test/dummy/app/helpers/application_helper.rb
102
+ - test/dummy/app/assets/stylesheets/application.css
103
+ - test/dummy/app/assets/javascripts/application.js
104
+ - test/dummy/app/views/layouts/application.html.erb
105
+ - test/dummy/app/controllers/application_controller.rb
106
+ - test/integration/navigation_test.rb
107
+ - test/test_helper.rb
108
+ homepage: http://github.com/budu/Scratch
109
+ licenses: []
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ segments:
121
+ - 0
122
+ hash: -4378836335766716854
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ segments:
130
+ - 0
131
+ hash: -4378836335766716854
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 1.8.10
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: A plugin to relieve from some Rails itches.
138
+ test_files:
139
+ - test/unit/concerns/nilify_test.rb
140
+ - test/unit/concerns/stripify_test.rb
141
+ - test/unit/core_ext/array_test.rb
142
+ - test/unit/core_ext/hash_test.rb
143
+ - test/unit/scratch_test.rb
144
+ - test/dummy/log/test.log
145
+ - test/dummy/log/development.log
146
+ - test/dummy/README.rdoc
147
+ - test/dummy/config/environments/production.rb
148
+ - test/dummy/config/environments/test.rb
149
+ - test/dummy/config/environments/development.rb
150
+ - test/dummy/config/locales/en.yml
151
+ - test/dummy/config/boot.rb
152
+ - test/dummy/config/application.rb
153
+ - test/dummy/config/routes.rb
154
+ - test/dummy/config/environment.rb
155
+ - test/dummy/config/database.yml
156
+ - test/dummy/config/initializers/session_store.rb
157
+ - test/dummy/config/initializers/mime_types.rb
158
+ - test/dummy/config/initializers/backtrace_silencers.rb
159
+ - test/dummy/config/initializers/wrap_parameters.rb
160
+ - test/dummy/config/initializers/inflections.rb
161
+ - test/dummy/config/initializers/secret_token.rb
162
+ - test/dummy/public/404.html
163
+ - test/dummy/public/500.html
164
+ - test/dummy/public/422.html
165
+ - test/dummy/public/favicon.ico
166
+ - test/dummy/Rakefile
167
+ - test/dummy/script/rails
168
+ - test/dummy/config.ru
169
+ - test/dummy/db/development.sqlite3
170
+ - test/dummy/db/schema.rb
171
+ - test/dummy/db/test.sqlite3
172
+ - test/dummy/db/migrate/20120226002304_create_nilify_test_models.rb
173
+ - test/dummy/db/migrate/20120226052737_create_stripify_test_models.rb
174
+ - test/dummy/app/models/nilify_test_model.rb
175
+ - test/dummy/app/models/stripify_test_model.rb
176
+ - test/dummy/app/helpers/application_helper.rb
177
+ - test/dummy/app/assets/stylesheets/application.css
178
+ - test/dummy/app/assets/javascripts/application.js
179
+ - test/dummy/app/views/layouts/application.html.erb
180
+ - test/dummy/app/controllers/application_controller.rb
181
+ - test/integration/navigation_test.rb
182
+ - test/test_helper.rb