syobocalite 1.0.1 → 1.1.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: c66235b54db0a2f1bd0140ebba1f78a7a50ddf7f9f3ac80c8e0326fbd7335551
4
- data.tar.gz: df1a38d0ce3ca6e543a5e7dc5c7bcbe4809f5e43fa04735bd78fd528bb71607f
3
+ metadata.gz: 54e715bc7979d257cd27952ad2591999411c2fbff9a5bf89ae74e68ef2130507
4
+ data.tar.gz: 838b7257de52a103e8d12f04892600020edd0eeb2845b94da847508022ec2634
5
5
  SHA512:
6
- metadata.gz: 5473becc58c3ddd2d13f96032db08b6dc00460b3672eb84f83f3c17e9bf6e70184bba6028f5bc5a529f581861ee4f41ce92f1900e01cebcacd22a8dcb24efbaf
7
- data.tar.gz: 676908cea8efdffdb64195561a791700f8be8a71b6dcad3869ae104ca0d97f872d5da38afdc83152e5b7ac583c9074d0b735fdd7c2d26426e67dc1e937864220
6
+ metadata.gz: 3df0024a0d4337855bf8b6c51e51b3a7859ec97b5f3030b4bca2695057e88cb9640aaa443adbd27508f8fb3830c928284cd42f217247a6c741c476a9f651ec6c
7
+ data.tar.gz: 745e50fe71acf628cd6dba421b44327234179a099702ac626b7e6718d834cdb51ce2e02f8b7b023beb2ef80445b92223a07d79d007650c9e31e78d1d72307134
@@ -0,0 +1,10 @@
1
+ # c.f. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
2
+ version: 2
3
+
4
+ updates:
5
+ - package-ecosystem: github-actions
6
+ directory: /
7
+ schedule:
8
+ interval: weekly
9
+ assignees:
10
+ - sue445
@@ -0,0 +1,59 @@
1
+ # Simple workflow for deploying static content to GitHub Pages
2
+ name: Deploy static content to Pages
3
+
4
+ on:
5
+ # Runs on pushes targeting the default branch
6
+ push:
7
+ branches:
8
+ - master
9
+
10
+ # Allows you to run this workflow manually from the Actions tab
11
+ workflow_dispatch:
12
+
13
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14
+ permissions:
15
+ contents: read
16
+ pages: write
17
+ id-token: write
18
+
19
+ # Allow one concurrent deployment
20
+ concurrency:
21
+ group: "pages"
22
+ cancel-in-progress: true
23
+
24
+ jobs:
25
+ # Single deploy job since we're just deploying
26
+ deploy:
27
+ environment:
28
+ name: github-pages
29
+ url: ${{ steps.deployment.outputs.page_url }}
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - name: Checkout
33
+ uses: actions/checkout@v4
34
+
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ruby
38
+ bundler-cache: true
39
+
40
+ - run: bundle exec yard
41
+
42
+ - name: Setup Pages
43
+ uses: actions/configure-pages@v5
44
+ - name: Upload artifact
45
+ uses: actions/upload-pages-artifact@v3
46
+ with:
47
+ # Upload entire repository
48
+ path: './doc'
49
+ - name: Deploy to GitHub Pages
50
+ id: deployment
51
+ uses: actions/deploy-pages@main
52
+
53
+ - name: Slack Notification (not success)
54
+ uses: act10ns/slack@v2
55
+ if: "! success()"
56
+ continue-on-error: true
57
+ with:
58
+ status: ${{ job.status }}
59
+ webhook-url: ${{ secrets.SLACK_WEBHOOK }}
@@ -12,82 +12,59 @@ on:
12
12
  schedule:
13
13
  - cron: "0 10 * * 5" # JST 19:00 (Fri)
14
14
 
15
- env:
16
- CI: "true"
17
-
18
15
  jobs:
19
16
  test:
20
17
  runs-on: ubuntu-latest
21
18
 
22
- container: ${{ matrix.ruby }}
23
-
24
19
  strategy:
25
20
  fail-fast: false
26
21
 
27
22
  matrix:
28
23
  ruby:
