greenwich 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- greenwich (2.0.1)
4
+ greenwich (2.0.2)
5
5
  activerecord (~> 3.0)
6
6
  activesupport (~> 3.0)
7
7
  tzinfo (~> 0.3)
@@ -20,7 +20,7 @@ module Greenwich
20
20
 
21
21
  define_method time_field do
22
22
  time_zone = Greenwich::Utilities.get_time_zone(self, time_zone_field)
23
- time = read_attribute(utc_time_field)
23
+ time = send(utc_time_field)
24
24
  time = time.in_time_zone(time_zone) if time && time_zone
25
25
 
26
26
  time
@@ -60,7 +60,7 @@ module Greenwich
60
60
 
61
61
  associated_time_fields.each do |time_field|
62
62
  if greenwich_time_field_needs_conversion?(time_field, name)
63
- send("#{time_field}=".to_sym, read_attribute("#{time_field}_utc"))
63
+ send("#{time_field}=".to_sym, send("#{time_field}_utc"))
64
64
 
65
65
  greenwich_time_fields_converted["#{time_field}_utc"] = true
66
66
  end
@@ -80,7 +80,7 @@ module Greenwich
80
80
  private
81
81
  def greenwich_time_field_needs_conversion?(time_field, time_zone_field)
82
82
  (send("#{time_zone_field}_was".to_sym).nil? || send("#{time_field}_utc_was").nil?) &&
83
- read_attribute("#{time_field}_utc").present? &&
83
+ send("#{time_field}_utc").present? &&
84
84
  self.greenwich_time_fields_converted["#{time_field}_utc"].nil?
85
85
  end
86
86
  end
@@ -1,3 +1,3 @@
1
1
  module Greenwich
2
- VERSION = "2.0.1"
2
+ VERSION = '2.0.2'
3
3
  end
@@ -1,26 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- root = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
4
- db_root = File.join(root, 'db')
5
-
6
- Dir.mkdir(db_root) unless File.exists?(db_root)
7
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3',
8
- :database => "#{db_root}/conversion.sqlite")
9
-
10
- ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS 'model_with_time_zones'")
11
- ActiveRecord::Base.connection.create_table(:model_with_time_zones) do |t|
12
- t.datetime :started_at_utc
13
- t.datetime :ended_at_utc
14
- t.string :time_zone
15
- end
16
-
17
3
  class ModelWithTimeZone < ActiveRecord::Base
18
4
  include Greenwich::Conversion
19
5
 
20
- attr_accessible :started_at_utc,
21
- :ended_at_utc,
22
- :time_zone
23
-
24
6
  time_with_time_zone :started_at_utc, :time_zone => :time_zone
25
7
  time_with_time_zone :ended_at_utc, :time_zone => :time_zone
26
8
 
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
- Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
2
-
1
+ require 'sqlite3'
2
+ require 'active_record'
3
3
  require 'greenwich'
4
+
5
+ Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each {|f| require f}
@@ -0,0 +1,25 @@
1
+ test_db_root = File.expand_path('../../../tmp/', __FILE__)
2
+ Dir.mkdir test_db_root unless Dir.exists? test_db_root
3
+
4
+ SQLite3::Database.new "#{test_db_root}/test.db"
5
+
6
+ ActiveRecord::Base.establish_connection(
7
+ :adapter => 'sqlite3',
8
+ :database => 'tmp/test.db'
9
+ )
10
+
11
+ ActiveRecord::Base.connection.create_table(:model_with_time_zones) do |t|
12
+ t.datetime :started_at_utc
13
+ t.datetime :ended_at_utc
14
+ t.string :time_zone
15
+ end
16
+
17
+ RSpec.configure do |config|
18
+ config.before(:each) do
19
+ ActiveRecord::Base.connection.execute 'DELETE FROM model_with_time_zones'
20
+ end
21
+
22
+ config.after(:suite) do
23
+ `rm -f ./tmp/test.db`
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greenwich
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-18 00:00:00.000000000 Z
13
+ date: 2012-10-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -200,6 +200,7 @@ files:
200
200
  - lib/greenwich/version.rb
201
201
  - spec/conversion_spec.rb
202
202
  - spec/spec_helper.rb
203
+ - spec/support/active_record.rb
203
204
  - spec/support/focused.rb
204
205
  - spec/support/pending.rb
205
206
  - spec/utilities_spec.rb
@@ -231,6 +232,7 @@ summary: Allowing users to select dates with custom time zones since 2011.
231
232
  test_files:
232
233
  - spec/conversion_spec.rb
233
234
  - spec/spec_helper.rb
235
+ - spec/support/active_record.rb
234
236
  - spec/support/focused.rb
235
237
  - spec/support/pending.rb
236
238
  - spec/utilities_spec.rb