hanreki 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e1aacd0a4f8f841d3494a736aea503be21d5ed8f274895817ac14de17479dab
4
- data.tar.gz: 37a0d4efa39e5680d5c9fbd1777448e5b97be00d1c70356c8bc254e09588d8a2
3
+ metadata.gz: 944f39bf167421f37e9bb814289d58b77a791695cae547cca3d4afd7acd9d2b5
4
+ data.tar.gz: ca7b46cc65c16e5fe7c61ff6e4739d4a7d8194b64b35a767f312520ca987abfb
5
5
  SHA512:
6
- metadata.gz: 17f4f1a31987d47f16ee85245ec62b08cc5557c293dc2be2ae8cbc7c812c1d78f0c7a330c7f94937e0133e263e4b4dae432819dac8cc76b8b7efa6b229aac1c4
7
- data.tar.gz: bcfdfe534bac710e6de6ff1ba9814b74112c17bcd1dc4e0af27f9196d8058957dec4d5dfb932e346fc04131020ca4916dbdd4d7fc6506e450af33e95663094fb
6
+ metadata.gz: 81b8d3882ee6bb4186b9d3c5e2acc7d43e5914bc9590bc686707526e247d809e43a90a69a3b35712dc509a304df58881be1386db997e48769bf328792d3b50a2
7
+ data.tar.gz: 0b406751aef3e864deba94e983811cf8e174cd75db217ecfc8b31ddc1e06cc339c40affcbdccf5e29f90e67cd753be4d188ea454ac37eaff9b01a56ebbad3aaa
data/lib/hanreki/event.rb CHANGED
@@ -10,8 +10,6 @@ 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
15
13
 
16
14
  def initialize(attributes)
17
15
  # Create assign methods for event attributes
@@ -34,16 +32,8 @@ class Event
34
32
  line_number: line_number,
35
33
  })
36
34
  first_day = Date.parse("#{month}01")
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
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 }
47
37
  # Zero-fill (eg. 1 -> 01, 02 -> 02)
48
38
  day = day.rjust(2, "0")
49
39
  raise ValidationError.new(event), 'invalid day' unless day.length == 2
@@ -66,23 +56,15 @@ class Event
66
56
  hash = {
67
57
  start: @start,
68
58
  end: @end,
69
- url: @url,
70
- make_start: @make_start,
71
- make_end: @make_end
59
+ url: @url
72
60
  }
73
61
  case type
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
62
+ when :public then hash[:title] = @public_summary
63
+ when :private then hash[:title] = @private_summary
80
64
  end
81
65
  if time_type == :string
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?
66
+ hash[:start] = hash[:start].iso8601
67
+ hash[:end] = hash[:end].iso8601
86
68
  end
87
69
  hash
88
70
  end
@@ -100,18 +82,10 @@ class Event
100
82
  !@private_summary.nil?
101
83
  end
102
84
 
103
- def make_private?
104
- !@make_private_summary.nil?
105
- end
106
-
107
85
  def public?
108
86
  !@public_summary.nil?
109
87
  end
110
88
 
111
- def make_public?
112
- !@make_public_summary.nil?
113
- end
114
-
115
89
  # イベントのバリデーションを行う
116
90
  # バリデーションに成功した場合は true を返し, 失敗した場合は例外を送出する
117
91
  def validate
@@ -32,17 +32,6 @@ 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
-
46
35
  private
47
36
 
48
37
  # Generate new calendar
@@ -43,13 +43,11 @@ 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) }
47
46
  f.write(ical)
48
47
  end
49
48
  File.open(ICAL_PRIVATE_PATH, 'w') do |f|
50
49
  ical = ICalendar.new
51
50
  private_events.each { |event| ical.set_event(event, :private) }
52
- private_make_events.each { |event| ical.set_make_event(event, :make_private) }
53
51
  f.write(ical)
54
52
  end
55
53
  end
@@ -57,10 +55,10 @@ class Schedule
57
55
  # Output private and public JSON calendar files
58
56
  def out_json
59
57
  File.open(JSON_PUBLIC_PATH, 'w') do |f|
60
- f.write(events_to_json(public_events_for_json, :public, validate: true))
58
+ f.write(events_to_json(public_events, :public, validate: true))
61
59
  end
62
60
  File.open(JSON_PRIVATE_PATH, 'w') do |f|
63
- f.write(events_to_json(private_events_for_json, :private, validate: true))
61
+ f.write(events_to_json(private_events, :private, validate: true))
64
62
  end
65
63
  end
66
64
 
@@ -114,26 +112,10 @@ class Schedule
114
112
  @events.select(&:public?)
115
113
  end
116
114
 
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
-
125
115
  def private_events
126
116
  @events.select(&:private?)
127
117
  end
128
118
 
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
-
137
119
  def events_to_json(events, type, validate = false)
138
120
  json = events.map { |event| event.to_h(type, :string) }.to_json
139
121
  validate_json!(json) if validate
@@ -6,12 +6,6 @@
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
- },
15
9
  "start": {
16
10
  "type": "string",
17
11
  "format": "date-time"
@@ -25,18 +19,6 @@
25
19
  {"type": "string"},
26
20
  {"type": "null"}
27
21
  ]
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
- ]
40
22
  }
41
23
  },
42
24
  "required": ["title", "start", "end", "url"]
@@ -1,3 +1,3 @@
1
1
  module Hanreki
2
- VERSION = '4.1.0'
2
+ VERSION = '4.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanreki
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CAMPHOR-