29
- - ruby:2.5
30
- - ruby:2.6
31
- - ruby:2.7
32
- - ruby:3.0
33
- - rubylang/ruby:master-nightly-bionic
34
- include:
35
- - ruby: rubylang/ruby:master-nightly-bionic
36
- allow_failures: "true"
24
+ - "2.5"
25
+ - "2.6"
26
+ - "2.7"
27
+ - "3.0"
28
+ - "3.1"
29
+ - "3.2"
30
+ - "3.3"
37
31
 
38
32
  steps:
39
- - uses: actions/checkout@v2
33
+ - uses: actions/checkout@v4
40
34
 
41
-
42
- - name: Cache vendor/bundle
43
- uses: actions/cache@v1
44
- id: cache_gem
35
+ - uses: ruby/setup-ruby@v1
45
36
  with:
46
- path: vendor/bundle
47
- key: v1-gem-${{ runner.os }}-${{ matrix.ruby }}-${{ github.sha }}
48
- restore-keys: |
49
- v1-gem-${{ runner.os }}-${{ matrix.ruby }}-
50
- continue-on-error: ${{ matrix.allow_failures == 'true' }}
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
39
+ cache-version: ${{ matrix.gemfile }}
51
40
 
52
- - name: bundle update
53
- run: |
54
- set -xe
55
- bundle config path vendor/bundle
56
- bundle update --jobs $(nproc) --retry 3
57
- continue-on-error: ${{ matrix.allow_failures == 'true' }}
41
+ - run: bundle update --jobs $(nproc) --retry 3
58
42
 
59
43
  - name: Setup Code Climate Test Reporter
60
44
  uses: aktions/codeclimate-test-reporter@v1
61
45
  with:
62
46
  codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
63
47
  command: before-build
64
- if: matrix.ruby >= 'ruby:2.4'
65
48
  continue-on-error: true
66
49
 
67
- - name: Run test
68
- run: |
69
- set -xe
70
- bundle exec rspec
71
- continue-on-error: ${{ matrix.allow_failures == 'true' }}
50
+ - run: bundle exec rspec
72
51
 
73
52
  - name: Teardown Code Climate Test Reporter
74
53
  uses: aktions/codeclimate-test-reporter@v1
75
54
  with:
76
55
  codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
77
56
  command: after-build
78
- if: matrix.ruby >= 'ruby:2.4' && always()
57
+ if: always()
79
58
  continue-on-error: true
80
59
 
81
60
  - name: Slack Notification (not success)
82
- uses: lazy-actions/slatify@master
61
+ uses: act10ns/slack@v2
83
62
  if: "! success()"
84
63
  continue-on-error: true
85
64
  with:
86
- job_name: ${{ format('*build* ({0})', matrix.ruby) }}
87
- type: ${{ job.status }}
88
- icon_emoji: ":octocat:"
89
- url: ${{ secrets.SLACK_WEBHOOK }}
90
- token: ${{ secrets.GITHUB_TOKEN }}
65
+ status: ${{ job.status }}
66
+ webhook-url: ${{ secrets.SLACK_WEBHOOK }}
67
+ matrix: ${{ toJson(matrix) }}
91
68
 
92
69
  notify:
93
70
  needs:
@@ -97,12 +74,9 @@ jobs:
97
74
 
98
75
  steps:
99
76
  - name: Slack Notification (success)
100
- uses: lazy-actions/slatify@master
77
+ uses: act10ns/slack@v2
101
78
  if: always()
102
79
  continue-on-error: true
103
80
  with:
