birthdays 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2967c905ab88ac1c1a5f9dfbc755b04917ed16f5d93289e28a539ac65d2a192d
4
+ data.tar.gz: a6e5551ddb9c0d4d8e6e3b24c7ea8ce97ebb889c32528b82f1f154824e6dac04
5
+ SHA512:
6
+ metadata.gz: 51f9ee0acbec40975b9b08b783d129f5f7ff093052f4cc0489292f1791a3defaebb3e41ef0c5defd7c8ecf3e51c35aa54c752ae801d15ab3dbec1a0d00037df1
7
+ data.tar.gz: 4768b1415ef5bdf1dc010ea2947b1fac2b7d914da47f06d3b7ecd03ca337d38b5b572d86811bd37a6937285d1588c0afc5105573d5326f8e19026edce1ba30d4
@@ -0,0 +1,6 @@
1
+ /.bundle
2
+ /.yardoc/
3
+ /Gemfile.lock
4
+ /doc/
5
+ /pkg/
6
+ /vendor/cache/*.gem
@@ -0,0 +1,9 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ - 2.3.3
6
+ - 2.2.6
7
+ #- ruby-head
8
+ #- ruby-head-clang
9
+ script: bundle exec rake test
@@ -0,0 +1,6 @@
1
+ --markup markdown
2
+ --title "birthdays Documentation"
3
+ --protected
4
+ -
5
+ ChangeLog.md
6
+ LICENSE.txt
@@ -0,0 +1,22 @@
1
+ == Release v0.1.2 (2020-02-18) ==
2
+
3
+ * Bump version
4
+ * Update Rakefile
5
+ * Update Rakefile
6
+ * Copyright
7
+ * ActiveSupport 5 depends on ruby >=2.2.2
8
+ * In travis the test should be under bundle exec
9
+ * Update dependencies
10
+ * We need the git version of Drain for now
11
+ * Configure travis and streamline rake and test files
12
+ * Copyright
13
+ * Copyright
14
+ * The library name changed
15
+
16
+ == Release v0.1.0 and v0.1.1 (2015-02-24) ==
17
+
18
+ * Forgot dependency!
19
+ * Clean up Rakefile
20
+ * libraries + description
21
+ * Initial commit.
22
+
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'drain', :github => 'DamienRobert/drain'
5
+
6
+ group :development do
7
+ gem 'kramdown'
8
+ end
@@ -0,0 +1,20 @@
1
+ Copyright © 2015–2020 Damien Robert
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # birthdays
2
+
3
+ * [Homepage](https://github.com/DamienRobert/birthdays#readme)
4
+ * [Issues](https://github.com/DamienRobert/birthdays/issues)
5
+ * [Documentation](http://rubydoc.info/gems/birthdays)
6
+ * [Email](mailto:Damien.Olivier.Robert+gems at gmail.com)
7
+
8
+ [![Gem Version](https://img.shields.io/gem/v/birthdays.svg)](https://rubygems.org/gems/birthdays)
9
+ [![Build Status](https://travis-ci.org/DamienRobert/birthdays.svg?branch=master)](https://travis-ci.org/DamienRobert/birthdays)
10
+
11
+ ## Description
12
+
13
+ Show the birthdays in a time period so you don't forget them!
14
+
15
+ ## Features
16
+
17
+ Use a wrapper around Chronic so that the time specification is quite
18
+ powerful.
19
+
20
+ ## Examples
21
+
22
+ By default use the file ~/.birthdays.yaml, that you can fill like:
23
+
24
+ "Father's Day": "3rd Sunday in June"
25
+ "Christmas": "25 December"
26
+ "New Year": "01 January"
27
+ "John Doe": 1970-01-01
28
+
29
+ Then to see the birthdays for next week just use
30
+
31
+ birthdays 'now..in 7 days'
32
+
33
+ ## Install
34
+
35
+ $ gem install birthdays
36
+
37
+ ## Synopsis
38
+
39
+ $ birthdays time..period
40
+
41
+ ## Copyright
42
+
43
+ Copyright © 2015–2017 Damien Robert
44
+
45
+ MIT License. See [LICENSE.txt](./LICENSE.txt) for details.
@@ -0,0 +1,26 @@
1
+ require 'rake'
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |test|
5
+ test.libs << 'test'
6
+ test.pattern = 'test/**/test_*.rb'
7
+ test.verbose = true
8
+ end
9
+
10
+ begin
11
+ require 'yard'
12
+ YARD::Rake::YardocTask.new
13
+ rescue LoadError => e
14
+ task :yard do
15
+ warn e.message
16
+ end
17
+ end
18
+ task :doc => :yard
19
+
20
+ begin
21
+ require 'dr/rake_gems'
22
+ Gem::MyTasks.new
23
+ rescue LoadError => e
24
+ warn e.message
25
+ end
26
+
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ require 'birthdays'
3
+
4
+ if __FILE__ == $0
5
+ require "optparse"
6
+ opts={file: "#{ENV['HOME']}/.birthdays.yaml"}
7
+ optparse = OptionParser.new do |opt|
8
+ opt.banner = "Output coming birthdays"
9
+ opt.on("--file=FILE", "Birthdays file") do |v| opts[:file]=v end
10
+ opt.on("--[no-]age", "Switch to age mode") do |v| opts[:age]=v end
11
+ opt.on("--[no-]crontab", "When run under a crontab") do |v| opts[:crontab]=v end
12
+ end
13
+ optparse.parse!
14
+
15
+ persons=YAML.load_file(opts[:file]).map do |name,bday|
16
+ Person.new(name,bday)
17
+ end
18
+
19
+ args=ARGV
20
+ args=[Time.now] if args.empty?
21
+ if opts[:age]
22
+ args.each do |today|
23
+ today = DR::TimeParse.parse(today)
24
+ puts "On #{today}, the ages are", persons.map {|i| "- #{i.to_s(today)} [#{i.age(today)}]"}
25
+ end
26
+ else
27
+ args.each do |today|
28
+ today = DR::TimeParse.parse(today)
29
+ personsbday = persons.select {|p| p.birthday?(today)}.sort
30
+ unless personsbday.empty?
31
+ puts "On #{today}, the birthdays are", personsbday.map {|i| "- #{i.to_s(today)}"}
32
+ exit 1 if opts[:crontab] #generate a mail report
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
7
+
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
11
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
+
13
+ require 'birthdays/version'
14
+ Birthdays::VERSION
15
+ end
16
+
17
+ gem.summary = gemspec['summary']
18
+ gem.description = gemspec['description']
19
+ gem.licenses = Array(gemspec['license'])
20
+ gem.authors = Array(gemspec['authors'])
21
+ gem.email = gemspec['email']
22
+ gem.homepage = gemspec['homepage']
23
+
24
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
25
+
26
+ gem.files = `git ls-files`.split($/)
27
+
28
+ `git submodule --quiet foreach --recursive pwd`.split($/).each do |submodule|
29
+ submodule.sub!("#{Dir.pwd}/",'')
30
+
31
+ Dir.chdir(submodule) do
32
+ `git ls-files`.split($/).map do |subpath|
33
+ gem.files << File.join(submodule,subpath)
34
+ end
35
+ end
36
+ end
37
+ gem.files = glob[gemspec['files']] if gemspec['files']
38
+
39
+ gem.executables = gemspec.fetch('executables') do
40
+ glob['bin/*'].map { |path| File.basename(path) }
41
+ end
42
+ gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
43
+
44
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
45
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
46
+
47
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
48
+ %w[ext lib].select { |dir| File.directory?(dir) }
49
+ })
50
+
51
+ gem.requirements = Array(gemspec['requirements'])
52
+ gem.required_ruby_version = gemspec['required_ruby_version']
53
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
54
+ gem.post_install_message = gemspec['post_install_message']
55
+
56
+ split = lambda { |string| string.split(/,\s*/) }
57
+
58
+ if gemspec['dependencies']
59
+ gemspec['dependencies'].each do |name,versions|
60
+ gem.add_dependency(name,split[versions])
61
+ end
62
+ end
63
+
64
+ if gemspec['development_dependencies']
65
+ gemspec['development_dependencies'].each do |name,versions|
66
+ gem.add_development_dependency(name,split[versions])
67
+ end
68
+ end
69
+
70
+ gem.metadata['yard.run']='yri'
71
+ end
@@ -0,0 +1,18 @@
1
+ name: birthdays
2
+ summary: "Birthdays reminder"
3
+ description: "Show the birthdays in a time period so you don't forget them!"
4
+ license: MIT
5
+ authors: Damien Robert
6
+ email: Damien.Olivier.Robert+gems@gmail.com
7
+ homepage: https://github.com/DamienRobert/birthdays#readme
8
+
9
+ dependencies:
10
+ drain: ~> 0.1
11
+ chronic: ~> 0.1
12
+ chronic_duration: ~> 0.1
13
+ activesupport: ~> 5.0
14
+ development_dependencies:
15
+ minitest: "~> 5.0"
16
+ rake: "~> 10"
17
+ rubygems-tasks: "~> 0.2"
18
+ yard: "~> 0.8"
@@ -0,0 +1,63 @@
1
+ require 'birthdays/version'
2
+
3
+ require 'yaml'
4
+ require 'dr/parse/time_parse'
5
+
6
+ class Person
7
+ attr_accessor :name, :bday, :ybday
8
+
9
+ def self.get_day(*args, range: :keep)
10
+ return Time.now if args.empty?
11
+ day=args.first
12
+ if Range === day
13
+ case range
14
+ when :begin
15
+ return day.begin
16
+ when :end
17
+ return day.end
18
+ end
19
+ end
20
+ return day
21
+ end
22
+
23
+ def initialize(name,bday)
24
+ @name=name
25
+ if bday.class == Date then
26
+ @bday=bday
27
+ else
28
+ @bday = DR::TimeParse.parse(bday).to_date
29
+ end
30
+ @ybday=Date.parse("#{@bday.month}/#{@bday.day}")
31
+ end
32
+ def <=>(el)
33
+ return @ybday <=> el.ybday
34
+ end
35
+
36
+ def birthday?(*day)
37
+ day=Person.get_day(*day)
38
+ case day
39
+ when Range
40
+ first=day.begin
41
+ last=day.end
42
+ return (first.month < @bday.month or first.month == @bday.month && first.day <= @bday.day) &&
43
+ (last.month > @bday.month or last.month == @bday.month && last.day >= @bday.day)
44
+ else
45
+ return day.month == @bday.month && day.day == @bday.day
46
+ end
47
+ end
48
+ def age(*day)
49
+ day=Person.get_day(*day, range: :end)
50
+ ChronicDuration.output(day - @bday.to_time)
51
+ end
52
+ #round the age in years
53
+ def bday_age(*day)
54
+ day=Person.get_day(*day, range: :end).to_date
55
+ age=day.year-@bday.year
56
+ age-=1 if day < @ybday
57
+ return age
58
+ end
59
+ def to_s(*day)
60
+ day=Person.get_day(*day, range: :end)
61
+ @name+" (born #{@bday}, #{bday_age(day)}y)"
62
+ end
63
+ end
@@ -0,0 +1,4 @@
1
+ module Birthdays
2
+ # birthdays version
3
+ VERSION = "0.1.2"
4
+ end
@@ -0,0 +1,13 @@
1
+ require 'minitest/autorun'
2
+
3
+ ## Uncomment to launch pry on a failure
4
+ #require 'pry-rescue/minitest'
5
+
6
+ begin
7
+ require 'minitest/reporters'
8
+ Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
9
+ #Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
10
+ #Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new
11
+ rescue LoadError => error
12
+ warn "minitest/reporters not found, not changing minitest reporter: #{error}"
13
+ end
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+ require 'birthdays'
3
+
4
+ class TestBirthdays < Minitest::Test
5
+
6
+ def test_version
7
+ version = Birthdays.const_get('VERSION')
8
+
9
+ assert(!version.empty?, 'should have a VERSION constant')
10
+ end
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: birthdays
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Damien Robert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: drain
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: chronic
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: chronic_duration
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubygems-tasks
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.2'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.8'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.8'
125
+ description: Show the birthdays in a time period so you don't forget them!
126
+ email: Damien.Olivier.Robert+gems@gmail.com
127
+ executables:
128
+ - birthdays
129
+ extensions: []
130
+ extra_rdoc_files:
131
+ - ChangeLog.md
132
+ - LICENSE.txt
133
+ - README.md
134
+ files:
135
+ - ".gitignore"
136
+ - ".travis.yml"
137
+ - ".yardopts"
138
+ - ChangeLog.md
139
+ - Gemfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/birthdays
144
+ - birthdays.gemspec
145
+ - gemspec.yml
146
+ - lib/birthdays.rb
147
+ - lib/birthdays/version.rb
148
+ - test/helper.rb
149
+ - test/test_birthdays.rb
150
+ homepage: https://github.com/DamienRobert/birthdays#readme
151
+ licenses:
152
+ - MIT
153
+ metadata:
154
+ yard.run: yri
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubygems_version: 3.1.2
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Birthdays reminder
174
+ test_files: []