active_median 0.1.2 → 0.1.3
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 +4 -4
- data/.travis.yml +22 -0
- data/CHANGELOG.md +4 -0
- data/README.md +9 -6
- data/active_median.gemspec +1 -0
- data/lib/active_median.rb +2 -2
- data/lib/active_median/version.rb +1 -1
- data/test/active_median_test.rb +3 -3
- data/test/gemfiles/activerecord32.gemfile +6 -0
- data/test/gemfiles/activerecord40.gemfile +6 -0
- data/test/gemfiles/activerecord41.gemfile +6 -0
- data/test/gemfiles/activerecord50.gemfile +6 -0
- data/test/test_helper.rb +3 -0
- metadata +27 -6
- data/gemfiles/activerecord32.gemfile +0 -6
- data/gemfiles/activerecord40.gemfile +0 -6
- data/gemfiles/activerecord41.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b551770177ca1b626f794e53a6076dcd2fd80f09
|
4
|
+
data.tar.gz: 94f4f4e96beaefbadba494726b7809a5ff65e649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8a51b06f6d07222bda15aeac042384bbf04d94cf1810f2bb85e32404c76b21b417912272653369c0a393d38b107eaa18ecec83418762f5b498303130511ba72
|
7
|
+
data.tar.gz: 78a344daee6bc290764695fa6a7b6504aec0f6392d2788dcb3767b28e5f61c3b6d5499782719e0c236db2435f6c6315c9831e49a18c7d8ca5ded9af5333455a0
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.3.0
|
4
|
+
sudo: false
|
5
|
+
script: bundle exec rake test
|
6
|
+
before_script:
|
7
|
+
- gem install bundler
|
8
|
+
- psql -c 'create database active_median_test;' -U postgres
|
9
|
+
notifications:
|
10
|
+
email:
|
11
|
+
on_success: never
|
12
|
+
on_failure: change
|
13
|
+
gemfile:
|
14
|
+
- Gemfile
|
15
|
+
- test/gemfiles/activerecord50.gemfile
|
16
|
+
- test/gemfiles/activerecord41.gemfile
|
17
|
+
- test/gemfiles/activerecord40.gemfile
|
18
|
+
- test/gemfiles/activerecord32.gemfile
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- gemfile: test/gemfiles/activerecord50.gemfile
|
22
|
+
- gemfile: test/gemfiles/activerecord32.gemfile
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Median for ActiveRecord - PostgreSQL only at the moment
|
4
4
|
|
5
|
+
[](https://travis-ci.org/ankane/active_median)
|
6
|
+
|
5
7
|
```ruby
|
6
8
|
Item.median(:price)
|
7
9
|
```
|
@@ -17,7 +19,7 @@ Order.group("date_trunc('week', created_at)").median(:total)
|
|
17
19
|
Add this line to your application’s Gemfile:
|
18
20
|
|
19
21
|
```ruby
|
20
|
-
gem
|
22
|
+
gem 'active_median'
|
21
23
|
```
|
22
24
|
|
23
25
|
And add the `median` function to the database from the Rails console.
|
@@ -28,8 +30,9 @@ ActiveMedian.create_function
|
|
28
30
|
|
29
31
|
## Contributing
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
34
|
+
|
35
|
+
- [Report bugs](https://github.com/ankane/active_median/issues)
|
36
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/active_median/pulls)
|
37
|
+
- Write, clarify, or fix documentation
|
38
|
+
- Suggest or add new features
|
data/active_median.gemspec
CHANGED
data/lib/active_median.rb
CHANGED
data/test/active_median_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
3
|
class TestActiveMedian < Minitest::Test
|
4
4
|
|
@@ -8,12 +8,12 @@ class TestActiveMedian < Minitest::Test
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_even
|
11
|
-
|
11
|
+
[1, 1, 2, 3, 4, 100].each {|n| User.create!(visits_count: n) }
|
12
12
|
assert_equal 2.5, User.median(:visits_count)
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_odd
|
16
|
-
|
16
|
+
[1, 1, 2, 4, 100].each {|n| User.create!(visits_count: n) }
|
17
17
|
assert_equal 2, User.median(:visits_count)
|
18
18
|
end
|
19
19
|
|
data/test/test_helper.rb
CHANGED
@@ -2,11 +2,14 @@ require "bundler/setup"
|
|
2
2
|
Bundler.require :default
|
3
3
|
require "minitest/autorun"
|
4
4
|
require "minitest/pride"
|
5
|
+
require "logger"
|
5
6
|
|
6
7
|
Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test)
|
7
8
|
|
8
9
|
ActiveRecord::Base.establish_connection adapter: "postgresql", database: "active_median_test"
|
9
10
|
|
11
|
+
# ActiveRecord::Base.logger = Logger.new(STDOUT)
|
12
|
+
|
10
13
|
ActiveRecord::Migration.create_table :users, force: true do |t|
|
11
14
|
t.integer :visits_count
|
12
15
|
t.decimal :latitude
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_median
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
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'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pg
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,18 +88,20 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
77
92
|
- CHANGELOG.md
|
78
93
|
- Gemfile
|
79
94
|
- LICENSE.txt
|
80
95
|
- README.md
|
81
96
|
- Rakefile
|
82
97
|
- active_median.gemspec
|
83
|
-
- gemfiles/activerecord32.gemfile
|
84
|
-
- gemfiles/activerecord40.gemfile
|
85
|
-
- gemfiles/activerecord41.gemfile
|
86
98
|
- lib/active_median.rb
|
87
99
|
- lib/active_median/version.rb
|
88
100
|
- test/active_median_test.rb
|
101
|
+
- test/gemfiles/activerecord32.gemfile
|
102
|
+
- test/gemfiles/activerecord40.gemfile
|
103
|
+
- test/gemfiles/activerecord41.gemfile
|
104
|
+
- test/gemfiles/activerecord50.gemfile
|
89
105
|
- test/test_helper.rb
|
90
106
|
homepage: https://github.com/ankane/active_median
|
91
107
|
licenses:
|
@@ -107,10 +123,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
123
|
version: '0'
|
108
124
|
requirements: []
|
109
125
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.6.1
|
111
127
|
signing_key:
|
112
128
|
specification_version: 4
|
113
129
|
summary: Median for ActiveRecord
|
114
130
|
test_files:
|
115
131
|
- test/active_median_test.rb
|
132
|
+
- test/gemfiles/activerecord32.gemfile
|
133
|
+
- test/gemfiles/activerecord40.gemfile
|
134
|
+
- test/gemfiles/activerecord41.gemfile
|
135
|
+
- test/gemfiles/activerecord50.gemfile
|
116
136
|
- test/test_helper.rb
|
137
|
+
has_rdoc:
|