season 0.0.6 → 0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad71e236ae386e4b79309af41447cbba18b26833
4
- data.tar.gz: 946198f7bd269368e8123916eec88f0199671704
3
+ metadata.gz: 79b28b9578876f09d5400f07f274fa4b09403f73
4
+ data.tar.gz: f92588ed36959b02592fdd52a654aa77651da231
5
5
  SHA512:
6
- metadata.gz: 161a85053768d7d9a72603be1971476460bbdd25fb39bdf5cc2f8143f334aa3fa2adb43417a10c42b168211442d625e7af5ae16ac87fa732808c2234311fc941
7
- data.tar.gz: ead7c4c8946153bc4c70485d6f1af7964f0d3761000119af6290780d90b791981a9673349968be7cfc5f9f1ad61a2d0eadbaf6c667ccfade2d57b09e4c4dcdc9
6
+ metadata.gz: 97af23dc94be0015526dfee136ce23b3d14e163472091116efc9240560369ecf635b12150ecced3448a8bb60a4447f7e3312cbc5253a01c0f09b9b868ab53fdb
7
+ data.tar.gz: dae5f32b172de1dff47a1d0a9c397039c7cec56d5842f7a97fa1af95c5188ea1fe8456c8c096e2e90c9ac5fc2f3f1f95628207b4344490f5f642a107e028a9e8
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ require: rubocop-rspec
2
+
3
+ Documentation:
4
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.5
6
+ - 2.2.0
7
+ before_install:
8
+ - gem install bundler
9
+ gemfile:
10
+ - Gemfile
11
+ rvm:
12
+ - 1.9.3
13
+ - 2.0.0
14
+ - 2.1.5
15
+ - 2.2.0
16
+ addons:
17
+ code_climate:
18
+ repo_token: 55c323e5e1588037c7eda2a3d4267d788ba4e855f306d6a877577a11e00e47a2
19
+ notifications:
20
+ email:
21
+ recipients:
22
+ - jdscosta91@gmail.com
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem "codeclimate-test-reporter", group: :test, require: nil
4
+
3
5
  # Specify your gem's dependencies in season.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Season