104
- job_name: '*build*'
105
- type: ${{ job.status }}
106
- icon_emoji: ":octocat:"
107
- url: ${{ secrets.SLACK_WEBHOOK }}
108
- token: ${{ secrets.GITHUB_TOKEN }}
81
+ status: ${{ job.status }}
82
+ webhook-url: ${{ secrets.SLACK_WEBHOOK }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## master
2
- [full changelog](https://github.com/sue445/syobocalite/compare/v1.0.1...master)
2
+ [full changelog](https://github.com/sue445/syobocalite/compare/v1.1.0...master)
3
+
4
+ ## 1.1.0
5
+ [full changelog](https://github.com/sue445/syobocalite/compare/v1.0.1...v1.1.0)
6
+
7
+ * Add `#flag`,`#remark?`, `#new?`, `#final?` and `#re_air?` to `Syobocalite::Program`
8
+ * https://github.com/sue445/syobocalite/pull/41
3
9
 
4
10
  ## 1.0.1
5
11
  [full changelog](https://github.com/sue445/syobocalite/compare/v1.0.0...v1.0.1)
data/README.md CHANGED
@@ -42,11 +42,11 @@ end_at = Time.zone.parse("2018-10-07 09:00:00")
42
42
  Syobocalite.search(start_at: start_at, end_at: end_at)
43
43
  ```
44
44
 
45
- `Syobocalite.search` returns `Array` of [`Syobocalite::Program`](lib/syobocalite/program.rb)
45
+ `Syobocalite.search` returns `Array` of [Syobocalite::Program](lib/syobocalite/program.rb)
46
46
 
47
47
  ## vs. [syobocal](https://github.com/xmisao/syobocal)
48
48
  * Supports only `http://cal.syoboi.jp/cal_chk.php`
49
- * Supports `Time` and [`ActiveSupport::TimeWithZone`](https://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html)
49
+ * Supports `Time` and [ActiveSupport::TimeWithZone](https://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html)
50
50
  * Returns array of PORO (NOT array of `Hash`)
51
51
 
52
52
  ## Development
@@ -0,0 +1,27 @@
1
+ module Syobocalite
2
+ # API client for https://cal.syoboi.jp/db.php
3
+ # @see https://docs.cal.syoboi.jp/spec/db.php/
4
+ class DbClient
5
+ # Get program's flag
6
+ # @param tid [Integer]
7
+ # @param pid [Integer]
8
+ # @return [Integer]
9
+ # @see https://docs.cal.syoboi.jp/spec/proginfo-flag/
10
+ def get_program_flag(tid:, pid:)
11
+ params = {
12
+ "Command" => "ProgLookup",
13
+ "Fields" => "Flag",
14
+ "TID" => tid,
15
+ "PID" => pid,
16
+ }
17
+
18
+ headers = {
19
+ "User-Agent" => Syobocalite.user_agent,
20
+ }
21
+
22
+ xml = URI.open("https://cal.syoboi.jp/db.php?#{params.to_param}", headers).read
23
+ response = MultiXml.parse(xml)
24
+ response["ProgLookupResponse"]["ProgItems"]["ProgItem"]["Flag"].to_i
25
+ end
26
+ end
27
+ end
@@ -73,6 +73,41 @@ module Syobocalite
73
73
  alias_method :story_number, :count
74
74
  alias_method :story_number=, :count=
75
75
 
76
+ # Get program's flag
77
+ # @return [Integer]
78
+ # @see https://docs.cal.syoboi.jp/spec/proginfo-flag/
79
+ def flag
80
+ @flag ||= Syobocalite::DbClient.new.get_program_flag(tid: tid, pid: pid)
81
+ end
82
+
83
+ # Whether contains remark
84
+ # @return [Boolean]
85
+ # @see https://docs.cal.syoboi.jp/spec/proginfo-flag/
86
+ def remark?
87
+ flag & 0x01 != 0
88
+ end
89
+
90
+ # Whether new program
91
+ # @return [Boolean]
92
+ # @see https://docs.cal.syoboi.jp/spec/proginfo-flag/
93
+ def new?
94
+ flag & 0x02 != 0
95
+ end
96
+
97
+ # Whether final program
98
+ # @return [Boolean]
99
+ # @see https://docs.cal.syoboi.jp/spec/proginfo-flag/
100
+ def final?
101
+ flag & 0x04 != 0
102
+ end
103
+
104
+ # Whether re-air program
105
+ # @return [Boolean]
106
+ # @see https://docs.cal.syoboi.jp/spec/proginfo-flag/
107
+ def re_air?
108
+ flag & 0x08 != 0
109
+ end
110
+
76
111
  # @param attrs [Hash]
77
112
  #
78
113
  # @return [Syobocalite::Program]
@@ -1,3 +1,3 @@
1
1
  module Syobocalite
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/syobocalite.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "syobocalite/version"
2
2
  require "syobocalite/program"
3
+ require "syobocalite/db_client"
3
4
  require "active_support/all"
4
5
  require "multi_xml"
5
6
  require "open-uri"
@@ -12,7 +13,7 @@ module Syobocalite
12
13
  #
13
14
  # @return [Array<Program>]
14
15
  #
15
- # @see https://sites.google.com/site/syobocal/spec/cal_chk-php
16
+ # @see https://docs.cal.syoboi.jp/spec/cal_chk.php/
16
17
  def self.search(start_at:, end_at:)
17
18
  xml = fetch(start_at: start_at, end_at: end_at)
18
19
  response = MultiXml.parse(xml)
@@ -25,6 +26,11 @@ module Syobocalite
25
26
  end
26
27
  end
27
28
 
29
+ # @return [String]
30
+ def self.user_agent
31
+ "Syobocalite v#{Syobocalite::VERSION}"
32
+ end
33
+
28
34
  def self.fetch(start_at:, end_at:)
29
35
  params = {}
30
36
 
@@ -38,7 +44,7 @@ module Syobocalite
38
44
  end
39
45
 
40
46
  headers = {
41
- "User-Agent" => "Syobocalite v#{Syobocalite::VERSION}",
47
+ "User-Agent" => user_agent,
42
48
  }
43
49
 
44
50
  URI.open("http://cal.syoboi.jp/cal_chk.php?#{params.to_param}", headers).read
data/syobocalite.gemspec CHANGED
@@ -16,15 +16,11 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.required_ruby_version = ">= 2.3.0"
18
18
 
19
- if spec.respond_to?(:metadata)
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = spec.homepage
22
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
23
- spec.metadata["rubygems_mfa_required"] = "true"
24
- else
25
- raise "RubyGems 2.0 or newer is required to protect against " \
26
- "public gem pushes."
27
- end
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = spec.homepage
21
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
22
+ spec.metadata["documentation_uri"] = "https://sue445.github.io/syobocalite/"
23
+ spec.metadata["rubygems_mfa_required"] = "true"
28
24
 
29
25
  # Specify which files should be added to the gem when it is released.
30
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -41,7 +37,7 @@ Gem::Specification.new do |spec|
41
37
  spec.add_dependency "multi_xml"
42
38
 
43
39
  spec.add_development_dependency "bundler", ">= 1.16"
44
- spec.add_development_dependency "coveralls"
40
+ spec.add_development_dependency "coveralls_reborn"
45
41
  spec.add_development_dependency "pry-byebug"
46
42
  spec.add_development_dependency "rake", ">= 10.0"
47
43
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syobocalite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-20 00:00:00.000000000 Z
11
+ date: 2024-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.16'
55
55
  - !ruby/object:Gem::Dependency
56
- name: coveralls
56
+ name: coveralls_reborn
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -158,6 +158,8 @@ extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
160
  - ".coveralls.yml"
161
+ - ".github/dependabot.yml"
162
+ - ".github/workflows/pages.yml"
161
163
  - ".github/workflows/test.yml"
162
164
  - ".gitignore"
163
165
  - ".rspec"
@@ -170,6 +172,7 @@ files:
170
172
  - bin/console
171
173
  - bin/setup
172
174
  - lib/syobocalite.rb
175
+ - lib/syobocalite/db_client.rb
173
176
  - lib/syobocalite/program.rb
174
177
  - lib/syobocalite/version.rb
175
178
  - syobocalite.gemspec
@@ -180,6 +183,7 @@ metadata:
180
183
  homepage_uri: https://github.com/sue445/syobocalite
181
184
  source_code_uri: https://github.com/sue445/syobocalite
182
185
  changelog_uri: https://github.com/sue445/syobocalite/blob/master/CHANGELOG.md
186
+ documentation_uri: https://sue445.github.io/syobocalite/
183
187
  rubygems_mfa_required: 'true'
184
188
  post_install_message:
185
189
  rdoc_options: []
@@ -196,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
200
  - !ruby/object:Gem::Version
197
201
  version: '0'
198
202
  requirements: []
199
- rubygems_version: 3.2.22
203
+ rubygems_version: 3.5.3
200
204
  signing_key:
201
205
  specification_version: 4
202
206
  summary: Lite client for Syoboi calendar