alarm_it 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/CHANGELOG +0 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +33 -0
- data/Rakefile +18 -0
- data/VERSION +1 -0
- data/alarm_it.gemspec +25 -0
- data/alarm_it.sqlite3 +0 -0
- data/generators/alarm_it_migration/alarm_it_migration_generator.rb +7 -0
- data/generators/alarm_it_migration/templates/migration.rb +21 -0
- data/lib/alarm_it.rb +20 -0
- data/lib/alarm_it/alarm.rb +62 -0
- data/lib/alarm_it/alarmable.rb +13 -0
- data/lib/alarm_it/alarmer.rb +21 -0
- data/lib/alarm_it/alarms_helper.rb +17 -0
- data/lib/alarm_it/version.rb +3 -0
- data/lib/generators/alarm_it/migration/migration_generator.rb +32 -0
- data/lib/generators/alarm_it/migration/templates/active_record/migration.rb +21 -0
- data/rails/init.rb +1 -0
- data/spec/alarm_it/alarm_spec.rb +76 -0
- data/spec/alarm_it/alarmable_spec.rb +8 -0
- data/spec/alarm_it/alarmer_spec.rb +24 -0
- data/spec/database.yml.sample +17 -0
- data/spec/debug.log +8246 -0
- data/spec/models.rb +35 -0
- data/spec/schema.rb +25 -0
- data/spec/spec_helper.rb +60 -0
- data/uninstall.rb +1 -0
- metadata +188 -0
data/spec/models.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class Alarmable < ActiveRecord::Base
|
2
|
+
acts_as_alarmable
|
3
|
+
end
|
4
|
+
|
5
|
+
class Alarmer < ActiveRecord::Base
|
6
|
+
acts_as_alarmer
|
7
|
+
end
|
8
|
+
|
9
|
+
# class AlarmableModel < ActiveRecord::Base
|
10
|
+
# acts_as_alarmable
|
11
|
+
# has_many :unalarmable_models
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# class CachedModel < ActiveRecord::Base
|
15
|
+
# acts_as_alarmable
|
16
|
+
# end
|
17
|
+
|
18
|
+
# class OtherAlarmableModel < ActiveRecord::Base
|
19
|
+
# acts_as_alarmable
|
20
|
+
# end
|
21
|
+
|
22
|
+
# class InheritingAlarmableModel < AlarmableModel
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# class AlteredInheritingAlarmableModel < AlarmableModel
|
26
|
+
# acts_as_alarmable
|
27
|
+
# end
|
28
|
+
|
29
|
+
# class AlarmerUser < ActiveRecord::Base
|
30
|
+
# acts_as_alarmer
|
31
|
+
# end
|
32
|
+
|
33
|
+
# class UnalarmableModel < ActiveRecord::Base
|
34
|
+
# belongs_to :alarmable_model
|
35
|
+
# end
|
data/spec/schema.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
ActiveRecord::Schema.define :version => 0 do
|
2
|
+
create_table :alarms do |t|
|
3
|
+
t.string :name
|
4
|
+
t.text :description
|
5
|
+
t.string :alarmable_type
|
6
|
+
t.integer :alarmable_id
|
7
|
+
t.datetime :set_at
|
8
|
+
t.datetime :repeat_at
|
9
|
+
t.datetime :inactivated_at
|
10
|
+
t.string :alarmer_type
|
11
|
+
t.integer :alarmer_id
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
add_index :alarms, [:alarmable_type, :alarmable_id]
|
16
|
+
add_index :alarms, [:alarmer_type, :alarmer_id]
|
17
|
+
|
18
|
+
create_table :alarmables, :force => true do |t|
|
19
|
+
t.column :name, :string
|
20
|
+
end
|
21
|
+
|
22
|
+
create_table :alarmers, :force => true do |t|
|
23
|
+
t.column :name, :string
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "rubygems"
|
5
|
+
require "bundler"
|
6
|
+
|
7
|
+
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.5")
|
8
|
+
raise RuntimeError, "Your bundler version is too old." +
|
9
|
+
"Run `gem install bundler` to upgrade."
|
10
|
+
end
|
11
|
+
|
12
|
+
# Set up load paths for all bundled gems
|
13
|
+
Bundler.setup
|
14
|
+
rescue Bundler::GemNotFound
|
15
|
+
raise RuntimeError, "Bundler couldn't find some gems." +
|
16
|
+
"Did you run \`bundle install\`?"
|
17
|
+
end
|
18
|
+
|
19
|
+
Bundler.require
|
20
|
+
require File.expand_path('../../lib/alarm_it', __FILE__)
|
21
|
+
require 'shoulda/matchers/integrations/rspec'
|
22
|
+
|
23
|
+
# unless [].respond_to?(:freq)
|
24
|
+
# class Array
|
25
|
+
# def freq
|
26
|
+
# k=Hash.new(0)
|
27
|
+
# each {|e| k[e]+=1}
|
28
|
+
# k
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
|
33
|
+
ENV['DB'] ||= 'mysql'
|
34
|
+
|
35
|
+
database_yml = File.expand_path('../database.yml', __FILE__)
|
36
|
+
if File.exists?(database_yml)
|
37
|
+
active_record_configuration = YAML.load_file(database_yml)[ENV['DB']]
|
38
|
+
|
39
|
+
ActiveRecord::Base.establish_connection(active_record_configuration)
|
40
|
+
# ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
|
41
|
+
|
42
|
+
ActiveRecord::Base.silence do
|
43
|
+
ActiveRecord::Migration.verbose = true
|
44
|
+
|
45
|
+
# load(File.dirname(__FILE__) + '/schema.rb')
|
46
|
+
load(File.dirname(__FILE__) + '/models.rb')
|
47
|
+
end
|
48
|
+
|
49
|
+
else
|
50
|
+
raise "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample"
|
51
|
+
end
|
52
|
+
|
53
|
+
def clean_database!
|
54
|
+
models = [AlarmIt::Alarm, Alarmable, Alarmer]
|
55
|
+
models.each do |model|
|
56
|
+
ActiveRecord::Base.connection.execute "DELETE FROM #{model.table_name}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
clean_database!
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alarm_it
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 0.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Yannis Jaquet
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-24 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rails
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 977940598
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
- 1
|
33
|
+
- 0
|
34
|
+
- rc1
|
35
|
+
version: 3.1.0.rc1
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: mysql2
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 23
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 3
|
50
|
+
- 2
|
51
|
+
version: 0.3.2
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: will_paginate
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: -1876988247
|
63
|
+
segments:
|
64
|
+
- 3
|
65
|
+
- 0
|
66
|
+
- pre2
|
67
|
+
version: 3.0.pre2
|
68
|
+
type: :runtime
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 23
|
79
|
+
segments:
|
80
|
+
- 2
|
81
|
+
- 6
|
82
|
+
- 0
|
83
|
+
version: 2.6.0
|
84
|
+
type: :development
|
85
|
+
version_requirements: *id004
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: shoulda-matchers
|
88
|
+
prerelease: false
|
89
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
type: :development
|
99
|
+
version_requirements: *id005
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: factory_girl
|
102
|
+
prerelease: false
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 3
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
version: "0"
|
112
|
+
type: :development
|
113
|
+
version_requirements: *id006
|
114
|
+
description: Associate alarms to any model
|
115
|
+
email: suvar3_7@mac.com
|
116
|
+
executables: []
|
117
|
+
|
118
|
+
extensions: []
|
119
|
+
|
120
|
+
extra_rdoc_files: []
|
121
|
+
|
122
|
+
files:
|
123
|
+
- .gitignore
|
124
|
+
- .rspec
|
125
|
+
- CHANGELOG
|
126
|
+
- Gemfile
|
127
|
+
- MIT-LICENSE
|
128
|
+
- README.rdoc
|
129
|
+
- Rakefile
|
130
|
+
- VERSION
|
131
|
+
- alarm_it.gemspec
|
132
|
+
- alarm_it.sqlite3
|
133
|
+
- generators/alarm_it_migration/alarm_it_migration_generator.rb
|
134
|
+
- generators/alarm_it_migration/templates/migration.rb
|
135
|
+
- lib/alarm_it.rb
|
136
|
+
- lib/alarm_it/alarm.rb
|
137
|
+
- lib/alarm_it/alarmable.rb
|
138
|
+
- lib/alarm_it/alarmer.rb
|
139
|
+
- lib/alarm_it/alarms_helper.rb
|
140
|
+
- lib/alarm_it/version.rb
|
141
|
+
- lib/generators/alarm_it/migration/migration_generator.rb
|
142
|
+
- lib/generators/alarm_it/migration/templates/active_record/migration.rb
|
143
|
+
- rails/init.rb
|
144
|
+
- spec/alarm_it/alarm_spec.rb
|
145
|
+
- spec/alarm_it/alarmable_spec.rb
|
146
|
+
- spec/alarm_it/alarmer_spec.rb
|
147
|
+
- spec/database.yml.sample
|
148
|
+
- spec/debug.log
|
149
|
+
- spec/models.rb
|
150
|
+
- spec/schema.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
- uninstall.rb
|
153
|
+
has_rdoc: true
|
154
|
+
homepage:
|
155
|
+
licenses: []
|
156
|
+
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
hash: 3
|
168
|
+
segments:
|
169
|
+
- 0
|
170
|
+
version: "0"
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
hash: 3
|
177
|
+
segments:
|
178
|
+
- 0
|
179
|
+
version: "0"
|
180
|
+
requirements: []
|
181
|
+
|
182
|
+
rubyforge_project:
|
183
|
+
rubygems_version: 1.3.7
|
184
|
+
signing_key:
|
185
|
+
specification_version: 3
|
186
|
+
summary: Associate alarms to any model
|
187
|
+
test_files: []
|
188
|
+
|