check_in_objects 1.0.0alpha
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +67 -0
- data/Rakefile +21 -0
- data/lib/check_in_objects.rb +2 -0
- data/lib/check_in_objects/acts_as_object_checkable.rb +23 -0
- data/lib/check_in_objects/models.rb +3 -0
- data/lib/check_in_objects/models/attendance.rb +3 -0
- data/lib/check_in_objects/models/entry.rb +3 -0
- data/lib/check_in_objects/models/exit.rb +3 -0
- data/lib/check_in_objects/railtie.rb +4 -0
- data/lib/check_in_objects/version.rb +3 -0
- data/lib/generators/check_in_objects/USAGE +8 -0
- data/lib/generators/check_in_objects/check_in_objects_generator.rb +25 -0
- data/lib/generators/check_in_objects/templates/migration.rb +10 -0
- data/lib/tasks/check_in_objects_tasks.rake +4 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4eb1dbc5ebc5706e993e52e72968b13bfa163d6f21099634699c91c086e422d1
|
4
|
+
data.tar.gz: c088219fd762c2914a32aaea748273635884026f0e1146879418d58c5ffe1fb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da430bc556689714fb7cc6992f108d13f7e97d9b1b2f53671d5470953e4bc0357afee13090def86ce37249c30b98cc319440bca2a7eb203b27a3b4009bdd93b3
|
7
|
+
data.tar.gz: 8bdfccafbfe2bf315b6071f70bbeb8fe8858dc4a4d12d85197cec60101f74a9d20749aa5ab8573d0715bd657100d5e0640947e20479073bc84409a2ba6ea85bc
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# CheckInObjects
|
2
|
+
|
3
|
+
Rails plugin that do check-in/check-out of models of ActiveRecord.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/armando1339/check_in_objects) [](https://coveralls.io/github/armando1339/check_in_objects?branch=feature/adding_travisci)
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Add the `#acts_as_object_checkable` in the ActiveRecord models that want they have the functionality.
|
10
|
+
The method will add associations with the Attendance and Entry models where Entry inherits from Attendace. The association will give you access to the ActiveRecord relationship method
|
11
|
+
|
12
|
+
Example:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
class User < ActiveRecord::Base
|
16
|
+
acts_as_object_checkable
|
17
|
+
end
|
18
|
+
|
19
|
+
# Then:
|
20
|
+
|
21
|
+
user = User.new
|
22
|
+
user.attendances.build_attendance
|
23
|
+
user.entries.build_entry
|
24
|
+
|
25
|
+
# for exit
|
26
|
+
|
27
|
+
entry = user.entries.last
|
28
|
+
entry.create_exit
|
29
|
+
```
|
30
|
+
|
31
|
+
## Installation
|
32
|
+
|
33
|
+
Add this line to your application's Gemfile:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'check_in_objects'
|
37
|
+
```
|
38
|
+
|
39
|
+
And then execute:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
$ bundle install
|
43
|
+
```
|
44
|
+
|
45
|
+
In the root directory:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
$ rails generate check_in_objects
|
49
|
+
```
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug report or pull request are welcome.
|
54
|
+
|
55
|
+
Make a pull request:
|
56
|
+
|
57
|
+
- Clone the repo
|
58
|
+
- Create your feature branch
|
59
|
+
- Commit your changes
|
60
|
+
- Push the branch
|
61
|
+
- Create new Pull-Request
|
62
|
+
|
63
|
+
Please write tests if necessary.
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'CheckInObjects'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
18
|
+
require "rspec/core/rake_task"
|
19
|
+
|
20
|
+
RSpec::Core::RakeTask.new(:spec)
|
21
|
+
task default: :spec
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CheckInObjects
|
2
|
+
module ActsAsObjectCheckable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
ObjectCheckable = Module.new do
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_many :attendances, as: :entity, dependent: :destroy
|
10
|
+
has_many :entries, as: :entity, dependent: :destroy
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class_methods do
|
15
|
+
def acts_as_object_checkable
|
16
|
+
include ObjectCheckable
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# => including the method in ActiveRecord
|
23
|
+
ActiveRecord::Base.include CheckInObjects::ActsAsObjectCheckable
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class CheckInObjectsGenerator < Rails::Generators::Base
|
2
|
+
include Rails::Generators::Migration
|
3
|
+
source_root File.expand_path('templates', __dir__)
|
4
|
+
|
5
|
+
def migration
|
6
|
+
migration_template(
|
7
|
+
'migration.rb',
|
8
|
+
'db/migrate/create_attendances.rb'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
def rails5_and_up?
|
13
|
+
Rails::VERSION::MAJOR >= 5
|
14
|
+
end
|
15
|
+
|
16
|
+
def migration_version
|
17
|
+
if rails5_and_up?
|
18
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.next_migration_number(dir)
|
23
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateAttendances < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def change
|
3
|
+
create_table :attendances do |t|
|
4
|
+
t.string :type
|
5
|
+
t.references :entity, polymorphic: true, index: true
|
6
|
+
t.references :attendance, foreign_key: true, index: true
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: check_in_objects
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Armando Alejandre
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.2.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.2.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pg
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: shoulda-matchers
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: shoulda-callback-matchers
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Rails plugin that do check-in/check-out of models of ActiveRecord.
|
126
|
+
email:
|
127
|
+
- armando1339@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- MIT-LICENSE
|
133
|
+
- README.md
|
134
|
+
- Rakefile
|
135
|
+
- lib/check_in_objects.rb
|
136
|
+
- lib/check_in_objects/acts_as_object_checkable.rb
|
137
|
+
- lib/check_in_objects/models.rb
|
138
|
+
- lib/check_in_objects/models/attendance.rb
|
139
|
+
- lib/check_in_objects/models/entry.rb
|
140
|
+
- lib/check_in_objects/models/exit.rb
|
141
|
+
- lib/check_in_objects/railtie.rb
|
142
|
+
- lib/check_in_objects/version.rb
|
143
|
+
- lib/generators/check_in_objects/USAGE
|
144
|
+
- lib/generators/check_in_objects/check_in_objects_generator.rb
|
145
|
+
- lib/generators/check_in_objects/templates/migration.rb
|
146
|
+
- lib/tasks/check_in_objects_tasks.rake
|
147
|
+
homepage: https://github.com/armando1339
|
148
|
+
licenses:
|
149
|
+
- MIT
|
150
|
+
metadata:
|
151
|
+
allowed_push_host: https://rubygems.org
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 1.3.1
|
166
|
+
requirements: []
|
167
|
+
rubygems_version: 3.0.6
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Rails plugin that do check-in/check-out of models of ActiveRecord.
|
171
|
+
test_files: []
|