greenwich 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 ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in greenwich.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2011 The Kompanee - Jeff Felchner
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 NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,116 @@
1
+ Greenwich...
2
+ ================================
3
+
4
+ ...has been helping Rails developers work with custom time zones since 2011.
5
+
6
+ ![Greenwich](http://www.thekompanee.com/public_files/greenwich.jpg)
7
+
8
+ Rails 2.1 brought much-needed improvements to working with time zones in Rails.
9
+ But even now, with Rails 3 out and kicking ass, allowing users to _specify_ the time
10
+ zone they would like to use for a given date is still a PITA.
11
+
12
+ Enter Greenwich
13
+
14
+ You too can now give your users the **POWER** of choosing a time zone via a
15
+ standard web form. Maybe you have a system that allows people to enter appointments
16
+ for Widgets, Inc. Since they make the best widgets in the world, they're very popular
17
+ internationally. You would like a system which allows your users to enter not just the
18
+ _time_ of an appointment but also the time _zone_ in which the appointment is located.
19
+
20
+ Still interested? Read on intrepid traveler.
21
+
22
+ Installation
23
+ --------------------------------
24
+
25
+ gem install greenwich
26
+
27
+ Initialization
28
+ --------------------------------
29
+
30
+ You add Greenwich to your models like so:
31
+
32
+ date_with_time_zone :field_name
33
+
34
+ By default Greenwich looks for a few different columns in your model depending on the
35
+ field name you passed in. Let's look at some examples.
36
+
37
+ Meta-Programming Magic
38
+ --------------------------------
39
+
40
+ ** DateTime Field Lookup **
41
+ Greenwich will lookup `:field_name` based on a couple different standard column suffixes.
42
+
43
+ * `_at`
44
+ * `_datetime`
45
+
46
+ For example, if you specify:
47
+
48
+ date_with_time_zone :start
49
+
50
+ Greenwich will look for the columns `start_at` and `start_datetime` (in that order).
51
+
52
+ ** Time Zone Field Lookup **
53
+ Time Zone lookups default to a per-field or per-model specification. If you specify:
54
+
55
+ date_with_time_zone :start
56
+
57
+ Greenwich will lookup the time zone from `:start_time_zone` first, and if it doesn't
58
+ find a field by that name, it will use `:time_zone`.
59
+
60
+ Usage
61
+ --------------------------------
62
+ * Note: These examples assume the application's default time zone is set to UTC.
63
+ If you have modified the default time zone, directly accessing your DateTime field
64
+ will render it in _that_ time zone and not UTC.
65
+
66
+ When working with your instances, Greenwich will convert to the proper time zone when
67
+ you access it. So if you've previously saved a DateTime like this:
68
+
69
+ my_model.start = Time.strptime('2011-07-04 13:00:00 -600 CST')
70
+
71
+ Then that will result in your model returning the following values (assuming these
72
+ particular columns exist in the database):
73
+
74
+ my_model.start_at # => 2011-07-04 19:00:00 GMT
75
+ my_model.start_datetime # => 2011-07-04 19:00:00 GMT
76
+ my_model.start_time_zone # => 'Central Standard Time'
77
+ my_model.time_zone # => 'Central Standard Time'
78
+
79
+ Whereas asking Greenwich for the value of `start` will result in:
80
+
81
+ my_model.start # => 2011-07-04 13:00:00 CST
82
+
83
+ If you then change your time zone:
84
+
85
+ my_model.start_time_zone = 'Eastern Standard Time'
86
+
87
+ Then calling the attributes on your model will result in the following:
88
+
89
+ my_model.start_at # => 2011-07-04 19:00:00 GMT
90
+ my_model.start_datetime # => 2011-07-04 19:00:00 GMT
91
+ my_model.start_time_zone # => 'Eastern Standard Time'
92
+ my_model.time_zone # => 'Eastern Standard Time'
93
+
94
+ And again, asking Greenwich for the value of `start` will result in:
95
+
96
+ my_model.start # => 2011-07-04 13:00:00 EST
97
+
98
+ Issues
99
+ ------
100
+
101
+ If you have problems, please create a [Github issue](https://github.com/jfelchner/validates_truthiness/issues).
102
+
103
+ Credits
104
+ -------
105
+
106
+ ![thekompanee](http://www.thekompanee.com/public_files/kompanee-github-readme-logo.png)
107
+
108
+ validates_truthiness is maintained by [The Kompanee, Ltd.](http://www.thekompanee.com)
109
+
110
+ The names and logos for The Kompanee are trademarks of The Kompanee, Ltd.
111
+
112
+ License
113
+ -------
114
+
115
+ validates_truthiness is Copyright © 2011 The Kompanee. It is free software, and may be redistributed under the terms specified in the LICENSE file.
116
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/greenwich.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "greenwich/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.rubygems_version = '1.4.2'
7
+
8
+ s.name = "greenwich"
9
+ s.rubyforge_project = "greenwich"
10
+
11
+ s.version = Greenwich::VERSION
12
+ s.platform = Gem::Platform::RUBY
13
+
14
+ s.authors = ["thekompanee", "jfelchner"]
15
+ s.email = ["support@thekompanee.com"]
16
+ s.homepage = "http://github.com/jfelchner/greenwich"
17
+
18
+ s.summary = %q{Allowing users to select dates with custom time zones since 2011.}
19
+ s.description = %q{Store all of your times in the database as UTC but want to give your users the ability to choose a custom time zone for each instance of a DateTime field?}
20
+
21
+ s.rdoc_options = ["--charset = UTF-8"]
22
+ s.extra_rdoc_files = %w[README.md LICENSE]
23
+
24
+ #= Manifest =#
25
+ s.files = `git ls-files`.split("\n")
26
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
+ s.require_paths = ["lib"]
29
+ #= Manifest =#
30
+
31
+ s.add_development_dependency('bundler', '~> 1.0.15')
32
+ s.add_development_dependency('rspec', '~> 2.6.0')
33
+ s.add_development_dependency('yard', '~> 0.7.1')
34
+ end
data/lib/greenwich.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "greenwich/version"
2
+
3
+ module Greenwich
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Greenwich
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: greenwich
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - thekompanee
9
+ - jfelchner
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-07-03 00:00:00.000000000 -05:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: &2153525320 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.15
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *2153525320
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: &2153524820 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 2.6.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *2153524820
38
+ - !ruby/object:Gem::Dependency
39
+ name: yard
40
+ requirement: &2153524360 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.7.1
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *2153524360
49
+ description: Store all of your times in the database as UTC but want to give your
50
+ users the ability to choose a custom time zone for each instance of a DateTime field?
51
+ email:
52
+ - support@thekompanee.com
53
+ executables: []
54
+ extensions: []
55
+ extra_rdoc_files:
56
+ - README.md
57
+ - LICENSE
58
+ files:
59
+ - .gitignore
60
+ - Gemfile
61
+ - Rakefile
62
+ - greenwich.gemspec
63
+ - lib/greenwich.rb
64
+ - lib/greenwich/version.rb
65
+ - README.md
66
+ - LICENSE
67
+ has_rdoc: true
68
+ homepage: http://github.com/jfelchner/greenwich
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --charset = UTF-8
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project: greenwich
89
+ rubygems_version: 1.6.2
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Allowing users to select dates with custom time zones since 2011.
93
+ test_files: []