hanreki 3.1.0 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4d5d51295a519391b161cb91eae07d899bf9a260
4
- data.tar.gz: 2b9fd146dc373dfa1147b028a7e187a1f084ff4d
2
+ SHA256:
3
+ metadata.gz: 0e1aacd0a4f8f841d3494a736aea503be21d5ed8f274895817ac14de17479dab
4
+ data.tar.gz: 37a0d4efa39e5680d5c9fbd1777448e5b97be00d1c70356c8bc254e09588d8a2
5
5
  SHA512:
6
- metadata.gz: 8615ef2ab3c0b10a1e63303155b181e9ae48576da4b3ac123770012ec23a09985160d6c4e632e34ab87453dbdf329f945aa6775be8a70c3f0e4e0b101fb9f695
7
- data.tar.gz: 1d7852bac0484984f375de1131a36ec796aa018fa8e96739df7613070131eb2f6bb62d2585ac6ac1bcf3853c31754297f2a4f29523bea96da32af2cec666708a
6
+ metadata.gz: 17f4f1a31987d47f16ee85245ec62b08cc5557c293dc2be2ae8cbc7c812c1d78f0c7a330c7f94937e0133e263e4b4dae432819dac8cc76b8b7efa6b229aac1c4
7
+ data.tar.gz: bcfdfe534bac710e6de6ff1ba9814b74112c17bcd1dc4e0af27f9196d8058957dec4d5dfb932e346fc04131020ca4916dbdd4d7fc6506e450af33e95663094fb
data/hanreki.gemspec CHANGED
@@ -26,11 +26,11 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.required_ruby_version = '>= 2.2.0'
28
28
 
29
- spec.add_dependency 'thor', '~> 0.19'
29
+ spec.add_dependency 'thor', '>= 0.19', '< 2.0'
30
30
  spec.add_dependency 'icalendar', '~> 2.3'
31
31
  spec.add_dependency 'json-schema', '~> 2.7'
32
32
 
33
- spec.add_development_dependency 'bundler', '~> 1.12'
34
- spec.add_development_dependency 'rake', '~> 12.0'
33
+ spec.add_development_dependency 'bundler', '~> 2.1'
34
+ spec.add_development_dependency 'rake', '~> 13.0'
35
35
  spec.add_development_dependency 'rspec', '~> 3.0'
36
36
  end
data/lib/hanreki/event.rb CHANGED
@@ -10,6 +10,8 @@ class Event
10
10
  attr_accessor :start, :end
11
11
  attr_accessor :public_summary, :private_summary
12
12
  attr_accessor :url
13
+ attr_accessor :make_start, :make_end
14
+ attr_accessor :make_public_summary, :make_private_summary
13
15
 
14
16
  def initialize(attributes)
15
17
  # Create assign methods for event attributes
@@ -32,8 +34,16 @@ class Event
32
34
  line_number: line_number,
33
35
  })
34
36
  first_day = Date.parse("#{month}01")
35
- raise ValidationError.new(event), 'invalid number of columns' unless line.length == 7
36
- day, dow, hour_start, hour_end, public_summary, private_summary, url = line.fields.map { |c| c.to_s.strip }
37
+ raise ValidationError.new(event), 'invalid number of columns' unless line.length == 7 || line.length == 11
38
+ if line.length == 7
39
+ day, dow, hour_start, hour_end, public_summary, private_summary, url = line.fields.map { |c| c.to_s.strip }
40
+ else
41
+ day, dow, hour_start, hour_end, public_summary, private_summary, url, make_hour_start, make_hour_end, make_public_summary, make_private_summary = line.fields.map { |c| c.to_s.strip }
42
+ event.make_start = Time.parse("#{month}#{day} #{make_hour_start} +09:00").getlocal("+09:00")
43
+ event.make_end = Time.parse("#{month}#{day} #{make_hour_end} +09:00").getlocal("+09:00")
44
+ event.make_public_summary = make_public_summary unless make_public_summary.empty?
45
+ event.make_private_summary = make_private_summary unless make_private_summary.empty?
46
+ end
37
47
  # Zero-fill (eg. 1 -> 01, 02 -> 02)
38
48
  day = day.rjust(2, "0")
39
49
  raise ValidationError.new(event), 'invalid day' unless day.length == 2
@@ -56,15 +66,23 @@ class Event
56
66
  hash = {
57
67
  start: @start,
58
68
  end: @end,
59
- url: @url
69
+ url: @url,
70
+ make_start: @make_start,
71
+ make_end: @make_end
60
72
  }
61
73
  case type
62
- when :public then hash[:title] = @public_summary
63
- when :private then hash[:title] = @private_summary
74
+ when :public
75
+ hash[:title] = @public_summary
76
+ hash[:make_title] = @make_public_summary
77
+ when :private
78
+ hash[:title] = @private_summary
79
+ hash[:make_title] = @make_private_summary
64
80
  end
65
81
  if time_type == :string
66
- hash[:start] = hash[:start].iso8601
67
- hash[:end] = hash[:end].iso8601
82
+ hash[:start] = hash[:start].iso8601 unless hash[:start].nil?
83
+ hash[:end] = hash[:end].iso8601 unless hash[:end].nil?
84
+ hash[:make_start] = hash[:make_start].iso8601 unless hash[:make_start].nil?
85
+ hash[:make_end] = hash[:make_end].iso8601 unless hash[:make_end].nil?
68
86
  end
