mcalendar 0.1.0

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
+ SHA256:
3
+ metadata.gz: 6969a630ad01605c9c2a0582c7909b5fda89f56ccaf25f191d44d3b3c639850f
4
+ data.tar.gz: fc3b40b9e0a16d6e53ee263d0153f667e99359415565cfaf9ed90dd18b13858e
5
+ SHA512:
6
+ metadata.gz: 6ff6294d198ddb32da63185ce543bb44fce1ec730120036cc45c105c2218979b9cc0a1e095879bbf3526be9dfe160fd7682e7a198192d85111e5e5834367ac8b
7
+ data.tar.gz: 860fd4c24dfc8f1edb4588590e450167370b63b1467d0af90b5709f1bbfa8e0f3d41d50e4806aa34c3b9b6e83a850b0ec600ee005f17315dc318b7cffc89494d
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
10
+ pdf/*.pdf
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.5
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mcalendar.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 icm7216
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,41 @@
1
+ # Mcalendar
2
+
3
+ Ruby monthly calendar, console and pdf.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'mcalendar'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install mcalendar
21
+
22
+
23
+ ## Usage
24
+
25
+ If you want to create a calendar for this month.
26
+
27
+ When you run the command, the calendar appears on the console. The pdf file is created in the pfd directory.
28
+ ```
29
+ mcalendar
30
+ ```
31
+
32
+
33
+ If you want to create a calendar for any month.
34
+ ```
35
+ mcalendar 2020/02
36
+ ```
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mcalendar"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/mcalendar ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "mcalendar"
@@ -0,0 +1,58 @@
1
+
2
+ module Mcalendar
3
+ class Calendar
4
+ WEEKS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
5
+
6
+ def initialize(year, month)
7
+ @first_of_month = Date.new(year, month, 1)
8
+ @end_of_month = Date.new(year, month, -1)
9
+ @days = (1..@end_of_month.day).map {|m| "%2d" % m}
10
+ @first_of_month.wday.times {@days.unshift(" ")}
11
+ end
12
+
13
+ def month_title
14
+ @first_of_month.strftime("%B %Y")
15
+ end
16
+
17
+ def to_s
18
+ week_header = WEEKS.join(" ")
19
+ month_header = month_title.center(week_header.size).rstrip
20
+ calendar = [[week_header]]
21
+ @days.each_slice(7) {|x| calendar << [x.join(" ")]}
22
+ [month_header, calendar]
23
+ end
24
+
25
+ def display
26
+ puts to_s
27
+ end
28
+
29
+ def pdf
30
+ month_header = [[month_title]]
31
+ calendar = [WEEKS]
32
+ @days.each_slice(7) {|x| calendar << x}
33
+
34
+ pdf = Prawn::Document.new(page_size: 'A4', margin: 20)
35
+ # stroke_axis
36
+ cell_height = calendar.size > 6 ? 50 : 60
37
+
38
+ pdf.bounding_box([0, 400], width: 553, height: 400) do
39
+ pdf.stroke_bounds
40
+
41
+ pdf.table(month_header) do
42
+ cells.style(width: 553, height: 59, align: :center, size: 26)
43
+ row(0).padding_top = 15
44
+ row(0).padding_bottom = 0
45
+ end
46
+
47
+ pdf.table(calendar) do
48
+ cells.style(width: 79, height: cell_height, align: :center, size: 19, padding: 15)
49
+ row(0).height = 40
50
+ row(0).padding_top = 10
51
+ row(0).padding_bottom = 0
52
+ end
53
+ end
54
+ pdf.render_file "pdf/calendar.pdf"
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,11 @@
1
+ # Ruby Monthly calendar
2
+
3
+ begin
4
+ d = Date.parse(ARGV.first)
5
+ rescue
6
+ d = Date.today
7
+ end
8
+
9
+ calendar = Mcalendar::Calendar.new(d.year, d.month)
10
+ calendar.display
11
+ calendar.pdf
@@ -0,0 +1,3 @@
1
+ module Mcalendar
2
+ VERSION = "0.1.0"
3
+ end
data/lib/mcalendar.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'date'
2
+ require "prawn"
3
+ require "prawn/table"
4
+
5
+ require_relative 'mcalendar/calendar'
6
+ require_relative 'mcalendar/command'
7
+ require_relative 'mcalendar/version'
data/mcalendar.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ require_relative 'lib/mcalendar/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "mcalendar"
5
+ spec.version = Mcalendar::VERSION
6
+ spec.authors = ["icm7216"]
7
+ spec.email = ["icm7216d@gmail.com"]
8
+
9
+ spec.summary = %q{Ruby Monthly calendar}
10
+ spec.description = %q{Ruby Monthly Calendar, Console and pdf}
11
+ spec.homepage = "https://github.com/icm7216/mcalendar"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "test-unit"
25
+ spec.add_development_dependency "test-unit-rr"
26
+ spec.add_development_dependency "prawn"
27
+ spec.add_development_dependency "prawn-table"
28
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mcalendar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - icm7216
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: test-unit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: test-unit-rr
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: prawn
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: prawn-table
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Ruby Monthly Calendar, Console and pdf
70
+ email:
71
+ - icm7216d@gmail.com
72
+ executables:
73
+ - mcalendar
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - exe/mcalendar
86
+ - lib/mcalendar.rb
87
+ - lib/mcalendar/calendar.rb
88
+ - lib/mcalendar/command.rb
89
+ - lib/mcalendar/version.rb
90
+ - mcalendar.gemspec
91
+ homepage: https://github.com/icm7216/mcalendar
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.3.0
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.0.6
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Ruby Monthly calendar
114
+ test_files: []