mongoid_enumerable 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9af51c7b47d1e09b22dd640e385adb4af4222417311bc9e03cedf68e783b8a0d
4
- data.tar.gz: 92869fa82757e9fab2ecc95c4721e1ccac09eeb66df1d302132fec2c61ab3b4c
3
+ metadata.gz: fb530cf42499e51a032c2aa44b278956b0cc9f09a85c51c2327f45e25c00c05f
4
+ data.tar.gz: cd079294ce92f0455eaf75f87e418aa1637418be8fd0e06914eab79af99f735a
5
5
  SHA512:
6
- metadata.gz: 4114bf4ea3e50eee951783b9b707fbe5cdcd61fe29c528a0585d77819d61935cd0980e9e63636f91bfd803f0e7250fdbffde7214a79b5f175ef928538125d10a
7
- data.tar.gz: a03cfd99dbc231ec593d867781221dc067e165991234293cce6cbb122605f10a42c56a9a0177eb4a763d72df9edb247ddf20e3aa48b534a301e2db2c3d83a22b
6
+ metadata.gz: add16cbb3e8ddc294a3a2ee5de08f8083e6fe21a63dadba3a0f80ba79e1c7d19abe72d47e8d8d006df451c797a89d1e73cb70368116d1f23017589ec2d8c7d93
7
+ data.tar.gz: 4b6a175e68056e2cc01664ffd660a9fa133d6e10c9bdab3899e250a1a0bcd2d0a94af2657ab2a714ea7976bbb181071106a8a8ba5bc3ffcec84afec1f173ff56
data/.travis.yml CHANGED
@@ -6,3 +6,12 @@ rvm:
6
6
  - 2.3.6
7
7
  - 2.2.9
8
8
  before_install: gem install bundler -v 1.16.1
9
+ env:
10
+ global:
11
+ - CC_TEST_REPORTER_ID=049baa35735ad9587a7ff016745e67eb057ef79958cb31113d4a19cc504c0216
12
+ before_script:
13
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
+ - chmod +x ./cc-test-reporter
15
+ - ./cc-test-reporter before-build
16
+ after_script:
17
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mongoid_enumerable (0.1.0)
5
- mongoid
4
+ mongoid_enumerable (0.1.1)
5
+ mongoid (>= 4.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -18,8 +18,10 @@ GEM
18
18
  byebug (10.0.2)
19
19
  concurrent-ruby (1.0.5)
20
20
  diff-lcs (1.3)
21
+ docile (1.3.0)
21
22
  i18n (1.0.1)
22
23
  concurrent-ruby (~> 1.0)
24
+ json (2.1.0)
23
25
  minitest (5.11.3)
24
26
  mongo (2.5.3)
25
27
  bson (>= 4.3.0, < 5.0.0)
@@ -43,6 +45,11 @@ GEM
43
45
  rspec (>= 3)
44
46
  terminal-notifier (>= 1.4)
45
47
  rspec-support (3.7.1)
48
+ simplecov (0.16.1)
49
+ docile (~> 1.1)
50
+ json (>= 1.8, < 3)
51
+ simplecov-html (~> 0.10.0)
52
+ simplecov-html (0.10.2)
46
53
  terminal-notifier (2.0.0)
47
54
  thread_safe (0.3.6)
48
55
  tzinfo (1.2.5)
@@ -59,6 +66,7 @@ DEPENDENCIES
59
66
  rake (~> 10.0)
60
67
  rspec (~> 3.0)
61
68
  rspec-nc
69
+ simplecov
62
70
 
63
71
  BUNDLED WITH
64
72
  1.16.1
data/README.md CHANGED
@@ -1,9 +1,37 @@
1
1
  # Mongoid Enumerable
2
2
 
3
3
  [![Build Status](https://travis-ci.org/douglaslise/mongoid_enumerable.svg?branch=master)](https://travis-ci.org/douglaslise/mongoid_enumerable)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/bc09bc91c31fed14924a/maintainability)](https://codeclimate.com/github/douglaslise/mongoid_enumerable/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/bc09bc91c31fed14924a/test_coverage)](https://codeclimate.com/github/douglaslise/mongoid_enumerable/test_coverage)
4
6
  [![Gem Version](https://badge.fury.io/rb/mongoid_enumerable.svg)](https://badge.fury.io/rb/mongoid_enumerable)
5
7
 
6
- Define custom methods for your MongoId documents:
8
+ Define enumerable fields in your Mongoid documents.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'mongoid_enumerable'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install mongoid_enumerable
25
+
26
+ ## Usage
27
+ Simply include `MongoidEnumerable` in your document.
28
+ After add `enumerable` with:
29
+ - Field name
30
+ - An array with possible values
31
+ - Options (`default` and/or `prefix`)
32
+
33
+ Example:
34
+
7
35
  ```ruby
8
36
  class Task
9
37
  include Mongoid::Document
@@ -13,33 +41,50 @@ class Task
13
41
  end
14
42
  ```
15
43
 
16
- Now we have methods in this model:
44
+ Now we have methods in this document's instance:
17
45
  ```ruby
18
46
  task = Task.new
19
47
 
20
48
  task.status # "waiting"
21
49
  task.waiting? # true
22
50
 
23
- task.running!
51
+ task.running! # changes status field to "running"
24
52
  task.running? # true
25
53
  task.waiting? # false
26
54
  ```
27
55
 
28
- ## Installation
29
-
30
- Add this line to your application's Gemfile:
31
-
56
+ ### Options
57
+ #### Default
58
+ Defines which value is the default for new documents. If not specified the first value is used as default.
32
59
  ```ruby
33
- gem 'mongoid_enumerable'
60
+ enumerable :status, %w(completed running failed waiting), default: "waiting"
34
61
  ```
62
+ #### Prefix
63
+ You can define a prefix for your methods that could be useful if you have more than one enumerable with the same values.
64
+ ```ruby
65
+ enumerable :build_status, %w(completed running failed waiting), default: "waiting", prefix: "build_"
66
+ enumerable :deploy_status, %w(completed running failed waiting), default: "waiting", prefix: "deploy_"
35
67
 
36
- And then execute:
68
+ task.build_completed?
69
+ task.build_failed!
70
+ task.deploy_running?
71
+ task.deploy_failed!
72
+ ```
37
73
 
38
- $ bundle
39
74
 
40
- Or install it yourself as:
75
+ ### Scopes/Criterias
76
+ All values are added as scopes/criterias to your document class:
77
+ ```ruby
78
+ Task.waiting # Returns all tasks with waiting status
79
+ Task.running # Returns all tasks with running status
80
+ ```
81
+
82
+ If prefixed, the scopes/criterias are prefixed too:
83
+ ```ruby
84
+ Task.build_waiting # Returns all tasks with build waiting status
85
+ Task.deploy_running # Returns all tasks with deploy running status
86
+ ```
41
87
 
42
- $ gem install mongoid_enumerable
43
88
 
44
89
  ## Development
45
90
 
@@ -1,3 +1,3 @@
1
1
  module MongoidEnumerable
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rspec-nc"
27
27
  spec.add_development_dependency "mongoid"
28
28
  spec.add_development_dependency "byebug"
29
- spec.add_dependency "mongoid"
29
+ spec.add_dependency "mongoid", ">= 4.0"
30
+ spec.add_development_dependency "simplecov"
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_enumerable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Lise
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-20 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,9 +100,23 @@ dependencies:
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '4.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '4.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - ">="