shabbat 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ff6b3922dfc6b18a37a15069154218e0257364bb
4
+ data.tar.gz: 55207cb43e712488fc05eac0e657c4d1d827f907
5
+ SHA512:
6
+ metadata.gz: 4ff72a82a96da60ae9779c322688640b3e434051c9c7b4c84bd34f4fcdd84ba2870f649af097adbbf6e7257c85577ac3520e161b5b5e766da191085d47d834a2
7
+ data.tar.gz: e164e96f63c994aeebdec7fe33a85a1896c1258f097b9af7c6ce49a3d6e197cca70c2061487028a7d1a85dfbba726855b13de943e0c0a779fdd04548081828a7
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shabbat.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 adam klein
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,44 @@
1
+ # Shabbat
2
+
3
+ The most Kosher GEM in the web!
4
+
5
+ Gives all the methods a jewish programmer needs
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'shabbat'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install shabbat
20
+
21
+ ## Usage
22
+
23
+ #### Date & Time methods:
24
+
25
+ Date.today.shabbat?
26
+ Time.now.shabbat?
27
+ Date.next_shabbat
28
+ Date.last_shabbat
29
+ 10.days.from_now.last_shabbat
30
+ 10.days.from_now.next_shabbat
31
+
32
+ ## Some ideas for the future:
33
+
34
+ Date.next_yom_kipur
35
+ Date.today_.to_heb
36
+ Date.today.meuberet?
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ task :default do
3
+ system('rspec spec')
4
+ end
@@ -0,0 +1,11 @@
1
+ class Date
2
+ include Shabbat
3
+ end
4
+
5
+ class DateTime
6
+ include Shabbat
7
+ end
8
+
9
+ class Time
10
+ include Shabbat
11
+ end
@@ -0,0 +1,31 @@
1
+ require "active_support/all"
2
+ module Shabbat
3
+ extend ActiveSupport::Concern
4
+ def shabbat?
5
+ to_date.saturday?
6
+ end
7
+ def next_shabbat
8
+ if shabbat?
9
+ to_date + 1.week
10
+ else
11
+ last_shabbat + 1.week
12
+ end
13
+ end
14
+ def last_shabbat
15
+ if shabbat?
16
+ to_date - 1.week
17
+ else
18
+ day = to_date
19
+ diff = day.wday + 1
20
+ day - diff.days
21
+ end
22
+ end
23
+ module ClassMethods
24
+ def next_shabbat
25
+ Date.today.next_shabbat
26
+ end
27
+ def last_shabbat
28
+ Date.today.last_shabbat
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module Shabbat
2
+ VERSION = "0.0.2"
3
+ end
data/lib/shabbat.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "shabbat/version"
2
+ require "shabbat/shabbat"
3
+ require "shabbat/overrides"
4
+
5
+ module Shabbat
6
+ # Nothing here...
7
+ end
data/shabbat.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shabbat/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "shabbat"
8
+ spec.version = Shabbat::VERSION
9
+ spec.authors = ["adam klein"]
10
+ spec.email = ["adam@500tech.com"]
11
+ spec.summary = "All the jewish methods you need"
12
+ spec.description = "The most Kosher GEM in the web. Extends Date and Time classes to add common jewish methods like Date.today.shabbat?, Date.next_shabbat, etc."
13
+ spec.homepage = "http://github.com/500tech/shabbat"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "activesupport"
22
+
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", [">= 2.2.0"]
26
+ spec.add_development_dependency "timecop"
27
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Shabbat do
4
+ Dates = {
5
+ friday: Date.parse('25/10/2013'),
6
+ next_saturday: Date.parse('2/11/2013'),
7
+ saturday: Date.parse('26/10/2013'),
8
+ last_saturday: Date.parse('19/10/2013'),
9
+ }
10
+ context 'on friday' do
11
+ around do |example|
12
+ Timecop.freeze(Dates[:friday])
13
+ example.run
14
+ Timecop.return
15
+ end
16
+ describe '.next_shabbat' do
17
+ it {Date.next_shabbat.should eq Dates[:saturday]}
18
+ it {Dates[:friday].next_shabbat.should eq Dates[:saturday]}
19
+ end
20
+ describe '.last_shabbat' do
21
+ it {Date.last_shabbat.should eq Dates[:last_saturday]}
22
+ it {Dates[:friday].last_shabbat.should eq Dates[:last_saturday]}
23
+ end
24
+ describe '.shabbat?' do
25
+ it {Dates[:friday].shabbat?.should be_false}
26
+ end
27
+ end
28
+ context 'on saturday' do
29
+ around do |example|
30
+ Timecop.freeze(Dates[:saturday])
31
+ example.run
32
+ Timecop.return
33
+ end
34
+ describe '.next_shabbat' do
35
+ it {Date.next_shabbat.should eq Dates[:next_saturday]}
36
+ it {Dates[:saturday].next_shabbat.should eq Dates[:next_saturday]}
37
+ end
38
+ describe '.last_shabbat' do
39
+ it {Date.last_shabbat.should eq Dates[:last_saturday]}
40
+ it {Dates[:saturday].last_shabbat.should eq Dates[:last_saturday]}
41
+ end
42
+ describe '.shabbat?' do
43
+ it {Dates[:saturday].shabbat?.should be_true}
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,19 @@
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
+ require 'shabbat'
8
+ require 'timecop'
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shabbat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - adam klein
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: timecop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: The most Kosher GEM in the web. Extends Date and Time classes to add
84
+ common jewish methods like Date.today.shabbat?, Date.next_shabbat, etc.
85
+ email:
86
+ - adam@500tech.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .rspec
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/shabbat.rb
98
+ - lib/shabbat/overrides.rb
99
+ - lib/shabbat/shabbat.rb
100
+ - lib/shabbat/version.rb
101
+ - shabbat.gemspec
102
+ - spec/shabbat_spec.rb
103
+ - spec/spec_helper.rb
104
+ homepage: http://github.com/500tech/shabbat
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.0.8
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: All the jewish methods you need
128
+ test_files:
129
+ - spec/shabbat_spec.rb
130
+ - spec/spec_helper.rb