hatenablog_publisher 0.1.3 → 0.3.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
2
  SHA256:
3
- metadata.gz: b4d7a12f8c90dd7935b75ae3d38c753be5de35c90d04359838c2f7bf287d6240
4
- data.tar.gz: 77109bd61c92b19ed09435e935100d40331cb627b8dbaeff95856ba86180d643
3
+ metadata.gz: 1c3040d39a5be46c7a7e2dcf5fd7ee32b0b598e6b784924f455260173b8d4743
4
+ data.tar.gz: 30370641aa5797c6f77b4a63e12a68fea0fdd4083dad15ae20a5a90cc0ffbfba
5
5
  SHA512:
6
- metadata.gz: 236522c0ec5b627ce2ccaff7800b06613ef7fdc019dff261a62658a64a9a01179788bac6878af44019f85ec728570b3f55ebf5c8efb14e9dd6ae24ccf12d5582
7
- data.tar.gz: aa73000a6526d5b1a5235c270a967f9451c444ca33f8bb664aa64a09aacd21660b78021d2f4fe0e0a5c9b41913b86a41a74b062618506012868da82168f21602
6
+ metadata.gz: 99bd3e7df86ca28647270467861be3b61899a45c16abdc537e638618482b38c8938493ee8eb4845ddfae1a5efca130f626938f12ea195cc19638f716a04805a4
7
+ data.tar.gz: 18f8e3f072782ed1df829261378bfa3499873bbb6a373fe4387f226e7a81e0e7808151a32fb5d7f0613f4fb0b3062e1d5d3ed4c4948d2ff9c273ab8174edc9e4
@@ -0,0 +1,9 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
7
+ labels:
8
+ - dependabot
9
+ open-pull-requests-limit: 10
@@ -7,12 +7,16 @@ jobs:
7
7
  test:
8
8
  runs-on: ubuntu-latest
9
9
  name: 'test'
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby-version: ['2.6', '2.7', '3.0', '3.1']
10
14
  steps:
11
- - uses: actions/checkout@v2
15
+ - uses: actions/checkout@v3.0.2
12
16
  - uses: ruby/setup-ruby@v1
13
17
  with:
14
- ruby-version: 2.6
15
- - uses: actions/cache@v1
18
+ ruby-version: ${{ matrix.ruby-version }}
19
+ - uses: actions/cache@v3.0.2
16
20
  with:
17
21
  path: vendor/bundle
18
22
  key: ${{ runner.os }}-gems-${{ hashFiles('./Gemfile.lock') }}
@@ -28,6 +32,8 @@ jobs:
28
32
  HATENABLOG_CONSUMER_SECRET: dummy
29
33
  HATENABLOG_ACCESS_TOKEN_SECRET: dummy
30
34
  HATENABLOG_ACCESS_TOKEN: dummy
35
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
36
+ CI: true
31
37
  run: |
32
38
  bundle exec rspec
33
39
 
@@ -35,10 +41,14 @@ jobs:
35
41
  runs-on: ubuntu-latest
36
42
  name: 'rubocop'
37
43
  steps:
38
- - uses: actions/checkout@v2
44
+ - uses: actions/checkout@v3.0.2
45
+ - name: Read Ruby version from .ruby-version
46
+ run: echo ::set-output name=ruby_version::$(cat .ruby-version)
47
+ id: ruby-version
48
+
39
49
  - uses: ruby/setup-ruby@v1
40
50
  with:
41
- ruby-version: 2.6
51
+ ruby-version: ${{ steps.ruby-version.outputs.ruby_version }}
42
52
  - run: |
43
53
  gem install rubocop
44
54
 
@@ -48,7 +58,14 @@ jobs:
48
58
  run: |
49
59
  curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s
50
60
  rubocop | ./bin/reviewdog -f=rubocop -reporter=github-pr-review
51
- # - uses: reviewdog/action-rubocop@v1
52
- # with:
53
- # github_token: ${{ secrets.GITHUB_TOKEN }}
54
- # reporter: github-pr-check
61
+
62
+ slack-notify:
63
+ if: always()
64
+ needs: [test, rubocop]
65
+ name: post slack
66
+ runs-on: ubuntu-latest
67
+ steps:
68
+ - uses: Gamesight/slack-workflow-status@v1.1.0
69
+ with:
70
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
71
+ slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.6
data/Gemfile CHANGED
@@ -3,15 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in hatenablog_publisher.gemspec
4
4
  gemspec
5
5
 
