nautilfer 0.1.0 → 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: 63572dcc526bf5914968d100b6f19547ce5de40f609b44c0009e9a4ba8b8eb66
4
- data.tar.gz: c8c4bed3fb1aabdb49d777890224f49d8f2edf9f3a40749e034dc8685958fb45
3
+ metadata.gz: 2fc027969725b3e916bbfebc596676e05d3c0a698f182a5838ede547da8b016a
4
+ data.tar.gz: 531ea3a97fae61b2c7ee5f1958861f7e997daca78e9fe4fda76aeb95015a5672
5
5
  SHA512:
6
- metadata.gz: 1056cbfed52ccefe35fa7e68862f717f961b2db8914888bd7b9d4bb3241ea71b5624b04027b779a04eec4bdc4486ac982f3e9829bfe50cf3fe759bd2ce31714c
7
- data.tar.gz: c103d702a3cda831e1bef1471eefc4c13fc49eb599ce4ecbac3635011e7279b95d39a6239797d052ab01e02e54d07f0c1215dd53d3652a69aae87d7592ff2599
6
+ metadata.gz: e57b2c398f43fc49ec46f6ae5ef014641bdaa1b6debcb2905d89971010420f9e4e8413c1fe9fe55268e533786e9dfb6beccc2d38a01dd2bbb35a885246462981
7
+ data.tar.gz: 7be68f6112a193024924eb3069e8659a02daa63da94475035b1cf44b4f9e29bcfb082eeebe7cc1dc98e2d5b8acd4c4f3738b586230b8a2d3e49ff9b7371e1c25
data/AGENTS.md ADDED
@@ -0,0 +1,6 @@
1
+ # Agent Instructions
2
+
3
+ - After implementing changes in this repository, you must run `bundle install` followed by `bundle exec rspec`.
4
+ - Every change must include appropriate updates to the test suite (add or modify specs as needed).
5
+ - Update the README if necessary to reflect your changes.
6
+ - All instructions in this file are written in English and should be followed as written.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nautilfer (0.1.0)
4
+ nautilfer (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -26,8 +26,7 @@ GEM
26
26
  rainbow (3.1.1)
27
27
  rake (13.2.1)
28
28
  regexp_parser (2.9.2)
29
- rexml (3.3.6)
30
- strscan
29
+ rexml (3.4.2)
31
30
  rspec (3.13.0)
32
31
  rspec-core (~> 3.13.0)
33
32
  rspec-expectations (~> 3.13.0)
@@ -54,7 +53,6 @@ GEM
54
53
  rubocop-ast (1.32.1)
55
54
  parser (>= 3.3.1.0)
56
55
  ruby-progressbar (1.13.0)
57
- strscan (3.1.0)
58
56
  unicode-display_width (2.5.0)
59
57
  webmock (3.23.1)
60
58
  addressable (>= 2.8.0)
@@ -73,4 +71,4 @@ DEPENDENCIES
73
71
  webmock (~> 3.23)
74
72
 
75
73
  BUNDLED WITH
76
- 2.5.17
74
+ 2.7.1
data/README.md CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
7
  `nautilfer` is a gem that allows you to parse and analyze web pages, extracting key statistics and information for further use within your projects.
8
8
 
9
+ ## Requirements
10
+
11
+ - Ruby >= 3.4
12
+
9
13
  ## Installation
10
14
 
11
15
  Add this line to your application's Gemfile:
@@ -52,6 +56,33 @@ Then, you can easily parse and extract information from a web page like this:
52
56
  Nautilfer.to_teams(message: "## TEST\nhello", endpoint: "#{workflow_endpoint}")
53
57
  ```
54
58
 
59
+ Or instantiate Nautilfer directly when you want to reuse the same endpoint:
60
+
61
+ ```ruby
62
+ notifier = Nautilfer.new(endpoint: "#{workflow_endpoint}", adapter: :teams)
63
+ notifier.notify("## TEST\nhello")
64
+ ```
65
+
66
+ To notify a Slack channel via Incoming Webhook:
67
+
68
+ ```ruby
69
+ Nautilfer.to_slack(message: "Deployment completed", endpoint: "#{slack_webhook_url}")
70
+ ```
71
+
72
+ ```ruby
73
+ slack_notifier = Nautilfer.new(endpoint: "#{slack_webhook_url}", adapter: :slack)
74
+ slack_notifier.notify("Deployment completed")
75
+ ```
76
+
77
+ ## Chatwork Notification Integration
78
+
79
+ To enable Chatwork notifications, configure the API token and room ID:
80
+
81
+ ```ruby
82
+ notifier = Nautilfer::ChatworkNotifier.new('your_api_token', 'your_room_id')
83
+ notifier.notify('This is a test message from Nautilfer!')
84
+ ```
85
+
55
86
  ## Features
56
87
  - More features coming soon!
57
88
 
@@ -0,0 +1,29 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ class Nautilfer
6
+ class ChatworkNotifier
7
+ CHATWORK_API_ENDPOINT = "https://api.chatwork.com/v2"
8
+
9
+ def initialize(api_token, room_id)
10
+ @api_token = api_token
11
+ @room_id = room_id
12
+ end
13
+
14
+ def notify(message)
15
+ uri = URI("#{CHATWORK_API_ENDPOINT}/rooms/#{@room_id}/messages")
16
+ request = Net::HTTP::Post.new(uri)
17
+ request['X-ChatWorkToken'] = @api_token
18
+ request.set_form_data(body: message)
19
+
20
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
21
+ http.request(request)
22
+ end
23
+
24
+ raise "Failed to send notification: #{response.body}" unless response.is_a?(Net::HTTPSuccess)
25
+
26
+ JSON.parse(response.body)
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Nautilfer
4
- VERSION = "0.1.0"
3
+ class Nautilfer
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/nautilfer.rb CHANGED
@@ -3,11 +3,60 @@
3
3
  require_relative "nautilfer/version"
4
4
  require "json/add/core"
5
5
  require "net/http"
6
+ require "uri"
6
7
 
7
- module Nautilfer
8
+ class Nautilfer
8
9
  class Error < StandardError; end
10
+
11
+ def initialize(endpoint:, adapter: :teams)
12
+ @endpoint = URI.parse(endpoint)
13
+ @adapter = adapter
14
+ end
15
+
16
+ def notify(message)
17
+ payload, headers = build_payload(message)
18
+ perform_request(payload, headers)
19
+ end
20
+
9
21
  def self.to_teams(message:, endpoint:)
10
- message = {
22
+ new(endpoint: endpoint, adapter: :teams).notify(message)
23
+ end
24
+
25
+ def self.to_slack(message:, endpoint:)
26
+ new(endpoint: endpoint, adapter: :slack).notify(message)
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :endpoint, :adapter
32
+
33
+ def build_payload(message)
34
+ case adapter
35
+ when :teams
36
+ [teams_payload(message), default_headers]
37
+ when :slack
38
+ [slack_payload(message), default_headers]
39
+ else
40
+ raise Error, "Unsupported adapter: #{adapter}"
41
+ end
42
+ end
43
+
44
+ def default_headers
45
+ { 'Content-Type' => 'application/json' }
46
+ end
47
+
48
+ def perform_request(payload, headers)
49
+ http = Net::HTTP.new(endpoint.host, endpoint.port)
50
+ http.use_ssl = endpoint.scheme == 'https'
51
+ http.start do |connection|
52
+ request = Net::HTTP::Post.new(endpoint.request_uri, headers)
53
+ request.body = payload.to_json
54
+ connection.request(request)
55
+ end
56
+ end
57
+
58
+ def teams_payload(message)
59
+ {
11
60
  "attachments": [
12
61
  {
13
62
  "contentType": "application/vnd.microsoft.card.adaptive",
@@ -27,14 +76,11 @@ module Nautilfer
27
76
  }
28
77
  ]
29
78
  }
79
+ end
30
80
 
31
- uri = URI.parse(endpoint)
32
- http = Net::HTTP.new(uri.host, uri.port)
33
- http.use_ssl = true
34
- http.start do |h|
35
- request = Net::HTTP::Post.new(uri.request_uri, { 'Content-Type' => 'application/json' })
36
- request.body = message.to_json
37
- h.request(request)
38
- end
81
+ def slack_payload(message)
82
+ {
83
+ "text": message
84
+ }
39
85
  end
40
86
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nautilfer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Abe
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-09-02 00:00:00.000000000 Z
10
+ date: 2025-11-11 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Nautilfer provides a robust and flexible way to send notifications to
14
13
  Microsoft Teams using workflow integrations.
@@ -20,6 +19,7 @@ extra_rdoc_files: []
20
19
  files:
21
20
  - ".rspec"
22
21
  - ".rubocop.yml"
22
+ - AGENTS.md
23
23
  - CODE_OF_CONDUCT.md
24
24
  - Dockerfile
25
25
  - Gemfile
@@ -29,6 +29,7 @@ files:
29
29
  - Rakefile
30
30
  - compose.yml
31
31
  - lib/nautilfer.rb
32
+ - lib/nautilfer/chatwork_notifier.rb
32
33
  - lib/nautilfer/version.rb
33
34
  homepage: https://github.com/slidict/nautilfer
34
35
  licenses:
@@ -37,7 +38,6 @@ metadata:
37
38
  homepage_uri: https://github.com/slidict/nautilfer
38
39
  source_code_uri: https://github.com/slidict/nautilfer
39
40
  changelog_uri: https://github.com/slidict/nautilfer/releases
40
- post_install_message:
41
41
  rdoc_options: []
42
42
  require_paths:
43
43
  - lib
@@ -45,15 +45,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '3.0'
48
+ version: '3.4'
49
49
  required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubygems_version: 3.4.1
56
- signing_key:
55
+ rubygems_version: 3.6.2
57
56
  specification_version: 4
58
57
  summary: A gem for workflow-based notifications for Teams
59
58
  test_files: []