mongoid-utils 0.1.10

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d7f2efb2526d57ea2959694fb4dbf42acad36d9
4
+ data.tar.gz: c3eea88ff68d6300bccd74ac43afd2a156a9d557
5
+ SHA512:
6
+ metadata.gz: 0207bcb95410df31d74e788a222965b2e5aa903ddc733883a5e7a0527c622c9f10aa34592933cfb0da02386d170afbf32554efdc15ce4820084bc6a2ea4f9cae
7
+ data.tar.gz: 0b9c22f1afa124319f3613b99eb0453b712e0b2261fb2f1353731d3aeccaa4f81cea346115aff10d29455d1af1c61a67994ab506b1fed96c74c8fed9cdaad408
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at xbiznet@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mongoid_utils.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mongoid-utils (0.1.3)
5
+ activesupport
6
+ mongoid
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (5.1.1)
12
+ activesupport (= 5.1.1)
13
+ activesupport (5.1.1)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (~> 0.7)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ bson (4.2.1)
19
+ concurrent-ruby (1.0.5)
20
+ i18n (0.8.1)
21
+ minitest (5.10.2)
22
+ mongo (2.4.1)
23
+ bson (>= 4.2.1, < 5.0.0)
24
+ mongoid (6.1.0)
25
+ activemodel (~> 5.0)
26
+ mongo (>= 2.4.1, < 3.0.0)
27
+ rake (10.5.0)
28
+ thread_safe (0.3.6)
29
+ tzinfo (1.2.3)
30
+ thread_safe (~> 0.1)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.14)
37
+ mongoid-utils!
38
+ rake (~> 10.0)
39
+
40
+ BUNDLED WITH
41
+ 1.14.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Michail
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Michail
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # MongoidUtils
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mongoid_utils`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'mongoid_utils'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install mongoid_utils
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Michail/mongoid_utils. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mongoid_utils"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ module Mongoid
2
+ module Relations
3
+ module Macros
4
+ module ClassMethods
5
+ #alias :__habtm :has_and_belongs_to_many
6
+ __habtm = instance_method(:has_and_belongs_to_many)
7
+
8
+ #def has_and_belongs_to_many(name, options = {}, &block)
9
+
10
+ define_method(:has_and_belongs_to_many) { |name, options, &block|
11
+ meta = __habtm.bind(self).(name, options, &block)
12
+
13
+ if meta.counter_cached?
14
+ counter_field_name = (meta[:counter_cache] == true) ? "#{meta.name}_count" : meta[:counter_cache]
15
+ counter_ids_name = "#{meta.name.to_s.singularize}_ids"
16
+
17
+ self.class_eval %Q{
18
+ def #{counter_field_name}
19
+ self.#{counter_ids_name}.count.to_i
20
+ end
21
+ }
22
+ end
23
+
24
+ meta
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ module Mongoid
2
+ module Timestamps
3
+ module CreatedAt
4
+ # Returns the creation time calculated from ObjectID
5
+ #
6
+ # @return [ Date ] the creation time
7
+ def created_at
8
+ read_attribute(:created_at) || id.generation_time.to_datetime
9
+ end
10
+
11
+ # Set generation time of ObjectId.
12
+ # Note: This will modify the ObjectId and
13
+ # is therefor only useful for not persisted documents
14
+ #
15
+ # @return [ BSON::ObjectId ] the generated object id
16
+ # def created_at=(date)
17
+ # self.id = BSON::ObjectId.from_time(date)
18
+ # end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ require 'mongoid/utils/version'
2
+
3
+ require 'mongoid/created_at'
4
+ require 'mongoid/counter_cache'
5
+ require 'mongoid/utils/hit'
6
+
7
+ require 'mongoid/utils/commentable'
8
+ require 'mongoid/utils/hitable'
9
+ require 'mongoid/utils/listable'
10
+ require 'mongoid/utils/sluggable'
11
+ require 'mongoid/utils/sortable'
12
+ require 'mongoid/utils/votable'
@@ -0,0 +1,35 @@
1
+ module Mongoid
2
+ module Utils
3
+ module Commentable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ scope :discussable, -> {order_by(comments_count: :desc)}
8
+
9
+ has_many :comments, as: :commentable, dependent: :destroy
10
+ field :comments_count, type: Integer, default: 0
11
+ end
12
+
13
+ module ClassMethods
14
+ def discussable_by(param, options = {})
15
+ range = case param
16
+ when 'day'; Time.now.at_beginning_of_day..Time.now
17
+ when 'week'; Time.now.at_beginning_of_week..Time.now
18
+ when 'month'; Time.now.at_beginning_of_month..Time.now
19
+ when 'year'; Time.now.at_beginning_of_year..Time.now
20
+ end
21
+
22
+ filter = []
23
+ filter << { :$match => {commentable_type: self.name, _id: {:$gte => BSON::ObjectId.from_time(range.first), :$lte => BSON::ObjectId.from_time(range.last)} } }
24
+ filter << { :$group => {_id: '$commentable_id', count: {:$sum => 1}} }
25
+ # filter << { :$sort => {count: -1} }
26
+ filter << { :$limit => options[:limit].to_i } if options.key?(:limit)
27
+
28
+ ids = Comment.collection.aggregate(filter).collect { |raw| raw[:_id] }
29
+
30
+ where(:id.in => ids)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ module Mongoid
2
+ module Utils
3
+ class Hit
4
+ include Mongoid::Document
5
+
6
+ belongs_to :hitable, polymorphic: true
7
+
8
+ field :digest, type: BSON::Binary
9
+ field :hitable_id, type: BSON::ObjectId
10
+ field :hitable_type, type: String
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,51 @@
1
+ module Mongoid
2
+ module Utils
3
+ module Hitable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ scope :popular, -> {order_by(hits_count: :desc)}
8
+
9
+ has_many :hits, class_name: 'Mongoid::Utils::Hit', as: :hitable, dependent: :destroy
10
+ field :hits_count, type: Integer, default: 0
11
+ end
12
+
13
+ def hitted(hit_digest)
14
+ seen = hits.where(digest: hit_digest).count > 0
15
+
16
+ unless seen
17
+ hits.create(digest: hit_digest)
18
+ self.timeless.update_attribute(:hits_count, hits_count + 1)
19
+ end
20
+ end
21
+
22
+ # def hit_count(options={})
23
+ # options.reverse_merge!(filter: :session_hash, start_date: nil, end_date: Time.now)
24
+ # hts = options[:start_date].blank? ? hits : hits.between(created_at: options[:start_date]..options[:end_date])
25
+ #
26
+ # distinct = options[:filter] != :all
27
+ # distinct ? hts.where(options[:filter].ne => nil).distinct(options[:filter]).count : hts.count
28
+ # end
29
+
30
+ module ClassMethods
31
+ def popular_by(param, options = {})
32
+ range = case param
33
+ when 'day'; Time.now.at_beginning_of_day..Time.now
34
+ when 'week'; Time.now.at_beginning_of_week..Time.now
35
+ when 'month'; Time.now.at_beginning_of_month..Time.now
36
+ when 'year'; Time.now.at_beginning_of_year..Time.now
37
+ end
38
+
39
+ filter = []
40
+ filter << { :$match => {hitable_type: self.name, _id: {:$gte => BSON::ObjectId.from_time(range.first), :$lte => BSON::ObjectId.from_time(range.last)} } }
41
+ filter << { :$group => {_id: '$hitable_id', count: {:$sum => 1}} }
42
+ # filter << { :$sort => {count: -1} }
43
+ filter << { :$limit => options[:limit].to_i } if options.key?(:limit)
44
+
45
+ ids = Hit.collection.aggregate(filter).collect { |raw| raw[:_id] }
46
+ where(:id.in => ids)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,30 @@
1
+ module Mongoid
2
+ module Utils
3
+ module Listable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_and_belongs_to_many :lists, inverse_of: nil
8
+ after_update -> { @hash = nil }
9
+
10
+ index({ list_ids: 1 }, { sparse: true, name: "lists_index" })
11
+ end
12
+
13
+ def lists_hash
14
+ # @hash ||= Hash[lists.map { |list| [list.model_name.param_key.to_sym, list] }]#.group_by(&:first).map { |k,v| {k => (el = v.map(&:last)).length > 1 ? el : el[0]} }.last || {}
15
+ unless @hash
16
+ hashes = lists.map{ |list| Hash[*[list.model_name.param_key.to_sym, list]] }
17
+ @hash ||= hashes.flat_map(&:entries).group_by(&:first).map{|k,v| Hash[k, v.map(&:last)]}.reduce(Hash.new, :merge) || {}
18
+ @hash.each {|k,v| if v.length == 1 then @hash[k] = v.first end}
19
+ #hashes.inject{ |h1,h2| h1.merge(h2){ |*a| a[1,2] } } || {}
20
+ end
21
+
22
+ @hash
23
+ end
24
+
25
+ def list_title(list)
26
+ lists_hash[list].is_a?(Array) ? lists_hash[list].collect(&:title).join(', ') : lists_hash[list].try(:title)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,27 @@
1
+ module Mongoid
2
+ module Utils
3
+ module Sluggable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ before_save :generate_slug
8
+
9
+ field :slug, type: String
10
+ end
11
+
12
+ def to_param
13
+ slug
14
+ end
15
+
16
+ def generate_slug
17
+ self.slug = title.parameterize.strip
18
+ end
19
+
20
+ module ClassMethods
21
+ def from_param(param)
22
+ find_by(slug: param)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ module Mongoid
2
+ module Utils
3
+ module Sortable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ scope :fresh, -> { order_by(_id: :desc) }
8
+ end
9
+
10
+ module ClassMethods
11
+ def fresh_by(param)
12
+ range = case param
13
+ when 'day'; Time.now.at_beginning_of_day..Time.now
14
+ when 'week'; Time.now.at_beginning_of_week..Time.now
15
+ when 'month'; Time.now.at_beginning_of_month..Time.now
16
+ when 'year'; Time.now.at_beginning_of_year..Time.now
17
+ end
18
+
19
+ between(:id.in => BSON::ObjectId.from_time(range.first)..BSON::ObjectId.from_time(range.last))
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module Mongoid
2
+ module Utils
3
+ VERSION = "0.1.10"
4
+ end
5
+ end
@@ -0,0 +1,73 @@
1
+ module Mongoid
2
+ module Utils
3
+ module Votable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ field :votes_up, type: Integer, default: 0
8
+ field :votes_down, type: Integer, default: 0
9
+
10
+ embeds_many :votes, class_name: 'Mongoid::Utils::Votable::Vote'
11
+
12
+ scope :voted_by, ->(voter) { where('votes.voter_id' => voter.id) }
13
+ end
14
+
15
+ def voted?(voter)
16
+ votes.where(voter: voter).first != nil
17
+ end
18
+
19
+ def vote_up(voter)
20
+ vote!(1, voter)
21
+ end
22
+
23
+ def vote_down(voter)
24
+ vote!(-1, voter)
25
+ end
26
+
27
+ def vote!(value, voter)
28
+ vote = self.votes.find_or_create_by(user: voter)
29
+
30
+ if vote.value == value
31
+ vote.destroy
32
+ value = 0
33
+ end
34
+
35
+ update_values(value, vote)
36
+ vote.update_attribute(:value, value) if value != 0
37
+
38
+ vote
39
+ end
40
+
41
+ def votes_count
42
+ self.votes.count
43
+ end
44
+
45
+ def votes_value
46
+ self.votes_up - self.votes_down
47
+ end
48
+
49
+ module ClassMethods
50
+ end
51
+
52
+ private
53
+ def update_values(value, vote)
54
+ votes_up_change = (vote.value > 0 ? -vote.value : 0) + (value > 0 ? value : 0)
55
+ votes_down_change = (vote.value < 0 ? vote.value : 0) + (value < 0 ? value.abs : 0)
56
+
57
+ self.inc(votes_up: votes_up_change)
58
+ self.inc(votes_down: votes_down_change)
59
+ end
60
+
61
+ class Vote
62
+ include Mongoid::Document
63
+
64
+ field :value, type: Integer, default: 0
65
+
66
+ belongs_to :user
67
+ embedded_in :votable
68
+
69
+ index voter_id: 1
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mongoid/utils/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mongoid-utils"
8
+ spec.version = Mongoid::Utils::VERSION
9
+ spec.authors = ["Michail"]
10
+ spec.email = ["xbiznet@gmail.com"]
11
+
12
+ spec.summary = %q{Useful concerns for mongoid ORM for the rails framework. Including commentable, hitable, votable and so on...}
13
+ spec.description = %q{A set of Mongoid model concerns for adding functionality of commentable, votable, hitable models and some other nice add ons}
14
+ spec.homepage = "https://github.com/madmike/mongoid_utils"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "bin"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "activesupport"
34
+ spec.add_dependency "mongoid"
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.14"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid-utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.10
5
+ platform: ruby
6
+ authors:
7
+ - Michail
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mongoid
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: A set of Mongoid model concerns for adding functionality of commentable,
70
+ votable, hitable models and some other nice add ons
71
+ email:
72
+ - xbiznet@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/mongoid/counter_cache.rb
88
+ - lib/mongoid/created_at.rb
89
+ - lib/mongoid/utils.rb
90
+ - lib/mongoid/utils/commentable.rb
91
+ - lib/mongoid/utils/hit.rb
92
+ - lib/mongoid/utils/hitable.rb
93
+ - lib/mongoid/utils/listable.rb
94
+ - lib/mongoid/utils/sluggable.rb
95
+ - lib/mongoid/utils/sortable.rb
96
+ - lib/mongoid/utils/version.rb
97
+ - lib/mongoid/utils/votable.rb
98
+ - mongoid-utils.gemspec
99
+ homepage: https://github.com/madmike/mongoid_utils
100
+ licenses:
101
+ - MIT
102
+ metadata:
103
+ allowed_push_host: https://rubygems.org
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.6.8
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Useful concerns for mongoid ORM for the rails framework. Including commentable,
124
+ hitable, votable and so on...
125
+ test_files: []