hanreki 1.1.0 → 1.2.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 +4 -4
- data/README.md +5 -2
- data/hanreki.gemspec +7 -1
- data/lib/hanreki/schedule.rb +16 -6
- data/lib/hanreki/schema.json +27 -0
- data/lib/hanreki/version.rb +1 -1
- metadata +18 -9
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.travis.yml +0 -12
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a867b87334a1a1be5954d74b9059cd465651f1a5
|
4
|
+
data.tar.gz: 2961b20754273404809b8c9f8f1d2d789edfb879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a04b6f1fe15222d4de38772121cfe025a0df77008a58a726e09cec72bf0f2b4fa3650ac7ec4e4ef1f4ef1eca17d850bd8889369c920bab1dd332114a15d44709
|
7
|
+
data.tar.gz: 8579bada5beea05a9b7cf71eea9e2e423a456425430e28034dc77e2c19e3a0f36cb2fba1db85351ac6b097a9bca8ec536c53036b288d96e2f466eb3d6ffed9e7
|
data/README.md
CHANGED
@@ -25,12 +25,15 @@ And then execute:
|
|
25
25
|
$ bundle exec hanreki
|
26
26
|
|
27
27
|
## Usage
|
28
|
-
|
28
|
+
Run `hanreki help` or `bundle exec hanreki help`.
|
29
29
|
|
30
30
|
## Development
|
31
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
32
|
|
33
33
|
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
34
34
|
|
35
35
|
## Contributing
|
36
36
|
Bug reports and pull requests are welcome on GitHub at https://github.com/camphor-/hanreki.
|
37
|
+
|
38
|
+
## Why "hanreki"?
|
39
|
+
This application is named after a Japanese word "[頒暦](https://ja.wikipedia.org/wiki/頒暦)".
|
data/hanreki.gemspec
CHANGED
@@ -14,7 +14,12 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/camphor-/hanreki'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f|
|
18
|
+
f.match(%r{^(
|
19
|
+
(bin|test|spec|features)/|
|
20
|
+
\.gitignore|\.rspec|\.travis\.yml|Rakefile
|
21
|
+
)}x)
|
22
|
+
}
|
18
23
|
spec.bindir = 'exe'
|
19
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
25
|
spec.require_paths = ['lib']
|
@@ -23,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
23
28
|
|
24
29
|
spec.add_dependency 'thor', '~> 0.19'
|
25
30
|
spec.add_dependency 'icalendar', '~> 2.3'
|
31
|
+
spec.add_dependency 'json-schema', '~> 2.7'
|
26
32
|
|
27
33
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
28
34
|
spec.add_development_dependency 'rake', '~> 12.0'
|
data/lib/hanreki/schedule.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'csv'
|
2
2
|
require 'date'
|
3
3
|
require 'json'
|
4
|
+
require 'json-schema'
|
4
5
|
require 'hanreki/event'
|
5
6
|
require 'hanreki/i_calendar'
|
6
7
|
require 'hanreki/time_util'
|
@@ -14,6 +15,7 @@ class Schedule
|
|
14
15
|
JSON_PRIVATE_PATH = 'json/camphor_private_events.json'
|
15
16
|
JSONP_PUBLIC_PATH = 'jsonp/camphor_public_events.js'
|
16
17
|
JSONP_PRIVATE_PATH = 'jsonp/camphor_private_events.js'
|
18
|
+
JSON_SCHEMA_PATH = File.expand_path('../schema.json', __FILE__)
|
17
19
|
|
18
20
|
def initialize
|
19
21
|
# マスターファイルを生成する際のファイル名の決定に使用
|
@@ -55,22 +57,20 @@ class Schedule
|
|
55
57
|
# Output private and public JSON calendar files
|
56
58
|
def out_json
|
57
59
|
File.open(JSON_PUBLIC_PATH, 'w') do |f|
|
58
|
-
|
60
|
+
f.write(events_to_json(public_events, :public, validate: true))
|
59
61
|
end
|
60
62
|
File.open(JSON_PRIVATE_PATH, 'w') do |f|
|
61
|
-
|
63
|
+
f.write(events_to_json(private_events, :private, validate: true))
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
67
|
# Output private and public JSONP calendar files
|
66
68
|
def out_jsonp(callback = 'callback')
|
67
69
|
File.open(JSONP_PUBLIC_PATH, 'w') do |f|
|
68
|
-
|
69
|
-
f.write("#{callback}(#{events.to_json});")
|
70
|
+
f.write("#{callback}(#{events_to_json(public_events, :public)});")
|
70
71
|
end
|
71
72
|
File.open(JSONP_PRIVATE_PATH, 'w') do |f|
|
72
|
-
|
73
|
-
f.write("#{callback}(#{events.to_json});")
|
73
|
+
f.write("#{callback}(#{events_to_json(private_events, :private)});")
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -123,4 +123,14 @@ class Schedule
|
|
123
123
|
def private_events
|
124
124
|
@events.select(&:private?)
|
125
125
|
end
|
126
|
+
|
127
|
+
def events_to_json(events, type, validate = false)
|
128
|
+
json = events.map { |event| event.to_h(type, :string) }.to_json
|
129
|
+
validate_json!(json) if validate
|
130
|
+
json
|
131
|
+
end
|
132
|
+
|
133
|
+
def validate_json!(json)
|
134
|
+
JSON::Validator.validate!(JSON_SCHEMA_PATH, json)
|
135
|
+
end
|
126
136
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"type": "array",
|
4
|
+
"items": [
|
5
|
+
{
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"title": {"type": "string"},
|
9
|
+
"start": {
|
10
|
+
"type": "string",
|
11
|
+
"format": "date-time"
|
12
|
+
},
|
13
|
+
"end": {
|
14
|
+
"type": "string",
|
15
|
+
"format": "date-time"
|
16
|
+
},
|
17
|
+
"url": {
|
18
|
+
"anyOf": [
|
19
|
+
{"type": "string"},
|
20
|
+
{"type": "null"}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"required": ["title", "start", "end", "url"]
|
25
|
+
}
|
26
|
+
]
|
27
|
+
}
|
data/lib/hanreki/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanreki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CAMPHOR-
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json-schema
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.7'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.7'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,15 +102,9 @@ executables:
|
|
88
102
|
extensions: []
|
89
103
|
extra_rdoc_files: []
|
90
104
|
files:
|
91
|
-
- ".gitignore"
|
92
|
-
- ".rspec"
|
93
|
-
- ".travis.yml"
|
94
105
|
- Gemfile
|
95
106
|
- LICENSE
|
96
107
|
- README.md
|
97
|
-
- Rakefile
|
98
|
-
- bin/console
|
99
|
-
- bin/setup
|
100
108
|
- exe/hanreki
|
101
109
|
- hanreki.gemspec
|
102
110
|
- lib/hanreki.rb
|
@@ -104,6 +112,7 @@ files:
|
|
104
112
|
- lib/hanreki/event.rb
|
105
113
|
- lib/hanreki/i_calendar.rb
|
106
114
|
- lib/hanreki/schedule.rb
|
115
|
+
- lib/hanreki/schema.json
|
107
116
|
- lib/hanreki/time_util.rb
|
108
117
|
- lib/hanreki/version.rb
|
109
118
|
homepage: https://github.com/camphor-/hanreki
|
@@ -126,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
135
|
version: '0'
|
127
136
|
requirements: []
|
128
137
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.6.8
|
130
139
|
signing_key:
|
131
140
|
specification_version: 4
|
132
141
|
summary: Simple schedule manager for CAMPHOR-
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.1
|
5
|
-
- 2.2.4
|
6
|
-
- 2.3.1
|
7
|
-
- 2.4.0
|
8
|
-
before_install:
|
9
|
-
- gem install bundler
|
10
|
-
notifications:
|
11
|
-
slack:
|
12
|
-
secure: SqYPNEedzTJqs9XHn0SW1RvPVG2GPcMJWMrE4hg35WnzZk7rSk9DbHqjjZo1+qAS8MF/du68KKPRJe1KewerK+Zub2wwsFAR2Wvp0Elrq2fgKKNMY67ulG+ET6f2Mz9Uij83CO9fBxbCXxqja+nTbHZhx7YM5B9KSAqwNs6DYahxtueLiqK4y4YVULt/KUvo9mA2gjIbeTZE0TZ/se0pXVtunh/UFW+CE34rkTT3zoUtk4CcCO/wMXu56vwqyHluwwmhVVjvMB96WYrJ3O2R9ef3Cm9rfzAeyJ0LDBddOwr+z4ZsI2Yz+b270bM6F1Mb6sDO48WGi12u8JRRGECy/GA8R93Jo6mnC+cEPx50XElPE5njbI56LRBuzAjimEyxpwfA9UWBgRDGmHyEc3B16ri/DKknEE+YxEvsEfgKSt012sXBS0gYO6jIz318GMxdj6+EYYVJXwJMj8MZlCUtvfgqq4qQwk/vBDK9BAcfDjIbayWLEnenXJWnRwW7gVn4hQG4qx+TUUZDcgiZ+adFcMLZjvd500GSOeV8H+4U5pR0MWIzuC1MTAIYB4E7Tma2QQqU2dG3ztHqo4ubApTb/qBpcYrFOjCBPT2ItGC85mSlGMs4vgMnVUGyFaLR5u4PYe6Hd/uNfE6i8ayJ2E1STFVUuwD0EdOXqEZT6ulnvD4=
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "hanreki"
|
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
|