2
+ [![Gem Version](https://badge.fury.io/rb/season.svg)](http://badge.fury.io/rb/season) [![Code Climate](https://codeclimate.com/github/joaodiogocosta/season/badges/gpa.svg)](https://codeclimate.com/github/joaodiogocosta/season) [![Build Status](https://travis-ci.org/joaodiogocosta/season.svg?branch=master)](https://travis-ci.org/joaodiogocosta/season)
2
3
 
3
4
  Season let's you easily query your Models by a specific date/time.
4
5
 
@@ -7,7 +8,7 @@ Season let's you easily query your Models by a specific date/time.
7
8
  Add this line to your application's Gemfile:
8
9
 
9
10
  ```ruby
10
- gem 'season', '~> 0.0.6'
11
+ gem 'season', '~> 0.1'
11
12
  ```
12
13
 
13
14
  And then execute:
@@ -20,7 +21,7 @@ Or install it yourself as:
20
21
 
21
22
  ## Requirements
22
23
 
23
- In this first version Season only supports ActiveRecord, but we plan to also support MongoID in a very short period of time.
24
+ In this first version Season only supports ActiveRecord, but we plan to also support Mongoid in a very short period of time.
24
25
 
25
26
  ## Usage
26
27
 
@@ -33,9 +34,7 @@ Right now, Season gives you the following helper methods:
33
34
 
34
35
  class User < ActiveRecord::Base
35
36
  include Season::Scopes
36
-
37
37
  ...
38
-
39
38
  end
40
39
 
41
40
  # And then use it as:
@@ -52,7 +51,6 @@ User.updated_between(Time.now - 1.week, Time.now)
52
51
 
53
52
  They are chainable, so you can also do things like this:
54
53
  ```ruby
55
-
56
54
  User.where(id: [1, 2, 3]).created_before(Time.now)
57
55
  User.updated_after('01-01-2015').order(created_at: :asc)
58
56
  ```
@@ -65,9 +63,7 @@ The scopes are not included by default in your models. To use them you need to i
65
63
  ```ruby
66
64
  class User < ActiveRecord::Base
67
65
  include Season::Scopes
68
-
69
66
  ...
70
-
71
67
  end
72
68
  ```
73
69
 
@@ -81,11 +77,11 @@ end
81
77
 
82
78
  ## To Do
83
79
 
84
- - Tests!
80
+ - Even more tests
85
81
  - Support other ORMs (Mongoid, 'insert-more-here')
86
82
  - Add Error Handling
83
+ - Add helpers for instances (like `User.first.created_before?('01-02-2015')`)
87
84
  - Support user-defined date/time columns (through configuration)
88
- - Support configuration for enabling/disabling Season for all models
89
85
 
90
86
  ## Contributing
91
87
 
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ require 'rspec/core/rake_task'
4
+ task :default => :spec
5
+ RSpec::Core::RakeTask.new
6
+
@@ -15,7 +15,6 @@ module Season
15
15
  where("#{table_name}.created_at > ?", date)
16
16
  end
17
17
 
18
-
19
18
  def self.updated_before(date)
20
19
  where("#{table_name}.updated_at < ?", date)
21
20
  end
@@ -1,3 +1,3 @@
1
1
  module Season
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1"
3
3
  end
data/season.gemspec CHANGED
@@ -18,10 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = Gem::Requirement.new('>= 2.0.0')
21
+ spec.required_ruby_version = Gem::Requirement.new('>= 1.9.3')
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.7"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.1"
26
26
  spec.add_development_dependency "activerecord", "~> 4.0"
27
+ spec.add_development_dependency "rubocop", "~> 0.29"
28
+ spec.add_development_dependency "rubocop-rspec", "~> 1.2"
29
+ spec.add_development_dependency "sqlite3", "~> 1.3"
27
30
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'active_record'
3
+ require 'season/active_record/scopes'
4
+
5
+ silence_warnings do
6
+ ActiveRecord::Migration.verbose = false
7
+ ActiveRecord::Base.logger = Logger.new(nil)
8
+ ActiveRecord::Base.establish_connection(
9
+ adapter: 'sqlite3', database: ':memory:')
10
+ end
11
+
12
+ ActiveRecord::Base.connection.instance_eval do
13
+ create_table :users do |t|
14
+ t.timestamps null: true
15
+ end
16
+ end
17
+
18
+ class User < ActiveRecord::Base
19
+ include Season::Scopes
20
+ end
21
+
22
+ RSpec.describe Season::Scopes do
23
+ subject { User }
24
+
25
+ describe 'class methods' do
26
+ describe 'with default timestamps' do
27
+ it 'responds to created_(before/after/between)' do
28
+ expect(subject).to respond_to(:created_before, :created_after)
29
+ .with(1).argument
30
+ expect(subject).to respond_to(:created_between).with(2).arguments
31
+ end
32
+
33
+ it 'responds to updated_(before/after/between)' do
34
+ expect(subject).to respond_to(:updated_before, :updated_after)
35
+ .with(1).argument
36
+ expect(subject).to respond_to(:updated_between).with(2).arguments
37
+ end
38
+ end
39
+ end
40
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,89 +1,13 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
- # file to always be loaded, without a need to explicitly require it in any files.
5
- #
6
- # Given that it is always loaded, you are encouraged to keep this file as
7
- # light-weight as possible. Requiring heavyweight dependencies from this file
8
- # will add to the boot time of your test suite on EVERY test run, even for an
9
- # individual file that may not need all of that loaded. Instead, consider making
10
- # a separate helper file that requires the additional dependencies and performs
11
- # the additional setup, and require it from the spec files that actually need it.
12
- #
13
- # The `.rspec` file also contains a few flags that are not defaults but that
14
- # users commonly want.
15
- #
16
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
1
+ require 'season'
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+
17
5
  RSpec.configure do |config|
18
- # rspec-expectations config goes here. You can use an alternate
19
- # assertion/expectation library such as wrong or the stdlib/minitest
20
- # assertions if you prefer.
21
6
  config.expect_with :rspec do |expectations|
22
- # This option will default to `true` in RSpec 4. It makes the `description`
23
- # and `failure_message` of custom matchers include text for helper methods
24
- # defined using `chain`, e.g.:
25
- # be_bigger_than(2).and_smaller_than(4).description
26
- # # => "be bigger than 2 and smaller than 4"
27
- # ...rather than:
28
- # # => "be bigger than 2"
29
7
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
8
  end
31
9
 
32
- # rspec-mocks config goes here. You can use an alternate test double
33
- # library (such as bogus or mocha) by changing the `mock_with` option here.
34
10
  config.mock_with :rspec do |mocks|
35
- # Prevents you from mocking or stubbing a method that does not exist on
36
- # a real object. This is generally recommended, and will default to
37
- # `true` in RSpec 4.
38
11
  mocks.verify_partial_doubles = true
39
12
  end
40
-
41
- # The settings below are suggested to provide a good initial experience
42
- # with RSpec, but feel free to customize to your heart's content.
43
- =begin
44
- # These two settings work together to allow you to limit a spec run
45
- # to individual examples or groups you care about by tagging them with
46
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
- # get run.
48
- config.filter_run :focus
49
- config.run_all_when_everything_filtered = true
50
-
51
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
- # For more details, see:
53
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
- config.disable_monkey_patching!
57
-
58
- # This setting enables warnings. It's recommended, but in some cases may
59
- # be too noisy due to issues in dependencies.
60
- config.warnings = true
61
-
62
- # Many RSpec users commonly either run the entire suite or an individual
63
- # file, and it's useful to allow more verbose output when running an
64
- # individual spec file.
65
- if config.files_to_run.one?
66
- # Use the documentation formatter for detailed output,
67
- # unless a formatter has already been configured
68
- # (e.g. via a command-line flag).
69
- config.default_formatter = 'doc'
70
- end
71
-
72
- # Print the 10 slowest examples and example groups at the
73
- # end of the spec run, to help surface which specs are running
74
- # particularly slow.
75
- config.profile_examples = 10
76
-
77
- # Run specs in random order to surface order dependencies. If you find an
78
- # order dependency and want to debug it, you can fix the order by providing
79
- # the seed, which is printed after each run.
80
- # --seed 1234
81
- config.order = :random
82
-
83
- # Seed global randomization in this process using the `--seed` CLI option.
84
- # Setting this allows you to use `--seed` to deterministically reproduce
85
- # test failures related to randomization by passing the same `--seed` value
86
- # as the one that triggered the failure.
87
- Kernel.srand config.seed
88
- =end
89
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: season
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: '0.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joao Diogo Costa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,48 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.29'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.29'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.3'
69
111
  description: Season lets you query your ActiveRecord models by a specified period
70
112
  of time in an easier way.
71
113
  email:
@@ -76,6 +118,8 @@ extra_rdoc_files: []
76
118
  files:
77
119
  - ".gitignore"
78
120
  - ".rspec"
121
+ - ".rubocop.yml"
122
+ - ".travis.yml"
79
123
  - Gemfile
80
124
  - LICENSE.txt
81
125
  - README.md
@@ -85,7 +129,7 @@ files:
85
129
  - lib/season/configuration.rb
86
130
  - lib/season/version.rb
87
131
  - season.gemspec
88
- - spec/scopes.rb
132
+ - spec/active_record/scopes_spec.rb
89
133
  - spec/spec_helper.rb
90
134
  homepage: https://github.com/joaodiogocosta/season
91
135
  licenses:
@@ -99,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
143
  requirements:
100
144
  - - ">="
101
145
  - !ruby/object:Gem::Version
102
- version: 2.0.0
146
+ version: 1.9.3
103
147
  required_rubygems_version: !ruby/object:Gem::Requirement
104
148
  requirements:
105
149
  - - ">="
@@ -113,5 +157,5 @@ specification_version: 4
113
157
  summary: Season lets you query your ActiveRecord models by a specified period of time
114
158
  in an easier way.
115
159
  test_files:
116
- - spec/scopes.rb
160
+ - spec/active_record/scopes_spec.rb
117
161
  - spec/spec_helper.rb
data/spec/scopes.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Scopes do
4
- pending "write it"
5
- end