thermometer 0.0.2

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +32 -0
  5. data/lib/generators/thermometer/install_generator.rb +14 -0
  6. data/lib/generators/thermometer/templates/thermometer.yml +76 -0
  7. data/lib/tasks/thermometer_tasks.rake +4 -0
  8. data/lib/thermometer.rb +31 -0
  9. data/lib/thermometer/active_record.rb +50 -0
  10. data/lib/thermometer/configuration.rb +116 -0
  11. data/lib/thermometer/evaluate.rb +87 -0
  12. data/lib/thermometer/temperature.rb +90 -0
  13. data/lib/thermometer/version.rb +3 -0
  14. data/test/dummy/README.rdoc +28 -0
  15. data/test/dummy/Rakefile +6 -0
  16. data/test/dummy/app/assets/javascripts/application.js +13 -0
  17. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  18. data/test/dummy/app/controllers/application_controller.rb +5 -0
  19. data/test/dummy/app/helpers/application_helper.rb +2 -0
  20. data/test/dummy/app/models/User.rb +28 -0
  21. data/test/dummy/app/models/message.rb +3 -0
  22. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/test/dummy/bin/bundle +3 -0
  24. data/test/dummy/bin/rails +4 -0
  25. data/test/dummy/bin/rake +4 -0
  26. data/test/dummy/config.ru +4 -0
  27. data/test/dummy/config/application.rb +25 -0
  28. data/test/dummy/config/boot.rb +5 -0
  29. data/test/dummy/config/database.yml +25 -0
  30. data/test/dummy/config/environment.rb +5 -0
  31. data/test/dummy/config/environments/development.rb +29 -0
  32. data/test/dummy/config/environments/production.rb +80 -0
  33. data/test/dummy/config/environments/test.rb +36 -0
  34. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  36. data/test/dummy/config/initializers/inflections.rb +16 -0
  37. data/test/dummy/config/initializers/mime_types.rb +5 -0
  38. data/test/dummy/config/initializers/secret_token.rb +12 -0
  39. data/test/dummy/config/initializers/session_store.rb +3 -0
  40. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  41. data/test/dummy/config/locales/en.yml +23 -0
  42. data/test/dummy/config/routes.rb +56 -0
  43. data/test/dummy/config/thermometer.yml +60 -0
  44. data/test/dummy/db/development.sqlite3 +0 -0
  45. data/test/dummy/db/migrate/20140213183243_create_users.rb +8 -0
  46. data/test/dummy/db/migrate/20140214001211_create_messages.rb +9 -0
  47. data/test/dummy/db/schema.rb +31 -0
  48. data/test/dummy/db/seeds.rb +13 -0
  49. data/test/dummy/db/test.sqlite3 +0 -0
  50. data/test/dummy/lib/helper_methods.rb +4 -0
  51. data/test/dummy/log/development.log +10949 -0
  52. data/test/dummy/log/test.log +26820 -0
  53. data/test/dummy/public/404.html +58 -0
  54. data/test/dummy/public/422.html +58 -0
  55. data/test/dummy/public/500.html +57 -0
  56. data/test/dummy/public/favicon.ico +0 -0
  57. data/test/dummy/test/fixtures/messages.yml +29 -0
  58. data/test/dummy/test/fixtures/users.yml +12 -0
  59. data/test/dummy/test/models/user_test.rb +175 -0
  60. data/test/dummy/test/test_helper.rb +20 -0
  61. data/test/test_helper.rb +30 -0
  62. data/test/thermometer_test.rb +8 -0
  63. metadata +183 -0
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,29 @@
1
+ <% require 'faker' %>
2
+ <% require 'helper_methods' %>
3
+ <% @users = (1..50).to_a %>
4
+ <% @owners = @users %>
5
+
6
+
7
+
8
+
9
+ <% (@owners.size).times do |n| %>
10
+
11
+ <% @owner = @owners.delete(@owners.sample) %>
12
+
13
+ message0_<%= n %>:
14
+ content: <%= Faker::Lorem.words 5 %>
15
+ created_at: <%= @created_at = time_rand(Time.now-6.months) %>
16
+ updated_at: <%= time_rand(@created_at) %>
17
+ user: <%= "user_#{@owner}" %>
18
+ message1_<%= n %>:
19
+ content: <%= Faker::Lorem.words 5 %>
20
+ created_at: <%= @created_at = time_rand(Time.now-6.months) %>
21
+ updated_at: <%= time_rand(@created_at) %>
22
+ user: <%= "user_#{@owner}" %>
23
+ message2_<%= n %>:
24
+ content: <%= Faker::Lorem.words 5 %>
25
+ created_at: <%= @created_at = time_rand(Time.now-6.months) %>
26
+ updated_at: <%= time_rand(@created_at) %>
27
+ user: <%= "user_#{@owner}" %>
28
+
29
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% require 'faker' %>
2
+ <% require 'helper_methods' %>
3
+ <% @users = (1..50).to_a %>
4
+
5
+
6
+
7
+ <% (@users.size).times do |n| %>
8
+ user_<%= n %>:
9
+ name: <%= Faker::Name.name %>
10
+ created_at: <%= @created_at = time_rand(Time.now-6.months) %>
11
+ updated_at: <%= time_rand(@created_at) %>
12
+ <% end %>
@@ -0,0 +1,175 @@
1
+ require 'test_helper'
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+
5
+ test "instance should respond to has_temperature" do
6
+ assert users(:user_1).respond_to?(:has_temperature)
7
+ end
8
+
9
+ test "instance should respond to has_temperature?" do
10
+ assert users(:user_1).respond_to?(:has_temperature?)
11
+ end
12
+
13
+ test "instance should respond to is_colder_than?" do
14
+ assert users(:user_1).respond_to?(:is_colder_than?)
15
+ end
16
+
17
+ test "instance should respond to is_warmer_than?" do
18
+ assert users(:user_1).respond_to?(:is_warmer_than?)
19
+ end
20
+
21
+ test "instance association messages should respond to has_temperature" do
22
+ assert users(:user_1).messages.respond_to?(:has_temperature)
23
+ end
24
+
25
+ test "instance association messages should respond to has_temperature?" do
26
+ assert users(:user_1).messages.respond_to?(:has_temperature?)
27
+ end
28
+
29
+ test "instance association messages should respond to is_colder_than?" do
30
+ assert users(:user_1).messages.respond_to?(:is_colder_than?)
31
+ end
32
+
33
+ test "instance association messages should respond to is_warmer_than?" do
34
+ assert users(:user_1).messages.respond_to?(:is_warmer_than?)
35
+ end
36
+
37
+ test "Class should respond to has_temperature" do
38
+ assert User.respond_to?(:has_temperature)
39
+ end
40
+
41
+ test "Class should respond to has_temperature?" do
42
+ assert User.respond_to?(:has_temperature?)
43
+ end
44
+
45
+ test "Class should respond to is_colder_than?" do
46
+ assert User.respond_to?(:is_colder_than?)
47
+ end
48
+
49
+ test "Class should respond to is_warmer_than?" do
50
+ assert User.respond_to?(:is_warmer_than?)
51
+ end
52
+
53
+ ###
54
+
55
+ test "instance should return a value from has_temperature" do
56
+ assert_not_nil users(:user_1).has_temperature
57
+ end
58
+
59
+ test "instance should return a value from has_temperature?" do
60
+ assert_not_nil users(:user_1).has_temperature? :warm
61
+ end
62
+
63
+ test "instance should return a value from is_colder_than?" do
64
+ assert_not_nil users(:user_1).is_colder_than? :warm
65
+ end
66
+
67
+ test "instance should return a value from is_warmer_than?" do
68
+ assert_not_nil users(:user_1).is_warmer_than? :warm
69
+ end
70
+
71
+ test "instance association messages should return a value from has_temperature" do
72
+ assert_not_nil users(:user_1).messages.has_temperature
73
+ end
74
+
75
+ test "instance association messages should return a value from has_temperature?" do
76
+ assert_not_nil users(:user_1).messages.has_temperature? :warm
77
+ end
78
+
79
+ test "instance association messages should return a value from is_colder_than?" do
80
+ assert_not_nil users(:user_1).messages.is_colder_than? :warm
81
+ end
82
+
83
+ test "instance association messages should return a value from is_warmer_than?" do
84
+ assert_not_nil users(:user_1).messages.is_warmer_than? :warm
85
+ end
86
+
87
+ test "Class should return a value from has_temperature" do
88
+ assert_not_nil User.has_temperature
89
+ end
90
+
91
+ test "Class should return a value from has_temperature?" do
92
+ assert_not_nil User.has_temperature? :warm
93
+ end
94
+
95
+ test "Class should return a value from is_colder_than?" do
96
+ assert_not_nil User.is_colder_than? :warm
97
+ end
98
+
99
+ test "Class should return a value from is_warmer_than?" do
100
+ assert_not_nil User.is_warmer_than? :warm
101
+ end
102
+
103
+ ### overides for options
104
+
105
+ test "instance should return a value from has_temperature with options" do
106
+ assert_not_nil users(:user_1).has_temperature :sample => 3 , :order => 'asc'
107
+ end
108
+
109
+ test "instance should return a value from has_temperature? with options" do
110
+ assert_not_nil users(:user_1).has_temperature? :warm , :sample => 3
111
+ end
112
+
113
+ test "instance should return a value from is_colder_than? with options" do
114
+ assert_not_nil users(:user_1).is_colder_than? :warm , :order => 'asc'
115
+ end
116
+
117
+ test "instance should return a value from is_warmer_than? with options" do
118
+ assert_not_nil users(:user_1).is_warmer_than? :warm , :sample => 3
119
+ end
120
+
121
+ test "instance association messages should return a value from has_temperature with options" do
122
+ assert_not_nil users(:user_1).messages.has_temperature :date => :created_at
123
+ end
124
+
125
+ test "instance association messages should return a value from has_temperature? with options" do
126
+ assert_not_nil users(:user_1).messages.has_temperature? :warm , :sample => 3 , :order => 'asc'
127
+ end
128
+
129
+ test "instance association messages should return a value from is_colder_than? with options" do
130
+ assert_not_nil users(:user_1).messages.is_colder_than? :warm , :sample => 3
131
+ end
132
+
133
+ test "instance association messages should return a value from is_warmer_than? with options" do
134
+ assert_not_nil users(:user_1).messages.is_warmer_than? :warm , :order => 'asc'
135
+ end
136
+
137
+ test "Class should return a value from has_temperature with options" do
138
+ assert_not_nil User.has_temperature :date => :created_at
139
+ end
140
+
141
+ test "Class should return a value from has_temperature? with options" do
142
+ assert_not_nil User.has_temperature? :warm , :explicit => true, :sample => 3
143
+ end
144
+
145
+ test "Class should return a value from is_colder_than? with options" do
146
+ assert_not_nil User.is_colder_than? :warm , :sample => 3 , :order => 'asc'
147
+ end
148
+
149
+ test "Class should return a value from is_warmer_than? with options" do
150
+ assert_not_nil User.is_warmer_than? :warm , :explicit => true, :order => 'asc'
151
+ end
152
+
153
+ test "Class should return a value from is_warmer_than? with NO options" do
154
+ assert_not_nil User.is_warmer_than? :warm , :explicit => true
155
+ end
156
+
157
+ ### calls wrap up
158
+
159
+ test "Instance should return a value from has_temperatures" do
160
+ assert_not_nil users(:user_1).has_temperatures
161
+ end
162
+
163
+ ### scopes
164
+
165
+ test "Class scope should return a value from has_temperatures" do
166
+ assert_not_nil User.name_like("Ms.").has_temperature
167
+ end
168
+
169
+ test "Instance scope should return a value from has_temperatures" do
170
+ assert_not_nil users(:user_1).last_five_messages.has_temperature
171
+ end
172
+
173
+
174
+
175
+ end
@@ -0,0 +1,20 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ require File.expand_path('../../config/environment', __FILE__)
7
+ require 'rails/test_help'
8
+
9
+ class ActiveSupport::TestCase
10
+ ActiveRecord::Migration.check_pending!
11
+
12
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
13
+ #
14
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
15
+ # -- they do not yet inherit this setting
16
+ fixtures :all
17
+
18
+ # Add more helper methods to be used by all tests here...
19
+ end
20
+
@@ -0,0 +1,30 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
8
+ require "rails/test_help"
9
+
10
+
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+
13
+ # Load support files
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
15
+ Dir.glob("#{File.dirname(__FILE__)}/dummy/app/models/*.rb").sort.each { |file| require_dependency file }
16
+
17
+
18
+
19
+ # see https://github.com/rails/rails/issues/4971 for why we cant test this method
20
+ #if ActiveSupport::TestCase.method_defined?(:fixture_path=)
21
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../dummy/test/fixtures", __FILE__)
22
+ #end
23
+
24
+ # Load fixtures from the engine
25
+ class ActiveSupport::TestCase
26
+
27
+ set_fixture_class :users => "User"
28
+
29
+ fixtures :all
30
+ end