acts_as_footprintable 0.2.3 → 0.3.0

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
  SHA1:
3
- metadata.gz: 8e8915ee9a150cadf7601e9f54d18ee0d373f6c9
4
- data.tar.gz: bbbf50a358d50691ac80a361b0139e6b56405efd
3
+ metadata.gz: a5511b19bf736e594da831847c7e5680ed541f45
4
+ data.tar.gz: 587ada66643a68366b0099661d9a3f420f373f76
5
5
  SHA512:
6
- metadata.gz: 250b5cc290a53082fd2af8b2f692d9ec43025d420807ce16983f2a0f6288f0cf68309e7fcea4cec920b2d6eddbb01d445adf5637e94f280a0f834cc8396f03e8
7
- data.tar.gz: e49ee10b5b6ba5fed9fff2e525f0f424b75e263094badf48ee8841af9cf1b05d7ebab2b78f732b9aba7d99bcd442b7d055fc29423ada85b9cf138fc37a503597
6
+ metadata.gz: 1b3ee4db822262a0e47e15d49959b50552bb26b7c088163fb2006341e96fc62a5a897c2d48f2b5919eca9ca9eb7d2c070e05b34efd6ff0e7edaee0856c24e02c
7
+ data.tar.gz: 266229cf82bb0245dd70a330a527cff8619ef19734fdf59b4f010eadc383eb18336b5e7bd6b68f076e0b6acc9751ae1ebd1bc41425cf248fb07d6edd0d9db063
data/.travis.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.1
4
- - 2.2.5
3
+ - 2.4.0
4
+ - 2.3.3
5
+ - 2.2.6
5
6
  - 2.1.10
6
- - 2.0.0
7
7
  env:
8
+ - "RAILS_VERSION=5.0.0"
8
9
  - "RAILS_VERSION=4.2.0"
9
10
  - "RAILS_VERSION=4.1.0"
10
11
  - "RAILS_VERSION=4.0.0"
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  rails_version = ENV['RAILS_VERSION'] || 'default'
8
-
9
8
  rails = case rails_version
10
9
  when 'master'
11
10
  { :github => 'rails/rails' }
@@ -17,5 +16,5 @@ rails = case rails_version
17
16
 
18
17
  gem 'rails', rails
19
18
  group :development do
20
- gem 'combustion', github: 'patorash/combustion', branch: 'master'
19
+ gem 'combustion', '~> 0.5'
21
20
  end
@@ -10,8 +10,8 @@ module ActsAsFootprintable
10
10
  belongs_to :footprintable, :polymorphic => true
11
11
  belongs_to :footprinter, :polymorphic => true
12
12
 
13
- scope :for_type, lambda{|klass| where(:footprintable_type => klass)}
14
- scope :by_type, lambda{|klass| where(:footprinter_type => klass)}
13
+ scope :for_type, lambda{|klass| where(:footprintable_type => klass.name)}
14
+ scope :by_type, lambda{|klass| where(:footprinter_type => klass.name)}
15
15
 
16
16
  validates :footprintable_id, :presence => true
17
17
  validates :footprinter_id, :presence => true
@@ -39,8 +39,13 @@ module ActsAsFootprintable
39
39
 
40
40
  def recent_footprint_ids(target, limit=nil)
41
41
  recent_footprints = target.group("#{table_name}.footprintable_id, #{table_name}.footprintable_type").
42
- select("#{table_name}.footprintable_id, #{table_name}.footprintable_type, MAX(#{table_name}.created_at)")
43
- records = footprints.where("(#{table_name}.footprintable_id, #{table_name}.footprintable_type, #{table_name}.created_at) IN (#{recent_footprints.arel.to_sql})")
42
+ select("#{table_name}.footprintable_id, #{table_name}.footprintable_type, MAX(#{table_name}.created_at) AS created_at")
43
+ recent_footprints_conditions = recent_footprints.map{ |recent_footprint| recent_footprint.attributes.select{ |_, v| !v.nil?} }
44
+ columns = recent_footprints_conditions.first.keys.map{|column| "#{table_name}.#{column}" }.join(',')
45
+ values = recent_footprints_conditions.map { |row|
46
+ "(#{row.values.map{|value| ActiveRecord::Base::sanitize(value)}.join(',')})"
47
+ }.join(',')
48
+ records = footprints.where("(#{columns}) IN (#{values})")
44
49
  records = records.order("footprints.created_at desc")
45
50
  records = records.limit(limit) unless limit.nil?
46
51
  records.pluck(:id)
@@ -1,4 +1,4 @@
1
1
  # coding: utf-8
2
2
  module ActsAsFootprintable
3
- VERSION = "0.2.3"
3
+ VERSION = "0.3.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_footprintable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyoaki Oko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-10 00:00:00.000000000 Z
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 2.5.1
151
+ rubygems_version: 2.5.2
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Rails gem to allowing records to leave footprints