validates_timeliness-mongoid 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/validates_timeliness/mongoid.rb +4 -0
- data/lib/validates_timeliness/mongoid/version.rb +7 -0
- data/lib/validates_timeliness/orm/mongoid.rb +49 -0
- data/validates_timeliness-mongoid.gemspec +28 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 568af6e90da0a69d4f7258fcc2b29fa368716ff0
|
4
|
+
data.tar.gz: 25eb5c98b03d0a17275a986b884ddf015eebea78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01b4ba294051ebe03ffe44e15d9c78b4e93ddda89caaab03f37780422c2ba72e8dfddd037e7bc18cee3b4de89bf8280c336f267e92052b4165590b3fdc9dcfa2
|
7
|
+
data.tar.gz: ca2ac86a20ab7ce8a803b0c3cd2109e63d208126c630ee0da230275ac1440bf604e8404c3fae6a02b10e8ee3174a1c9b21e8fa66d2c9c972a4e8f175f5159258
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# ValidatesTimeliness::Mongoid
|
2
|
+
|
3
|
+
This the extracted mongoid adapter code from the validates_timeliness gem.
|
4
|
+
|
5
|
+
WARNING: The specs are not wired up properly and may not run. I will not be supporting this gem.
|
6
|
+
|
7
|
+
REQUEST: Someone who wants mongoid support is welcome to take over ownership of this gem.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'validates_timeliness-mongoid'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install validates_timeliness-mongoid
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/adzpa/validates_timeliness-mongoid.
|
34
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "validates_timeliness/mongoid"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module ValidatesTimeliness
|
2
|
+
module ORM
|
3
|
+
module Mongoid
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
# You need define the fields before you define the validations.
|
6
|
+
# It is best to use the plugin parser to avoid errors on a bad
|
7
|
+
# field value in Mongoid. Parser will return nil rather than error.
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
public
|
11
|
+
|
12
|
+
# Mongoid has no bulk attribute method definition hook. It defines
|
13
|
+
# them with each field definition. So we likewise define them after
|
14
|
+
# each validation is defined.
|
15
|
+
#
|
16
|
+
def timeliness_validation_for(attr_names, type)
|
17
|
+
super
|
18
|
+
attr_names.each { |attr_name| define_timeliness_write_method(attr_name) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def timeliness_attribute_type(attr_name)
|
22
|
+
{
|
23
|
+
Date => :date,
|
24
|
+
Time => :time,
|
25
|
+
DateTime => :datetime
|
26
|
+
}[fields[database_field_name(attr_name)].type] || :datetime
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def timeliness_type_cast_code(attr_name, var_name)
|
32
|
+
type = timeliness_attribute_type(attr_name)
|
33
|
+
|
34
|
+
"#{var_name} = Timeliness::Parser.parse(value, :#{type})"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def reload(*args)
|
39
|
+
_clear_timeliness_cache
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module Mongoid::Document
|
47
|
+
include ValidatesTimeliness::AttributeMethods
|
48
|
+
include ValidatesTimeliness::ORM::Mongoid
|
49
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
require 'validates_timeliness/mongoid/version'
|
8
|
+
|
9
|
+
Gem::Specification.new do |spec|
|
10
|
+
spec.name = ValidatesTimeliness::Mongoid::GEM_NAME
|
11
|
+
spec.version = ValidatesTimeliness::Mongoid::VERSION
|
12
|
+
spec.authors = ['Adam Meehan']
|
13
|
+
spec.email = ['adam.meehan@gmail.com']
|
14
|
+
|
15
|
+
spec.summary = %q{ValidatesTimeliness mongoid extension}
|
16
|
+
spec.description = %q{ValidatesTimeliness mongoid ORM compatability}
|
17
|
+
spec.homepage = ValidatesTimeliness::Mongoid::HOMEPAGE
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'validates_timeliness', '~> 4.0.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: validates_timeliness-mongoid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Meehan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: validates_timeliness
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: ValidatesTimeliness mongoid ORM compatability
|
56
|
+
email:
|
57
|
+
- adam.meehan@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/validates_timeliness/mongoid.rb
|
71
|
+
- lib/validates_timeliness/mongoid/version.rb
|
72
|
+
- lib/validates_timeliness/orm/mongoid.rb
|
73
|
+
- validates_timeliness-mongoid.gemspec
|
74
|
+
homepage: https://github.com/Dev-Crea/validates_timeliness-mongoid
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.5.1
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: ValidatesTimeliness mongoid extension
|
97
|
+
test_files: []
|