6
- gem 'activesupport'
7
- gem 'awesome_print'
8
- gem 'front_matter_parser'
9
- gem 'mime-types'
10
- gem 'oauth'
11
- gem 'oga'
12
- gem 'pry-byebug'
13
- gem 'rake', '~> 13.0'
14
- gem 'rspec', '~> 3.0'
15
- gem 'rubocop'
16
- gem 'sanitize'
17
- gem 'xml-simple'
6
+ group :test do
7
+ gem 'codecov', require: false
8
+ end
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # HatenablogPublisher
2
2
 
3
+ ![ci](https://github.com/swfz/hatenablog_publisher/workflows/ci/badge.svg)
4
+
5
+ [![codecov](https://codecov.io/gh/swfz/hatenablog_publisher/branch/master/graph/badge.svg)](https://codecov.io/gh/swfz/hatenablog_publisher)
6
+
3
7
  Module to manage local markdown and images using Hatena Blog API and PhotoLife API.
4
8
 
5
9
  ## Installation
@@ -15,7 +15,6 @@ module HatenablogPublisher
15
15
  end
16
16
 
17
17
  def publish
18
- image_tags = @context.text.scan(IMAGE_PATTERN).flatten
19
18
  photolife = HatenablogPublisher::Photolife.new
20
19
  dirname = File.dirname(@options.filename)
21
20
 
@@ -36,6 +35,10 @@ module HatenablogPublisher
36
35
  @context.reload_context
37
36
  end
38
37
 
38
+ def image_tags
39
+ @context.text.scan(IMAGE_PATTERN).flatten.reject { |tag| tag.match('^http') }
40
+ end
41
+
39
42
  def generate_body
40
43
  generator = HatenablogPublisher::Generator::Body.new(@context, @options)
41
44
  body = generator.generate
@@ -1,6 +1,7 @@
1
1
  require 'yaml'
2
2
  require 'time'
3
3
  require 'front_matter_parser'
4
+ require 'active_support'
4
5
  require 'active_support/core_ext/hash'
5
6
 
6
7
  module HatenablogPublisher
@@ -19,7 +20,8 @@ module HatenablogPublisher
19
20
  end
20
21
 
21
22
  def add_image_context(image, tag)
22
- syntax = "[#{image['syntax'].first}]"
23
+ # APIのレスポンスをそのまま使用すると記事上でフォトライフへのリンクになってしまうため、管理画面から画像投稿した結果と合わせた(image -> plain)
24
+ syntax = "[#{image['syntax'].first}]".gsub(/:image\]/,':plain]')
23
25
 
24
26
  @hatena ||= {}
25
27
  @hatena[:image] ||= {}
@@ -13,14 +13,24 @@ module HatenablogPublisher
13
13
  def generate
14
14
  markdown = @context.text.dup
15
15
 
16
- replaced_markdown = replace_image(markdown)
16
+ replaced_markdown = remove_textlint_comment(replace_image(markdown))
17
17
 
18
18
  CGI.escapeHTML(replaced_markdown)
19
19
  end
20
20
 
21
+ def remove_textlint_comment(markdown)
22
+ markdown.gsub(/^<!--\s+textlint-(enable|disable).*-->\n/, '')
23
+ end
24
+
21
25
  def replace_image(markdown)
22
- markdown.gsub(IMAGE_PATTERN) do
23
- "\n\n" + @context.image_syntax(Regexp.last_match(1))
26
+ markdown.gsub(IMAGE_PATTERN) do |s|
27
+ image_name = Regexp.last_match(1)
28
+
29
+ if image_name.match('^http')
30
+ s
31
+ else
32
+ "\n\n" + @context.image_syntax(image_name)
33
+ end
24
34
  end
25
35
  end
26
36
  end
@@ -13,7 +13,7 @@ module HatenablogPublisher
13
13
  end
14
14
 
15
15
  def yaml_loader
16
- FrontMatterParser::Loader::Yaml.new(whitelist_classes: [Time])
16
+ FrontMatterParser::Loader::Yaml.new(allowlist_classes: [Time])
17
17
  end
18
18
 
19
19
  def write(metadata, text)
@@ -1,3 +1,3 @@
1
1
  module HatenablogPublisher
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
data/renovate.json CHANGED
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "extends": [
3
3
  "config:base"
4
- ]
4
+ ],
5
+ "minor": {
6
+ "groupName": "all dependencies"
7
+ }
5
8
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hatenablog_publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - swfz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-22 00:00:00.000000000 Z
11
+ date: 2022-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -186,14 +186,15 @@ executables:
186
186
  extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
+ - ".github/dependabot.yml"
189
190
  - ".github/workflows/ci.yml"
190
191
  - ".gitignore"
191
192
  - ".rspec"
192
193
  - ".rubocop.yml"
194
+ - ".ruby-version"
193
195
  - ".travis.yml"
194
196
  - CODE_OF_CONDUCT.md
195
197
  - Gemfile
196
- - Gemfile.lock
197
198
  - LICENSE.txt
198
199
  - README.md
199
200
  - Rakefile
@@ -237,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
238
  - !ruby/object:Gem::Version
238
239
  version: '0'
239
240
  requirements: []
240
- rubygems_version: 3.0.1
241
+ rubygems_version: 3.1.6
241
242
  signing_key:
242
243
  specification_version: 4
243
244
  summary: Gem that posts to the Hatena Blog API and PhotoLife API
data/Gemfile.lock DELETED
@@ -1,116 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- hatenablog_publisher (0.1.2)
5
- activesupport
6
- front_matter_parser
7
- mime-types
8
- oauth
9
- oga
10
- sanitize
11
- xml-simple
12
-
13
- GEM
14
- remote: https://rubygems.org/
15
- specs:
16
- activesupport (6.0.3)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 0.7, < 2)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- zeitwerk (~> 2.2, >= 2.2.2)
22
- ansi (1.5.0)
23
- ast (2.4.0)
24
- awesome_print (1.8.0)
25
- byebug (11.1.3)
26
- coderay (1.1.2)
27
- concurrent-ruby (1.1.6)
28
- crass (1.0.6)
29
- diff-lcs (1.3)
30
- front_matter_parser (0.2.1)
31
- i18n (1.8.2)
32
- concurrent-ruby (~> 1.0)
33
- jaro_winkler (1.5.4)
34
- method_source (1.0.0)
35
- mime-types (3.3.1)
36
- mime-types-data (~> 3.2015)
37
- mime-types-data (3.2020.0425)
38
- mini_portile2 (2.4.0)
39
- minitest (5.14.0)
40
- nokogiri (1.10.9)
41
- mini_portile2 (~> 2.4.0)
42
- nokogumbo (2.0.2)
43
- nokogiri (~> 1.8, >= 1.8.4)
44
- oauth (0.5.4)
45
- oga (3.2)
46
- ast
47
- ruby-ll (~> 2.1)
48
- parallel (1.19.1)
49
- parser (2.7.1.2)
50
- ast (~> 2.4.0)
51
- pry (0.13.1)
52
- coderay (~> 1.1)
53
- method_source (~> 1.0)
54
- pry-byebug (3.9.0)
55
- byebug (~> 11.0)
56
- pry (~> 0.13.0)
57
- rainbow (3.0.0)
58
- rake (13.0.1)
59
- rexml (3.2.4)
60
- rspec (3.9.0)
61
- rspec-core (~> 3.9.0)
62
- rspec-expectations (~> 3.9.0)
63
- rspec-mocks (~> 3.9.0)
64
- rspec-core (3.9.2)
65
- rspec-support (~> 3.9.3)
66
- rspec-expectations (3.9.1)
67
- diff-lcs (>= 1.2.0, < 2.0)
68
- rspec-support (~> 3.9.0)
69
- rspec-mocks (3.9.1)
70
- diff-lcs (>= 1.2.0, < 2.0)
71
- rspec-support (~> 3.9.0)
72
- rspec-support (3.9.3)
73
- rubocop (0.82.0)
74
- jaro_winkler (~> 1.5.1)
75
- parallel (~> 1.10)
76
- parser (>= 2.7.0.1)
77
- rainbow (>= 2.2.2, < 4.0)
78
- rexml
79
- ruby-progressbar (~> 1.7)
80
- unicode-display_width (>= 1.4.0, < 2.0)
81
- ruby-ll (2.1.2)
82
- ansi
83
- ast
84
- ruby-progressbar (1.10.1)
85
- sanitize (5.1.0)
86
- crass (~> 1.0.2)
87
- nokogiri (>= 1.8.0)
88
- nokogumbo (~> 2.0)
89
- thread_safe (0.3.6)
90
- tzinfo (1.2.7)
91
- thread_safe (~> 0.1)
92
- unicode-display_width (1.7.0)
93
- xml-simple (1.1.5)
94
- zeitwerk (2.3.0)
95
-
96
- PLATFORMS
97
- ruby
98
-
99
- DEPENDENCIES
100
- activesupport
101
- awesome_print
102
- bundler
103
- front_matter_parser
104
- hatenablog_publisher!
105
- mime-types
106
- oauth
107
- oga
108
- pry-byebug
109
- rake (~> 13.0)
110
- rspec (~> 3.0)
111
- rubocop
112
- sanitize
113
- xml-simple
114
-
115
- BUNDLED WITH
116
- 2.1.4