birthday 0.3.0 → 0.3.1

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: 0beab021ffb059d11117877106093599a92031bb
4
- data.tar.gz: cc85206916ef94982552cf0601ca75857a10e348
3
+ metadata.gz: d041c97e410baa0f1a643c3ba69c6f06b7b657a5
4
+ data.tar.gz: 2c8201751091cc775b6bc543895daabf4f8f8469
5
5
  SHA512:
6
- metadata.gz: 0c4d919c36a8afc054bedba02461284794d4495df66984740bd37867eb1a1054f1264b6a8798a3376c9e3f8fbc020ac8c187565bd42e5672bca1c13836bd977b
7
- data.tar.gz: da904bd18f6b327ddb98a21c6b02e0379e18ba9224eabfae48c36fddda54658e888f93b871775450f1b21ee0b5e811387fbd9688183908e0edff1e0c54daae91
6
+ metadata.gz: 41d1408df17604f7e55645b93a7d97c92545e53019031d136a0347e7b709ab4ce638fcea30ceba6892faad6bf71fe032958e3c251dd02d508bb14a276e7a9f0e
7
+ data.tar.gz: 6a976ef9175a7f9bf61f9bf93c64585ff822a6b629f4940318b99048cbcfe36a9d9ce2ffd8eeb71d57a1e380dbc81a3a4ccb486681bd3cb6ff944d0fda26ed7c
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg/*
5
5
  .rvmrc
6
6
  .DS_Store
7
7
  spec/debug.log
8
+ .idea/*
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Birthday [![Build Status](https://secure.travis-ci.org/railslove/birthday.png)](http://travis-ci.org/railslove/birthday)
2
2
 
3
- This is a small gem that hooks into ActiveRecord and allows to tag a database field (date or datetime) as birthday, allowing to find birthdays with ease.
3
+ This is a small gem that hooks into ActiveRecord and allows to tag a database field (date or datetime) as birthday, allowing to find birthdays with ease.
4
4
 
5
5
  ## How To Install
6
6
 
@@ -10,7 +10,7 @@ To install this gem, fire this command from your terminal:
10
10
 
11
11
  or add this line to your Gemfile:
12
12
 
13
- gem 'birthday', '~> 0.2.0'
13
+ gem 'birthday', '~> 0.3.0'
14
14
 
15
15
  ## Synopsis
16
16
 
@@ -79,7 +79,7 @@ Since all these are essentially scopes, there's nothing stopping you from chaini
79
79
 
80
80
  ### Your own adapters
81
81
 
82
- At this moment, this gem supports only MySQL and PostgreSQL databases. If you want to support another type of database (perhaps SQLite), you can write your own adapter.
82
+ At this moment, this gem supports MySQL, PostgreSQL and SQLite databases. If you want to support another type of database, you can write your own adapter.
83
83
 
84
84
  You can create your own birthday adapters for the ORM adapters we're not supporting yet by writing a class with a class method `scope_hash`, which will return a hash normally used in `active_record` scopes.
85
85
 
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency "mysql"
26
26
  s.add_development_dependency "delorean"
27
27
  s.add_development_dependency "pg"
28
+ s.add_development_dependency "sqlite3"
28
29
  s.add_runtime_dependency "activerecord"
29
30
  s.add_runtime_dependency "activesupport"
30
31
  end
@@ -6,6 +6,7 @@ module Railslove
6
6
  autoload :MysqlAdapter, 'railslove/acts/birthday/adapter/mysql_adapter'
7
7
  autoload :Mysql2Adapter, 'railslove/acts/birthday/adapter/mysql2_adapter'
8
8
  autoload :PostgreSQLAdapter, 'railslove/acts/birthday/adapter/postgresql_adapter'
9
+ autoload :SQLite3Adapter, 'railslove/acts/birthday/adapter/sqlite3_adapter'
9
10
 
10
11
  def self.adapter_for(connection)
11
12
  "Railslove::Acts::Birthday::Adapter::#{connection.class.name.demodulize}".constantize
@@ -0,0 +1,12 @@
1
+ # Birthday
2
+ require 'railslove/acts/birthday/adapter/sqlite_adapter'
3
+ module Railslove
4
+ module Acts #:nodoc:
5
+ module Birthday #:nodoc:
6
+ module Adapter
7
+ class SQLite3Adapter < SQLiteAdapter
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ module Railslove
2
+ module Acts
3
+ module Birthday
4
+ module Adapter
5
+ class SQLiteAdapter
6
+ def self.scope_hash(field, date_start, date_end)
7
+ date_start = date_start.to_date
8
+ if ((date_end.respond_to?(:empty?) && date_end.empty?) || !date_end)
9
+ where_sql = "strftime('%m%d', `#{field}`) = \"#{date_start.strftime('%m%d')}\""
10
+ else
11
+ date_end = date_end.to_date
12
+ if date_end.strftime('%m%d') < date_start.strftime('%m%d')
13
+ where_sql = "(strftime('%m%d', `#{field}`) >= \"0101\""
14
+ where_sql << " AND strftime('%m%d', `#{field}`) <= \"#{date_start.strftime('%m%d')}\")"
15
+ where_sql << " OR (strftime('%m%d', `#{field}`) >= \"#{date_end.strftime('%m%d')}\""
16
+ where_sql << " AND strftime('%m%d', `#{field}`) <= \"1231\")"
17
+ else
18
+ where_sql = "strftime('%m%d', `#{field}`) >= \"#{date_start.strftime('%m%d')}\" AND strftime('%m%d', `#{field}`) <= \"#{date_end.strftime('%m%d')}\""
19
+ end
20
+ end
21
+ { :conditions => where_sql }
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,7 +1,7 @@
1
1
  module Railslove
2
2
  module Acts
3
3
  module Birthday
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
6
6
  end
7
7
  end
@@ -6,4 +6,9 @@ mysql:
6
6
  postgres:
7
7
  adapter: postgresql
8
8
  database: birthday_plugin_test
9
- username: postgres
9
+ username: postgres
10
+ sqlite:
11
+ adapter: sqlite3
12
+ database: db/birthday_plugin_test.sqlite3
13
+ pool: 5
14
+ timeout: 5000
@@ -7,12 +7,14 @@ require 'delorean'
7
7
  require 'yaml'
8
8
 
9
9
  config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
10
- adapter = ENV['DB'] || 'mysql'
10
+ adapter = ENV['DB'] || 'sqlite'
11
11
  case adapter
12
12
  when 'mysql'
13
13
  require 'mysql2'
14
14
  when 'postgres'
15
15
  require 'pg'
16
+ when 'sqlite'
17
+ require 'sqlite3'
16
18
  else
17
19
  require adapter
18
20
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: birthday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Połtyn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-25 00:00:00.000000000 Z
11
+ date: 2014-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
@@ -56,70 +56,84 @@ dependencies:
56
56
  name: mysql
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: delorean
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pg
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: activerecord
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - '>='
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - '>='
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: activesupport
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - '>='
129
+ - - ">="
116
130
  - !ruby/object:Gem::Version
117
131
  version: '0'
118
132
  type: :runtime
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - '>='
136
+ - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  description: Birthday gem creates convienent methods for date and datetime fields
@@ -130,19 +144,22 @@ executables: []
130
144
  extensions: []
131
145
  extra_rdoc_files: []
132
146
  files:
133
- - .gitignore
134
- - .rspec
135
- - .travis.yml
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".travis.yml"
136
150
  - Gemfile
137
151
  - README.md
138
152
  - RUNNING_UNIT_TESTS
139
153
  - Rakefile
140
154
  - birthday.gemspec
155
+ - db/birthday_plugin_test.sqlite3
141
156
  - lib/birthday.rb
142
157
  - lib/railslove/acts/birthday/adapter.rb
143
158
  - lib/railslove/acts/birthday/adapter/mysql2_adapter.rb
144
159
  - lib/railslove/acts/birthday/adapter/mysql_adapter.rb
145
160
  - lib/railslove/acts/birthday/adapter/postgresql_adapter.rb
161
+ - lib/railslove/acts/birthday/adapter/sqlite3_adapter.rb
162
+ - lib/railslove/acts/birthday/adapter/sqlite_adapter.rb
146
163
  - lib/railslove/acts/birthday/birthday.rb
147
164
  - lib/railslove/acts/birthday/version.rb
148
165
  - spec/birthday_spec.rb
@@ -158,17 +175,17 @@ require_paths:
158
175
  - lib
159
176
  required_ruby_version: !ruby/object:Gem::Requirement
160
177
  requirements:
161
- - - '>='
178
+ - - ">="
162
179
  - !ruby/object:Gem::Version
163
180
  version: '0'
164
181
  required_rubygems_version: !ruby/object:Gem::Requirement
165
182
  requirements:
166
- - - '>='
183
+ - - ">="
167
184
  - !ruby/object:Gem::Version
168
185
  version: '0'
169
186
  requirements: []
170
187
  rubyforge_project: birthday
171
- rubygems_version: 2.0.3
188
+ rubygems_version: 2.2.2
172
189
  signing_key:
173
190
  specification_version: 4
174
191
  summary: Birthday gem allows to tag date and datetime fields in ActiveRecord