simple_date_fix 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 +18 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/simple_date_fix/date_time.rb +39 -0
- data/lib/simple_date_fix/item_collection.rb +22 -0
- data/lib/simple_date_fix/version.rb +3 -0
- data/lib/simple_date_fix.rb +8 -0
- data/simple_date_fix.gemspec +24 -0
- data/spec/simple_date_fix/queries_spec.rb +24 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/aws_init.rb.example +4 -0
- metadata +110 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jeremy Green
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# SimpleDateFix
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'simple_date_fix'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install simple_date_fix
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
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 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'aws/record/attributes'
|
2
|
+
require 'active_support/core_ext/time/conversions'
|
3
|
+
require 'active_support/core_ext/time/zones'
|
4
|
+
require 'active_support/core_ext/date_time/conversions'
|
5
|
+
require 'active_support/core_ext/date_time/zones'
|
6
|
+
|
7
|
+
module AWS
|
8
|
+
module Record
|
9
|
+
module Attributes
|
10
|
+
class DateTimeAttr
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# Returns a DateTime object encoded as a string (suitable for sorting).
|
15
|
+
#
|
16
|
+
# attribute.serialize(DateTime.parse('2001-01-01'))
|
17
|
+
# #=> '2001-01-01T00:00:00:Z)
|
18
|
+
#
|
19
|
+
# @param [DateTime] datetime The datetime object to serialize.
|
20
|
+
# @param [Hash] options
|
21
|
+
# @return [String] Returns the datetime object serialized to a string
|
22
|
+
# in ISO8601 format (e.g. '2011-01-02T10:11:12Z')
|
23
|
+
def self.serialize datetime, options = {}
|
24
|
+
unless datetime.is_a?(DateTime)
|
25
|
+
msg = "expected a DateTime value, got #{datetime.class}"
|
26
|
+
raise ArgumentError, msg
|
27
|
+
end
|
28
|
+
|
29
|
+
original_zone = Time.zone
|
30
|
+
Time.zone = 'UTC'
|
31
|
+
string = datetime.in_time_zone.strftime('%Y-%m-%dT%H:%M:%S%z')
|
32
|
+
Time.zone = original_zone
|
33
|
+
string
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module AWS
|
2
|
+
class SimpleDB
|
3
|
+
class ItemCollection
|
4
|
+
|
5
|
+
# We modify this method to raise the error about a missing value for placeholder.
|
6
|
+
# That code it totatlly hosing everything relating to date queries.
|
7
|
+
#
|
8
|
+
# @private
|
9
|
+
protected
|
10
|
+
def replace_named_placeholders(str, named)
|
11
|
+
named.each do |name, value|
|
12
|
+
str = str.gsub(name.to_sym.inspect, coerce_substitution(value))
|
13
|
+
end
|
14
|
+
#str.scan(/:\S+/) do |missing|
|
15
|
+
# raise ArgumentError.new("missing value for placeholder #{missing}")
|
16
|
+
#end
|
17
|
+
str
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'simple_date_fix/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "simple_date_fix"
|
8
|
+
gem.version = SimpleDateFix::VERSION
|
9
|
+
gem.authors = ["Jeremy Green"]
|
10
|
+
gem.email = ["jeremy@octolabs.com"]
|
11
|
+
gem.description = %q{Fixes for date queries in AWS::Record}
|
12
|
+
gem.summary = %q{Fixes for date queries in AWS::Record}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "aws-sdk", "~> 1.8.0"
|
21
|
+
gem.add_dependency "active_support", "~> 3.0.0"
|
22
|
+
gem.add_development_dependency "rspec", ">= 2.0.0"
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'model validations' do
|
4
|
+
|
5
|
+
let(:klass) { Class.new(AWS::Record::Base) }
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
klass.datetime_attr :timestamp
|
9
|
+
klass.create_domain
|
10
|
+
klass.each{|u| u.destroy }
|
11
|
+
sleep(2)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should save and retreive a timestamp correctly' do
|
15
|
+
stamp = Time.now
|
16
|
+
obj = klass.new :timestamp => Time.now
|
17
|
+
obj.save
|
18
|
+
AWS::SimpleDB.consistent_reads do
|
19
|
+
obj = klass.first
|
20
|
+
obj.timestamp.to_i.should == stamp.to_i
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
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
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
#
|
8
|
+
require 'aws-sdk'
|
9
|
+
require 'support/aws_init'
|
10
|
+
|
11
|
+
require "#{File.dirname(__FILE__)}/../lib/simple_date_fix"
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
15
|
+
config.run_all_when_everything_filtered = true
|
16
|
+
config.filter_run :focus
|
17
|
+
|
18
|
+
# Run specs in random order to surface order dependencies. If you find an
|
19
|
+
# order dependency and want to debug it, you can fix the order by providing
|
20
|
+
# the seed, which is printed after each run.
|
21
|
+
# --seed 1234
|
22
|
+
config.order = 'random'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_date_fix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeremy Green
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: aws-sdk
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.8.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: 1.8.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: active_support
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.0.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.0.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.0.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.0
|
62
|
+
description: Fixes for date queries in AWS::Record
|
63
|
+
email:
|
64
|
+
- jeremy@octolabs.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .rspec
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/simple_date_fix.rb
|
76
|
+
- lib/simple_date_fix/date_time.rb
|
77
|
+
- lib/simple_date_fix/item_collection.rb
|
78
|
+
- lib/simple_date_fix/version.rb
|
79
|
+
- simple_date_fix.gemspec
|
80
|
+
- spec/simple_date_fix/queries_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
- spec/support/aws_init.rb.example
|
83
|
+
homepage: ''
|
84
|
+
licenses: []
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.8.24
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: Fixes for date queries in AWS::Record
|
107
|
+
test_files:
|
108
|
+
- spec/simple_date_fix/queries_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
- spec/support/aws_init.rb.example
|