69
87
  hash
70
88
  end
@@ -82,10 +100,18 @@ class Event
82
100
  !@private_summary.nil?
83
101
  end
84
102
 
103
+ def make_private?
104
+ !@make_private_summary.nil?
105
+ end
106
+
85
107
  def public?
86
108
  !@public_summary.nil?
87
109
  end
88
110
 
111
+ def make_public?
112
+ !@make_public_summary.nil?
113
+ end
114
+
89
115
  # イベントのバリデーションを行う
90
116
  # バリデーションに成功した場合は true を返し, 失敗した場合は例外を送出する
91
117
  def validate
@@ -101,6 +127,12 @@ class Event
101
127
  end
102
128
  end
103
129
 
130
+ if @public_summary == 'Online Open'
131
+ if @start == @end
132
+ raise ValidationError.new(self), '"online open" event should have duration'
133
+ end
134
+ end
135
+
104
136
  if @private_summary == 'Closed'
105
137
  if not @public_summary.nil?
106
138
  raise ValidationError.new(self), 'invalid public summary for a closed event'
@@ -32,6 +32,17 @@ class ICalendar
32
32
  end
33
33
  end
34
34
 
35
+ def set_make_event(event, type)
36
+ @calendar.event do |e|
37
+ e.dtstart = event.make_start
38
+ e.dtend = event.make_end
39
+ case type
40
+ when :make_public then e.summary = event.make_public_summary
41
+ when :make_private then e.summary = event.make_private_summary
42
+ end
43
+ end
44
+ end
45
+
35
46
  private
36
47
 
37
48
  # Generate new calendar
@@ -43,11 +43,13 @@ class Schedule
43
43
  File.open(ICAL_PUBLIC_PATH, 'w') do |f|
44
44
  ical = ICalendar.new
45
45
  public_events.each { |event| ical.set_event(event, :public) }
46
+ public_make_events.each { |event| ical.set_make_event(event, :make_public) }
46
47
  f.write(ical)
47
48
  end
48
49
  File.open(ICAL_PRIVATE_PATH, 'w') do |f|
49
50
  ical = ICalendar.new
50
51
  private_events.each { |event| ical.set_event(event, :private) }
52
+ private_make_events.each { |event| ical.set_make_event(event, :make_private) }
51
53
  f.write(ical)
52
54
  end
53
55
  end
@@ -55,10 +57,10 @@ 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
- f.write(events_to_json(public_events, :public, validate: true))
60
+ f.write(events_to_json(public_events_for_json, :public, validate: true))
59
61
  end
60
62
  File.open(JSON_PRIVATE_PATH, 'w') do |f|
61
- f.write(events_to_json(private_events, :private, validate: true))
63
+ f.write(events_to_json(private_events_for_json, :private, validate: true))
62
64
  end
63
65
  end
64
66
 
@@ -112,10 +114,26 @@ class Schedule
112
114
  @events.select(&:public?)
113
115
  end
114
116
 
117
+ def public_make_events
118
+ @events.select(&:make_public?)
119
+ end
120
+
121
+ def public_events_for_json
122
+ @events.select{ |e| e.public? || e.make_public? }
123
+ end
124
+
115
125
  def private_events
116
126
  @events.select(&:private?)
117
127
  end
118
128
 
129
+ def private_make_events
130
+ @events.select(&:make_private?)
131
+ end
132
+
133
+ def private_events_for_json
134
+ @events.select{ |e| e.private? || e.make_private? }
135
+ end
136
+
119
137
  def events_to_json(events, type, validate = false)
120
138
  json = events.map { |event| event.to_h(type, :string) }.to_json
121
139
  validate_json!(json) if validate
@@ -6,6 +6,12 @@
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "title": {"type": "string"},
9
+ "make_title": {
10
+ "anyOf": [
11
+ {"type": "string"},
12
+ {"type": "null"}
13
+ ]
14
+ },
9
15
  "start": {
10
16
  "type": "string",
11
17
  "format": "date-time"
@@ -19,6 +25,18 @@
19
25
  {"type": "string"},
20
26
  {"type": "null"}
21
27
  ]
28
+ },
29
+ "make_start": {
30
+ "anyOf": [
31
+ {"type": "string", "format": "date-time"},
32
+ {"type": "null"}
33
+ ]
34
+ },
35
+ "make_end": {
36
+ "anyOf": [
37
+ {"type": "string", "format": "date-time"},
38
+ {"type": "null"}
39
+ ]
22
40
  }
23
41
  },
24
42
  "required": ["title", "start", "end", "url"]
@@ -1,3 +1,3 @@
1
1
  module Hanreki
2
- VERSION = '3.1.0'
2
+ VERSION = '4.1.0'
3
3
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanreki
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.1.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-10-30 00:00:00.000000000 Z
11
+ date: 2021-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.19'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0.19'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: icalendar
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +64,28 @@ dependencies:
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '1.12'
67
+ version: '2.1'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '1.12'
74
+ version: '2.1'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rake
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '12.0'
81
+ version: '13.0'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '12.0'
88
+ version: '13.0'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: rspec
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -135,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
141
  - !ruby/object:Gem::Version
136
142
  version: '0'
137
143
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 2.6.8
144
+ rubygems_version: 3.0.3
140
145
  signing_key:
141
146
  specification_version: 4
142
147
  summary: Simple schedule manager for CAMPHOR-