rcap-rails-generators 1.3
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.
- data/CHANGELOG.rdoc +25 -0
- data/README.rdoc +248 -0
- data/lib/generators/rcap/migrations/migrations_generator.rb +38 -0
- data/lib/generators/rcap/migrations/templates/alerts_migration.rb +27 -0
- data/lib/generators/rcap/migrations/templates/areas_migration.rb +14 -0
- data/lib/generators/rcap/migrations/templates/infos_migration.rb +33 -0
- data/lib/generators/rcap/migrations/templates/resources_migration.rb +14 -0
- data/lib/generators/rcap/models/models_generator.rb +33 -0
- data/lib/generators/rcap/models/templates/models/alert.rb +365 -0
- data/lib/generators/rcap/models/templates/models/area.rb +156 -0
- data/lib/generators/rcap/models/templates/models/circle.rb +76 -0
- data/lib/generators/rcap/models/templates/models/event_code.rb +20 -0
- data/lib/generators/rcap/models/templates/models/geocode.rb +20 -0
- data/lib/generators/rcap/models/templates/models/info.rb +452 -0
- data/lib/generators/rcap/models/templates/models/parameter.rb +64 -0
- data/lib/generators/rcap/models/templates/models/point.rb +51 -0
- data/lib/generators/rcap/models/templates/models/polygon.rb +75 -0
- data/lib/generators/rcap/models/templates/models/resource.rb +143 -0
- data/lib/generators/rcap/models/templates/modules/rcap.rb +5 -0
- data/lib/generators/rcap/models/templates/modules/validations.rb +116 -0
- data/spec/alert_spec.rb +195 -0
- data/spec/area_spec.rb +179 -0
- data/spec/circle_spec.rb +88 -0
- data/spec/geocode_spec.rb +38 -0
- data/spec/info_spec.rb +270 -0
- data/spec/point_spec.rb +46 -0
- data/spec/polygon_spec.rb +68 -0
- data/spec/resource_spec.rb +156 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/utilities_spec.rb +57 -0
- data/spec/validations_spec.rb +95 -0
- metadata +155 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe( Array ) do
|
4
|
+
describe( 'to_s_for_cap' ) do
|
5
|
+
context( 'with an element containing white space' ) do
|
6
|
+
before( :all ) do
|
7
|
+
@list = [ 'one', 'white space', 'three' ]
|
8
|
+
end
|
9
|
+
|
10
|
+
it( 'should format the list correctly' ) do
|
11
|
+
@list.to_s_for_cap.should == 'one "white space" three'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context( 'without an element containing white space' ) do
|
16
|
+
before( :all ) do
|
17
|
+
@list = [ 'one', 'two', 'three' ]
|
18
|
+
end
|
19
|
+
it( 'should format the list correctly' ) do
|
20
|
+
@list.to_s_for_cap.should == 'one two three'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe( String ) do
|
27
|
+
describe( 'for_cap_list' ) do
|
28
|
+
context( 'with white space' ) do
|
29
|
+
before( :all ) do
|
30
|
+
@string = 'white space'
|
31
|
+
end
|
32
|
+
|
33
|
+
it( 'should format the string correctly' ) do
|
34
|
+
@string.for_cap_list.should == '"white space"'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context( 'without white space' ) do
|
39
|
+
before( :all ) do
|
40
|
+
@string= 'one'
|
41
|
+
end
|
42
|
+
it( 'should format the string correctly' ) do
|
43
|
+
@string.for_cap_list.should == 'one'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe( 'unpack_cap_list' ) do
|
49
|
+
it( 'shoud unpack strings in quotes correctly' ) do
|
50
|
+
'Item1 "Item 2" Item3'.unpack_cap_list.should == [ "Item1", "Item 2", "Item3" ]
|
51
|
+
end
|
52
|
+
|
53
|
+
it( 'should unpack strings correclty' ) do
|
54
|
+
'Item1 Item2 Item3'.unpack_cap_list.should == [ "Item1", "Item2", "Item3" ]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class ObjectWithValidatesCollection
|
4
|
+
include Validation
|
5
|
+
attr_accessor( :collection )
|
6
|
+
validates_collection_of( :collection )
|
7
|
+
def initialize
|
8
|
+
@collection = []
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class DependencyObject
|
13
|
+
include Validation
|
14
|
+
attr_accessor( :dependent_value, :contingent_value )
|
15
|
+
validates_dependency_of( :dependent_value, :on => :contingent_value )
|
16
|
+
end
|
17
|
+
|
18
|
+
class DependencyWithObject
|
19
|
+
include Validation
|
20
|
+
attr_accessor( :dependent_value, :contingent_value )
|
21
|
+
validates_dependency_of( :dependent_value, :on => :contingent_value, :with_value => true )
|
22
|
+
end
|
23
|
+
|
24
|
+
describe( Validation::ClassMethods ) do
|
25
|
+
describe( 'validates_collection_of' ) do
|
26
|
+
before( :each ) do
|
27
|
+
@object_with_collection = ObjectWithValidatesCollection.new
|
28
|
+
end
|
29
|
+
|
30
|
+
it( 'should be valid if all the members are valid' ) do
|
31
|
+
@object_with_collection.collection = Array.new(3){ RCAP::Point.new( :lattitude => 0, :longitude => 0 )}
|
32
|
+
@object_with_collection.should( be_valid )
|
33
|
+
end
|
34
|
+
|
35
|
+
it( 'should not be valid some of the members are invalid' ) do
|
36
|
+
@object_with_collection.collection = Array.new( 2 ){ RCAP::Point.new( :lattitude => 0, :longitude => 0 )} + [ RCAP::Point.new( :lattitude => "not a number", :longitude => 0)]
|
37
|
+
@object_with_collection.should_not( be_valid )
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe( 'validates_dependency_of' ) do
|
42
|
+
context( 'without :with_value' ) do
|
43
|
+
before( :each ) do
|
44
|
+
@object = DependencyObject.new
|
45
|
+
@object.dependent_value = true
|
46
|
+
@object.contingent_value = true
|
47
|
+
@object.should( be_valid )
|
48
|
+
end
|
49
|
+
|
50
|
+
it( 'should not be valid if the contigent value is nil' ) do
|
51
|
+
@object.contingent_value = nil
|
52
|
+
@object.should_not( be_valid )
|
53
|
+
end
|
54
|
+
it( 'should be valid if the dependent value is nil' ) do
|
55
|
+
@object.dependent_value = nil
|
56
|
+
@object.should( be_valid )
|
57
|
+
end
|
58
|
+
it( 'should be valid if both are nil' ) do
|
59
|
+
@object.dependent_value = nil
|
60
|
+
@object.contingent_value = nil
|
61
|
+
@object.should( be_valid )
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context( 'with :with_value' ) do
|
66
|
+
before( :each ) do
|
67
|
+
@object = DependencyWithObject.new
|
68
|
+
@object.dependent_value = true
|
69
|
+
@object.contingent_value = true
|
70
|
+
@object.should( be_valid )
|
71
|
+
end
|
72
|
+
|
73
|
+
it( 'should not be valid if the contigent value is nil' ) do
|
74
|
+
@object.contingent_value = nil
|
75
|
+
@object.should_not( be_valid )
|
76
|
+
end
|
77
|
+
|
78
|
+
it( 'should not be valid if the contingent value is not the required value' ) do
|
79
|
+
@object.contingent_value = 0
|
80
|
+
@object.should_not( be_valid )
|
81
|
+
end
|
82
|
+
|
83
|
+
it( 'should be valid if the dependent value is nil' ) do
|
84
|
+
@object.dependent_value = nil
|
85
|
+
@object.should( be_valid )
|
86
|
+
end
|
87
|
+
|
88
|
+
it( 'should be valid if both are nil' ) do
|
89
|
+
@object.dependent_value = nil
|
90
|
+
@object.contingent_value = nil
|
91
|
+
@object.should( be_valid )
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rcap-rails-generators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: "1.3"
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Farrel Lifson
|
9
|
+
- Pat George
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-03-21 00:00:00 -04:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: bundler
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.0.0
|
25
|
+
type: :development
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: jeweler
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.5.2
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: assistance
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: json
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :runtime
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: uuidtools
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.0
|
69
|
+
type: :runtime
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *id005
|
72
|
+
description: A Ruby API providing parsing and generation of CAP (Common Alerting Protocol) messages for use with Rails.
|
73
|
+
email: pat.george@gmail.com
|
74
|
+
executables: []
|
75
|
+
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
extra_rdoc_files:
|
79
|
+
- CHANGELOG.rdoc
|
80
|
+
- README.rdoc
|
81
|
+
files:
|
82
|
+
- lib/generators/rcap/migrations/migrations_generator.rb
|
83
|
+
- lib/generators/rcap/migrations/templates/alerts_migration.rb
|
84
|
+
- lib/generators/rcap/migrations/templates/areas_migration.rb
|
85
|
+
- lib/generators/rcap/migrations/templates/infos_migration.rb
|
86
|
+
- lib/generators/rcap/migrations/templates/resources_migration.rb
|
87
|
+
- lib/generators/rcap/models/models_generator.rb
|
88
|
+
- lib/generators/rcap/models/templates/models/alert.rb
|
89
|
+
- lib/generators/rcap/models/templates/models/area.rb
|
90
|
+
- lib/generators/rcap/models/templates/models/circle.rb
|
91
|
+
- lib/generators/rcap/models/templates/models/event_code.rb
|
92
|
+
- lib/generators/rcap/models/templates/models/geocode.rb
|
93
|
+
- lib/generators/rcap/models/templates/models/info.rb
|
94
|
+
- lib/generators/rcap/models/templates/models/parameter.rb
|
95
|
+
- lib/generators/rcap/models/templates/models/point.rb
|
96
|
+
- lib/generators/rcap/models/templates/models/polygon.rb
|
97
|
+
- lib/generators/rcap/models/templates/models/resource.rb
|
98
|
+
- lib/generators/rcap/models/templates/modules/rcap.rb
|
99
|
+
- lib/generators/rcap/models/templates/modules/validations.rb
|
100
|
+
- CHANGELOG.rdoc
|
101
|
+
- README.rdoc
|
102
|
+
- spec/alert_spec.rb
|
103
|
+
- spec/area_spec.rb
|
104
|
+
- spec/circle_spec.rb
|
105
|
+
- spec/geocode_spec.rb
|
106
|
+
- spec/info_spec.rb
|
107
|
+
- spec/point_spec.rb
|
108
|
+
- spec/polygon_spec.rb
|
109
|
+
- spec/resource_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- spec/utilities_spec.rb
|
112
|
+
- spec/validations_spec.rb
|
113
|
+
has_rdoc: true
|
114
|
+
homepage: https://github.com/pcg79/RCAP
|
115
|
+
licenses: []
|
116
|
+
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: -3059407052318949872
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: "0"
|
137
|
+
requirements: []
|
138
|
+
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 1.6.2
|
141
|
+
signing_key:
|
142
|
+
specification_version: 3
|
143
|
+
summary: CAP (Common Alerting Protocol) API for Ruby on Rails
|
144
|
+
test_files:
|
145
|
+
- spec/alert_spec.rb
|
146
|
+
- spec/area_spec.rb
|
147
|
+
- spec/circle_spec.rb
|
148
|
+
- spec/geocode_spec.rb
|
149
|
+
- spec/info_spec.rb
|
150
|
+
- spec/point_spec.rb
|
151
|
+
- spec/polygon_spec.rb
|
152
|
+
- spec/resource_spec.rb
|
153
|
+
- spec/spec_helper.rb
|
154
|
+
- spec/utilities_spec.rb
|
155
|
+
- spec/validations_spec.rb
|