Weekend 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/Weekend.gemspec +25 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/Weekend.rb +81 -0
- data/lib/Weekend/version.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f18d168acca7f5b6af5d68d0bdd622ee8101ccbe
|
4
|
+
data.tar.gz: 53b58871762aa9910cf228e25b9db08f8818835e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d4dd890d935ac94f1f21b629b0d4b03f65398f26a8b4fdbc18324d478f5920901083a0797a34fd887eda20ab9245bb518586ae28282db68caa860573b3605fee
|
7
|
+
data.tar.gz: f9bcaebfae57c6fc91ba4e9997ec261aa84cb1c3792a63d44d0f1c68a0b55ed18721d8dd23f1181b8e4ed0fa81facde47b80bbb921d3a02604760ba33233e420
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Tushar Maroo
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Weekend
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/Weekend`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'Weekend'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install Weekend
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/Weekend/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/Weekend.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'Weekend/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "Weekend"
|
8
|
+
spec.version = Weekend::VERSION
|
9
|
+
spec.authors = ["Tushar Maroo"]
|
10
|
+
spec.email = ["tusharmaroo@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Gem for basic but helpful week days related queries.}
|
13
|
+
spec.description = %q{}
|
14
|
+
spec.homepage = "http://www.tusharmaroo.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
25
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "Weekend"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/Weekend.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require "Weekend/version"
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module Weekend
|
5
|
+
# Your code goes here...
|
6
|
+
# filter weekends
|
7
|
+
def self.filter_weekends start_date, end_date
|
8
|
+
result(start_date,end_date,[1,2,3,4,5])
|
9
|
+
end
|
10
|
+
|
11
|
+
#filter weekdays
|
12
|
+
def self.filter_weekdays start_date, end_date
|
13
|
+
result(start_date,end_date,[0,6])
|
14
|
+
end
|
15
|
+
|
16
|
+
# total working days(except weekends)
|
17
|
+
def self.no_of_working_days start_date, end_date
|
18
|
+
filter_weekends(start_date,end_date).count
|
19
|
+
end
|
20
|
+
|
21
|
+
# no of weekends
|
22
|
+
def self.no_of_weekends start_date, end_date
|
23
|
+
filter_weekdays(start_date,end_date).count
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.result start_date, end_date, arr_of_days
|
27
|
+
((start_date.to_date)..(end_date.to_date)).to_a.select {|k| arr_of_days.include?(k.wday)}
|
28
|
+
end
|
29
|
+
# no of sundays/mondays/tuesdays etc
|
30
|
+
|
31
|
+
# all_days = ["Sunday", "Monday", "Tuesday","Wednesday","Thrusday","Friday","Saturday"]
|
32
|
+
|
33
|
+
# def self.all_days
|
34
|
+
# ["Sunday", "Monday", "Tuesday","Wednesday","Thrusday","Friday","Saturday"]
|
35
|
+
# end
|
36
|
+
# def self.included(base)
|
37
|
+
# base.extend ClassMethods
|
38
|
+
# end
|
39
|
+
|
40
|
+
# module ClassMethods
|
41
|
+
# all_days = ["Sunday", "Monday", "Tuesday","Wednesday","Thrusday","Friday","Saturday"]
|
42
|
+
|
43
|
+
# def no_of_days(day)
|
44
|
+
# Weekend.tushar
|
45
|
+
# end
|
46
|
+
|
47
|
+
def self.no_of_sundays start_date, end_date
|
48
|
+
result(start_date,end_date,[0]).count
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.no_of_mondays start_date, end_date
|
52
|
+
result(start_date,end_date,[1]).count
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.no_of_tuesdays start_date, end_date
|
56
|
+
result(start_date,end_date,[2]).count
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.no_of_wednesdays start_date, end_date
|
60
|
+
result(start_date,end_date,[3]).count
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.no_of_thrusdays start_date, end_date
|
64
|
+
result(start_date,end_date,[4]).count
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.no_of_fridays start_date, end_date
|
68
|
+
result(start_date,end_date,[5]).count
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.no_of_saturdays start_date, end_date
|
72
|
+
result(start_date,end_date,[6]).count
|
73
|
+
end
|
74
|
+
|
75
|
+
# ["Sunday", "Monday", "Tuesday","Wednesday","Thrusday","Friday","Saturday"].each do |day|
|
76
|
+
# method_name = day.to_sym
|
77
|
+
# define_method(method_name) { no_of_days }
|
78
|
+
# end
|
79
|
+
# end
|
80
|
+
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Weekend
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tushar Maroo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
description: ''
|
56
|
+
email:
|
57
|
+
- tusharmaroo@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- Weekend.gemspec
|
71
|
+
- bin/console
|
72
|
+
- bin/setup
|
73
|
+
- lib/Weekend.rb
|
74
|
+
- lib/Weekend/version.rb
|
75
|
+
homepage: http://www.tusharmaroo.com
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.2.2
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Gem for basic but helpful week days related queries.
|
99
|
+
test_files: []
|