acts_as_full_calendar_event 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +83 -0
- data/acts_as_full_calendar_event.gemspec +4 -4
- data/lib/acts_as_full_calendar_event/services/calendar.rb +0 -3
- data/spec/services/calendar_spec.rb +4 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af116ffac55aaca5a7cc9cd857d56aa9804c48cdb00f0bf65a687f4fa03cc9b6
|
4
|
+
data.tar.gz: 91fad8c932c7ae1dfbfb270165c82b72e23c0cd289356f6eee3d113e7d626146
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 327638bbf5b05ff671037a591790212397a1c2620b0c8d5bf7c0c62a04a0d902b519100fa14657b54eb8637031650fa7ee2f3a44c06d81753f3d59d7167a987d
|
7
|
+
data.tar.gz: 4a39fdce0bd44ac7a49e1e90c283205603a8524e7ef83677700d2d042e815e57836e89954b78384e945fb917a03236d1c3f6ca552eb18e2fafa6c07c81888d2f
|
data/Gemfile.lock
CHANGED
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Acts As Full Calendar Event
|
2
|
+
Gem to allow any model to work as event for FullCalendar
|
3
|
+
|
4
|
+
Acts As Full Calendar Event is a Ruby Gem specifically written for Rails/ActiveRecord models.
|
5
|
+
The main goals of this gem are:
|
6
|
+
|
7
|
+
- Allow any model to be used as event for [FullCalendar](https://fullcalendar.io/).
|
8
|
+
- Provide easy-to-use and reusable methods to perform searchs and filter data.
|
9
|
+
- Serialize data for calendar.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
### Supported Ruby and Rails versions
|
14
|
+
|
15
|
+
* Ruby >= 2.3.0
|
16
|
+
* Rails >= 4
|
17
|
+
|
18
|
+
### Install
|
19
|
+
|
20
|
+
Just add the following to your Gemfile to install the latest release.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'acts_as_full_calendar_event', '1.0.1'
|
24
|
+
```
|
25
|
+
|
26
|
+
And follow that up with a ``bundle install``.
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
class SomeEvent < ActiveRecord::Base
|
32
|
+
acts_as_full_calendar_event field_start: :calendar_inicio,
|
33
|
+
field_end: :calendar_fin,
|
34
|
+
field_title: :calendar_title,
|
35
|
+
field_color: "#FF0000",
|
36
|
+
field_text_color: :calendar_text_color,
|
37
|
+
field_url: :url_for_calendar,
|
38
|
+
field_link_data_toggle: :calendar_link_data_toggle,
|
39
|
+
field_link_data_target: :calendar_link_data_target,
|
40
|
+
method_fields: :for_calendario,
|
41
|
+
method_filter_category: :within_calendar_category,
|
42
|
+
method_filter_user: :by_user_id,
|
43
|
+
method_filter_date: :filter_by_date,
|
44
|
+
method_categories: :categories,
|
45
|
+
field_category_class: :category_class
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
### Calendar service
|
50
|
+
|
51
|
+
Initialize as
|
52
|
+
```ruby
|
53
|
+
ActsAsFullCalendarEvent::Calendar.new(params: params).filter
|
54
|
+
```
|
55
|
+
|
56
|
+
params is a hash that must contain:
|
57
|
+
· start (Date)
|
58
|
+
· end (Date)
|
59
|
+
and can also contain:
|
60
|
+
· user_id <Integer>
|
61
|
+
· Categories <Hash>
|
62
|
+
|
63
|
+
Categories hash has the following structure:
|
64
|
+
|
65
|
+
`{ "CategoryClassName1" => [id1, id2], "CategoryClassName2" => [id1, id2] }`
|
66
|
+
|
67
|
+
If some category class doesn't appear as hash key it will be ignored.
|
68
|
+
|
69
|
+
`filter` method returns an `ActiveRecord::Relation` with all matching events
|
70
|
+
|
71
|
+
## Testing
|
72
|
+
|
73
|
+
All tests follow the RSpec format and are located in the spec directory.
|
74
|
+
They can be run with:
|
75
|
+
|
76
|
+
```
|
77
|
+
rake spec
|
78
|
+
```
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
Acts as votable is released under the [MIT
|
83
|
+
License](http://www.opensource.org/licenses/MIT).
|
@@ -5,13 +5,13 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "acts_as_full_calendar_event"
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
|
-
s.
|
10
|
+
s.author = ["Adrian Fernandez"]
|
11
11
|
s.email = ["adrianfernandez85@gmail.com"]
|
12
12
|
s.homepage = "http://github.com/adrian-fernandez/acts_as_full_calendar_event"
|
13
|
-
s.summary = "Rails gem to allowing
|
14
|
-
s.description = "Rails gem to allowing
|
13
|
+
s.summary = "Rails gem to allowing models to be events for full calendar"
|
14
|
+
s.description = "Rails gem to allowing models to be events for full calendar"
|
15
15
|
s.license = "MIT"
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
@@ -4,9 +4,6 @@ module ActsAsFullCalendarEvent
|
|
4
4
|
private :user_id, :categories, :start_date, :end_date
|
5
5
|
|
6
6
|
def initialize(params:)
|
7
|
-
raise(ArgumentError, "params must include 'start' having a date value") if params[:start].blank? || params[:start].class != Date
|
8
|
-
raise(ArgumentError, "params must include 'end' having a date value") if params[:end].blank? || params[:end].class != Date
|
9
|
-
|
10
7
|
@user_id = params[:user_id] if params.has_key?(:user_id)
|
11
8
|
@categories = JSON.parse(params[:categories] || '{}')
|
12
9
|
@start_date = params[:start]
|
@@ -14,24 +14,24 @@ describe ActsAsFullCalendarEvent::Calendar do
|
|
14
14
|
)}.not_to raise_error(ArgumentError)
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "doesn't require start" do
|
18
18
|
expect { ActsAsFullCalendarEvent::Calendar.new(
|
19
19
|
params: {
|
20
20
|
user_id: 1,
|
21
21
|
end: Date.new(2018, 1, 31),
|
22
22
|
categories: { "1": 1 }
|
23
23
|
}
|
24
|
-
)}.
|
24
|
+
)}.not_to raise_error(ArgumentError)
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "doesn't require end" do
|
28
28
|
expect { ActsAsFullCalendarEvent::Calendar.new(
|
29
29
|
params: {
|
30
30
|
user_id: 1,
|
31
31
|
start: Date.new(2018, 1, 1),
|
32
32
|
categories: { "1": 1 }
|
33
33
|
}
|
34
|
-
)}.
|
34
|
+
)}.not_to raise_error(ArgumentError)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "doesn't require user_id" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_full_calendar_event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Fernandez
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.9.3
|
153
|
-
description: Rails gem to allowing
|
153
|
+
description: Rails gem to allowing models to be events for full calendar
|
154
154
|
email:
|
155
155
|
- adrianfernandez85@gmail.com
|
156
156
|
executables: []
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- ".gitignore"
|
161
161
|
- Gemfile
|
162
162
|
- Gemfile.lock
|
163
|
+
- README.md
|
163
164
|
- Rakefile
|
164
165
|
- acts_as_full_calendar_event.gemspec
|
165
166
|
- lib/acts_as_full_calendar_event.rb
|
@@ -199,7 +200,7 @@ rubyforge_project:
|
|
199
200
|
rubygems_version: 2.7.8
|
200
201
|
signing_key:
|
201
202
|
specification_version: 4
|
202
|
-
summary: Rails gem to allowing
|
203
|
+
summary: Rails gem to allowing models to be events for full calendar
|
203
204
|
test_files:
|
204
205
|
- spec/acts_as_full_calendar_event_spec.rb
|
205
206
|
- spec/factories/category.rb
|