syobocalite 0.1.0 → 0.1.1

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: f8dcc7caf5e785e5db9e1a125e3a6ae293649e8e1d8b1147f02be88765a37603
4
- data.tar.gz: ec89b3bc62616e1410eef439ab5618bd1bb4a6bd60d738cf02dba81a99e8eb44
3
+ metadata.gz: f7f070e10f14d7a0c05cb53c7174b79743733ea920021b19eda731a690925847
4
+ data.tar.gz: bf7cb84980a92810e73bfa70ac0ed432851f14517617ce56b260ad80ede919fb
5
5
  SHA512:
6
- metadata.gz: 4bffe23133dbd2af590cc510e9853e2c24ed082bc58b8627a27134fbd1caac3e83197b0efeb4d628e363bc699fc5509cd63eacd675e025437e8dff0ff5498e9d
7
- data.tar.gz: 7e35926344c57137a133463649dc2285b64ee85fd1aa051a32fb4c4e2d2fa1ee99a88c83703d7a7201de4b0a32405ed9f3f617b1b6cee1550cf3cbc1dbc86472
6
+ metadata.gz: d0d529f375366b4ebf8f551365bcf9dda0f299717a1fcf571e3d6aad04367ee998b4da09e22491cafdff79c321468bc47ec9dae69e205b7b8c873b1bcd5b95ab
7
+ data.tar.gz: 93fe3b38ae5498d3f76fa232f88eca0fc5ccde2b11de8e1504f3741329833e22910a6e465fcd79f16534f3f0b99acf54a4d966dbd552b1c12bd875b9eb703837
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## master
2
- [full changelog](https://github.com/sue445/syobocalite/compare/v0.1.0...master)
2
+ [full changelog](https://github.com/sue445/syobocalite/compare/v0.1.1...master)
3
+
4
+ ## 0.1.0
5
+ [full changelog](https://github.com/sue445/syobocalite/compare/v0.1.0...v0.1.1)
6
+
7
+ * Refactor `Syobocalite::Program#Initialize`
8
+ * https://github.com/sue445/syobocalite/pull/3
3
9
 
4
10
  ## 0.1.0
5
11
  * first release
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Lite client for [Syoboi calendar](http://cal.syoboi.jp/) API.
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/syobocalite.svg)](https://badge.fury.io/rb/syobocalite)
5
6
  [![Build Status](https://travis-ci.org/sue445/syobocalite.svg?branch=master)](https://travis-ci.org/sue445/syobocalite)
6
7
  [![Coverage Status](https://coveralls.io/repos/github/sue445/syobocalite/badge.svg?branch=master)](https://coveralls.io/github/sue445/syobocalite?branch=master)
7
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/9f77793acf8d5c24886e/maintainability)](https://codeclimate.com/github/sue445/syobocalite/maintainability)
data/lib/syobocalite.rb CHANGED
@@ -18,7 +18,7 @@ module Syobocalite
18
18
  response = MultiXml.parse(xml)
19
19
  prog_items = response["syobocal"]["ProgItems"]["ProgItem"]
20
20
 
21
- programs = prog_items.map { |prog_item| Syobocalite::Program.new(prog_item) }
21
+ programs = prog_items.map { |prog_item| Syobocalite::Program.from_prog_item(prog_item) }
22
22
 
23
23
  programs.select do |program|
24
24
  (start_at...end_at).cover?(program.st_time)
@@ -44,38 +44,68 @@ module Syobocalite
44
44
  # @return [String]
45
45
  attr_accessor :prog_comment
46
46
 
47
- # @param attrs [Hash]
48
- def initialize(attrs = {})
49
- @pid = attrs["PID"]&.to_i
50
- @tid = attrs["TID"]&.to_i
51
- @st_time = to_time(attrs["StTime"])
52
- @ed_time = to_time(attrs["EdTime"])
53
- @ch_name = attrs["ChName"]
54
- @ch_id = attrs["ChID"]&.to_i
55
- @count = attrs["Count"]&.to_i
56
- @st_offset = attrs["StOffset"]&.to_i
57
- @sub_title = sanitize_text(attrs["SubTitle"])
58
- @title = sanitize_text(attrs["Title"])
59
- @prog_comment = attrs["ProgComment"]&.gsub(/^!/, "")
47
+ # @param pid [Integer]
48
+ # @param tid [Integer]
49
+ # @param st_time [TimeWithZone]
50
+ # @param ed_time [TimeWithZone]
51
+ # @param ch_name [String]
52
+ # @param ch_id [Integer]
53
+ # @param count [Integer]
54
+ # @param st_offset [Integer]
55
+ # @param sub_title [String]
56
+ # @param title [String]
57
+ # @param prog_comment [String]
58
+ def initialize(pid: nil, tid: nil, st_time: nil, ed_time: nil, ch_name: nil, ch_id: nil,
59
+ count: nil, st_offset: nil, sub_title: nil, title: nil, prog_comment: nil)
60
+ @pid = pid
61
+ @tid = tid
62
+ @st_time = st_time
63
+ @ed_time = ed_time
64
+ @ch_name = ch_name
65
+ @ch_id = ch_id
66
+ @count = count
67
+ @st_offset = st_offset
68
+ @sub_title = sub_title
69
+ @title = title
70
+ @prog_comment = prog_comment
60
71
  end
61
72
 
62
73
  alias_method :story_number, :count
63
74
  alias_method :story_number=, :count=
64
75
 
65
- private
76
+ # @param attrs [Hash]
77
+ #
78
+ # @return [Syobocalite::Program]
79
+ def self.from_prog_item(attrs = {})
80
+ Syobocalite::Program.new(
81
+ pid: attrs["PID"]&.to_i,
82
+ tid: attrs["TID"]&.to_i,
83
+ st_time: to_time(attrs["StTime"]),
84
+ ed_time: to_time(attrs["EdTime"]),
85
+ ch_name: attrs["ChName"],
86
+ ch_id: attrs["ChID"]&.to_i,
87
+ count: attrs["Count"]&.to_i,
88
+ st_offset: attrs["StOffset"]&.to_i,
89
+ sub_title: sanitize_text(attrs["SubTitle"]),
90
+ title: sanitize_text(attrs["Title"]),
91
+ prog_comment: attrs["ProgComment"]&.gsub(/^!/, ""),
92
+ )
93
+ end
66
94
 
67
- def to_time(str)
95
+ def self.to_time(str)
68
96
  return nil unless str
69
97
 
70
98
  Time.use_zone("Tokyo") do
71
99
  Time.zone.parse(str)
72
100
  end
73
101
  end
102
+ private_class_method :to_time
74
103
 
75
- def sanitize_text(str)
104
+ def self.sanitize_text(str)
76
105
  return nil unless str
77
106
 
78
107
  CGI.unescapeHTML(str)
79
108
  end
109
+ private_class_method :sanitize_text
80
110
  end
81
111
  end
@@ -1,3 +1,3 @@
1
1
  module Syobocalite
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syobocalite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445