fortnight 0.0.1rc1 → 0.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.
data/.gitignore CHANGED
@@ -15,4 +15,3 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- /nbproject/private/
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2012 Néstor Coppi
2
- Gem for fortnights global-scope
2
+
3
3
  MIT License
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
data/README.md CHANGED
@@ -1,47 +1,29 @@
1
1
  # Fortnight
2
2
 
3
- Scope to difference by first and second half month.
4
-
5
- The gem work separing the month of a year in two half, first - 15th and 16th - last day
3
+ TODO: Write a gem description
6
4
 
7
5
  ## Installation
8
6
 
9
- Add the gem to your Gemfile
7
+ Add this line to your application's Gemfile:
10
8
 
11
9
  gem 'fortnight'
12
10
 
13
- and run:
11
+ And then execute:
14
12
 
15
- $ bundle install/update
13
+ $ bundle
16
14
 
17
- Add in the models that we want to use
15
+ Or install it yourself as:
18
16
 
19
- include Fortnight
17
+ $ gem install fortnight
20
18
 
21
19
  ## Usage
22
20
 
23
- It's very simple, the syntax is the next:
24
-
25
- Model.in_fortnight(year, month, options)
26
-
27
- 'options' for now are only :field and :half
28
- :field ALWAYS HAVE TO BE A TIME FIELD
29
- :half is to get the first (by default) or the second (as symbol)
30
-
31
- Examples:
32
-
33
- Customer.in_fortnight(2012, 04)
34
- We'll get the customers created_at between 2012-04-01 00:00 AND 2012-04-15 23:59:59
35
-
36
- Customer.in_fortnight(2012, 04, half: :second)
37
- We'll get the customers created_at between 2012-04-15 23:59:59 AND 2012-04-30 23:59:59
38
-
39
- Customer.in_fortnight(2012, 05, half: :second)
40
- We'll get the customers created_at between 2012-05-15 23:59:59 AND 2012-05-31 23:59:59
41
-
42
- Customer.in_fortnight(2012, 04, field: 'updated_at')
43
- We'll get the customers updated_at between 2012-04-01 00:00 AND 2012-04-15 23:59
21
+ TODO: Write usage instructions here
44
22
 
45
- Customer.in_fortnight(2012, 04, half: :second, field: 'updated_at')
46
- We'll get the customers updated_at between 2012-04-15 23:59:59 AND 2012-04-30 23:59:59
23
+ ## Contributing
47
24
 
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/fortnight.gemspec CHANGED
@@ -14,6 +14,4 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "fortnight"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Fortnight::VERSION
17
-
18
- gem.add_dependency 'rails', '>= 3.1.0'
19
17
  end
data/lib/fortnight.rb CHANGED
@@ -1,24 +1,19 @@
1
1
  require "fortnight/version"
2
2
 
3
3
  module Fortnight
4
- self.included(clase)
5
- clase.extend ClassMethods
6
- end
7
-
8
- module ClassMethods
9
- def in_fortnight(year, month, options={})
4
+ def in_fortnight(year, month, options={})
10
5
 
11
- begin_of_month = Time.new(year, month)
12
- half_of_month = begin_of_month.advance(days: 14).end_of_day
13
- final_of_month = begin_of_month.end_of_month.end_of_day
6
+ begin_of_month = Time.new(year, month)
7
+ half_of_month = begin_of_month.advance(days: 14).end_of_day
8
+ final_of_month = begin_of_month.end_of_month.end_of_day
14
9
 
15
- start = options[:half] == :second ? half_of_month : begin_of_month
16
- finish = options[:half] == :second ? final_of_month : half_of_month
10
+ start = options[:half] == :second ? half_of_month : begin_of_month
11
+ finish = options[:half] == :second ? final_of_month : half_of_month
17
12
 
18
- field = options[:field] || 'created_at'
13
+ field = options[:field] || 'created_at'
19
14
 
20
- scope = where("#{field} >= :s AND #{field} <= :f", s: start, f: finish)
21
- scope = scope.order(options[:order]) if options[:order]
22
- scope
23
- end
15
+ scope = where("#{field} >= :s AND #{field} <= :f", s: start, f: finish)
16
+ scope = scope.order(options[:order]) if options[:order]
17
+ scope
24
18
  end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Fortnight
2
- VERSION = "0.0.1rc1"
2
+ VERSION = "0.0.1"
3
3
  end
metadata CHANGED
@@ -1,32 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fortnight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1rc1
5
- prerelease: 5
4
+ version: 0.0.1
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Néstor Coppi
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-18 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 3.1.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 3.1.0
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
+ dependencies: []
30
14
  description: Scope to difference by first and second half month
31
15
  email:
32
16
  - nestorcoppi@gmail.com
@@ -57,9 +41,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
41
  required_rubygems_version: !ruby/object:Gem::Requirement
58
42
  none: false
59
43
  requirements:
60
- - - ! '>'
44
+ - - ! '>='
61
45
  - !ruby/object:Gem::Version
62
- version: 1.3.1
46
+ version: '0'
63
47
  requirements: []
64
48
  rubyforge_project:
65
49
  rubygems_version: 1.8.24