coelacanth 0.1.0 → 0.1.4
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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +23 -3
- data/config/coelacanth.yml +6 -0
- data/lib/coelacanth/client.rb +17 -7
- data/lib/coelacanth/configure.rb +7 -1
- data/lib/coelacanth/version.rb +1 -1
- data/lib/coelacanth.rb +2 -1
- metadata +5 -8
- data/changelog-ci-config.yml +0 -29
- data/coelacanth.gemspec +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25c5b81d90d4db4cfe123670105ad4cf91f3ff8a54ffa8c242385a39d1ef9827
|
4
|
+
data.tar.gz: 567ffbebc172d3747f85dd158610bc4e3baabadae8387306912f7bf4dd1dcc7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c05022d1bcca228c5c977776f89057087010dfd5da8617a529984d7cdaedcec8418a5167ef59afef2f0e628fbda425d4fffec528ade81413cf36a7fb6e1cbb4
|
7
|
+
data.tar.gz: e0560ede407f54ea6d840c9096bdfd67557832b4fd797c2fa60746b35f2295a55b5f016b94a7957704eb7457eb88f2710a3b76b2b01b5c2277d604140c6d7fba
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# coelacanth
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/coelacanth)
|
4
|
-
[](https://github.com/slidict/coelacanth/actions)
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
6
|
-
[](https://codeclimate.com/github/slidict/coelacanth/maintainability)
|
7
6
|
|
8
7
|
`coelacanth` is a gem that allows you to parse and analyze web pages, extracting key statistics and information for further use within your projects.
|
9
8
|
|
@@ -51,12 +50,33 @@ Then, you can easily parse and extract information from a web page like this:
|
|
51
50
|
|
52
51
|
```ruby
|
53
52
|
url = "https://example.com"
|
54
|
-
stats = Coelacanth.analyze(url)
|
53
|
+
stats = Coelacanth.analyze(url) # Not yet implement
|
55
54
|
```
|
56
55
|
|
57
56
|
## Features
|
58
57
|
- More features coming soon!
|
59
58
|
|
59
|
+
## Commit Message Guidelines
|
60
|
+
|
61
|
+
To ensure consistency and facilitate automatic updates to the `CHANGELOG.md`, please follow the [Conventional Commits](https://www.conventionalcommits.org/) specification when creating commit messages. This helps maintain a clear and structured commit history.
|
62
|
+
|
63
|
+
When submitting a Pull Request (PR), make sure your commits adhere to these guidelines.
|
64
|
+
|
65
|
+
### Example of Conventional Commit Messages:
|
66
|
+
|
67
|
+
- `feat: add new feature for parsing web pages`
|
68
|
+
- `fix: resolve issue with URL redirection`
|
69
|
+
- `docs: update README with usage instructions`
|
70
|
+
- `chore: update dependencies`
|
71
|
+
- `build: update build configuration`
|
72
|
+
- `ci: update CI pipeline`
|
73
|
+
- `style: fix code style issues`
|
74
|
+
- `refactor: refactor code for better readability`
|
75
|
+
- `perf: improve performance of data processing`
|
76
|
+
- `test: add new tests for URL parsing module`
|
77
|
+
|
78
|
+
By following these guidelines, you help ensure that our project's commit history is easy to navigate and that versioning and release notes are generated correctly.
|
79
|
+
|
60
80
|
## Contributing
|
61
81
|
Bug reports and pull requests are welcome on GitHub at https://github.com/slidict/coelacanth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
|
62
82
|
|
data/config/coelacanth.yml
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
development: &development
|
2
2
|
use_remote_client: false
|
3
|
+
remote_client:
|
4
|
+
ws_url: "ws://chrome:3000/chrome"
|
5
|
+
timeout: 10 # seconds
|
6
|
+
headers:
|
7
|
+
Authorization: "Bearer 1234567890"
|
8
|
+
User-Agent: "Coelacanth Chrome Extension"
|
3
9
|
test:
|
4
10
|
<<: *development
|
5
11
|
production:
|
data/lib/coelacanth/client.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "ferrum"
|
3
4
|
|
4
5
|
module Coelacanth
|
5
6
|
# Coelacanth::Client
|
6
7
|
class Client
|
8
|
+
def initialize
|
9
|
+
@config = Configure.new
|
10
|
+
end
|
11
|
+
|
7
12
|
def valid_url?(url)
|
8
13
|
uri = URI.parse(url)
|
9
14
|
uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
|
@@ -18,7 +23,7 @@ module Coelacanth
|
|
18
23
|
response = get_response(url)
|
19
24
|
|
20
25
|
case response
|
21
|
-
when Net::HTTPSuccess then
|
26
|
+
when Net::HTTPSuccess then url
|
22
27
|
when Net::HTTPRedirection then resolve_redirect(response["location"], limit - 1)
|
23
28
|
else
|
24
29
|
raise Coelacanth::RedirectError
|
@@ -26,21 +31,26 @@ module Coelacanth
|
|
26
31
|
end
|
27
32
|
|
28
33
|
def get_response(url)
|
29
|
-
if
|
34
|
+
if @config.read("use_remote_client")
|
30
35
|
remote_client.goto(url)
|
31
36
|
remote_client.body
|
32
37
|
else
|
33
|
-
Net::HTTP.get_response(
|
38
|
+
Net::HTTP.get_response(url)
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
37
42
|
private
|
38
43
|
|
39
44
|
def remote_client
|
40
|
-
@remote_client
|
41
|
-
|
42
|
-
|
43
|
-
|
45
|
+
if @remote_client.nil?
|
46
|
+
headers = @config.read("remote_client.headers")
|
47
|
+
@remote_client = Ferrum::Browser.new(
|
48
|
+
ws_url: @config.read("remote_client.ws_url"),
|
49
|
+
timeout: @config.read("remote_client.timeout")
|
50
|
+
).create_page
|
51
|
+
@remote_client.headers.set(headers) unless headers.empty?
|
52
|
+
end
|
53
|
+
@remote_client
|
44
54
|
end
|
45
55
|
end
|
46
56
|
end
|
data/lib/coelacanth/configure.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "yaml"
|
3
4
|
require "erb"
|
4
5
|
|
@@ -8,8 +9,13 @@ module Coelacanth
|
|
8
9
|
CONFIG_PATH = "config/coelacanth.yml"
|
9
10
|
|
10
11
|
def read(key)
|
12
|
+
return yaml[key] unless key.include?(".")
|
13
|
+
|
14
|
+
key.split(".").reduce(yaml) { |hash, k| hash[k] }
|
15
|
+
end
|
16
|
+
|
17
|
+
def yaml
|
11
18
|
@yaml ||= YAML.unsafe_load(ERB.new(File.read(file)).result)[env]
|
12
|
-
@yaml[key]
|
13
19
|
end
|
14
20
|
|
15
21
|
private
|
data/lib/coelacanth/version.rb
CHANGED
data/lib/coelacanth.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coelacanth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
coelacanth is a gem that allows you to easily parse and analyze web pages,
|
@@ -29,8 +29,6 @@ files:
|
|
29
29
|
- LICENSE.txt
|
30
30
|
- README.md
|
31
31
|
- Rakefile
|
32
|
-
- changelog-ci-config.yml
|
33
|
-
- coelacanth.gemspec
|
34
32
|
- compose.yml
|
35
33
|
- config/coelacanth.yml
|
36
34
|
- lib/coelacanth.rb
|
@@ -41,10 +39,9 @@ homepage: https://github.com/slidict/coelacanth
|
|
41
39
|
licenses:
|
42
40
|
- MIT
|
43
41
|
metadata:
|
44
|
-
allowed_push_host: https://rubygems.org
|
45
42
|
homepage_uri: https://github.com/slidict/coelacanth
|
46
43
|
source_code_uri: https://github.com/slidict/coelacanth
|
47
|
-
changelog_uri: https://github.com/slidict/coelacanth/
|
44
|
+
changelog_uri: https://github.com/slidict/coelacanth/releases
|
48
45
|
post_install_message:
|
49
46
|
rdoc_options: []
|
50
47
|
require_paths:
|
@@ -53,14 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
50
|
requirements:
|
54
51
|
- - ">="
|
55
52
|
- !ruby/object:Gem::Version
|
56
|
-
version: '3.
|
53
|
+
version: '3.0'
|
57
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
55
|
requirements:
|
59
56
|
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
58
|
version: '0'
|
62
59
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.4.1
|
64
61
|
signing_key:
|
65
62
|
specification_version: 4
|
66
63
|
summary: A gem for analyzing and extracting statistics from web pages.
|
data/changelog-ci-config.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
changelog_type: 'commit_message' # or 'pull_request'
|
2
|
-
header_prefix: 'Version:'
|
3
|
-
commit_changelog: true
|
4
|
-
comment_changelog: true
|
5
|
-
include_unlabeled_changes: true
|
6
|
-
unlabeled_group_title: 'Unlabeled Changes'
|
7
|
-
pull_request_title_regex: '^Release'
|
8
|
-
version_regex: 'v?([0-9]{1,2})+[.]+([0-9]{1,2})+[.]+([0-9]{1,2})\s\(\d{1,2}-\d{1,2}-\d{4}\)'
|
9
|
-
exclude_labels:
|
10
|
-
- bot
|
11
|
-
- dependabot
|
12
|
-
- ci
|
13
|
-
group_config:
|
14
|
-
- title: Bug Fixes
|
15
|
-
labels:
|
16
|
-
- bug
|
17
|
-
- bugfix
|
18
|
-
- title: Code Improvements
|
19
|
-
labels:
|
20
|
-
- improvements
|
21
|
-
- enhancement
|
22
|
-
- title: New Features
|
23
|
-
labels:
|
24
|
-
- feature
|
25
|
-
- title: Documentation Updates
|
26
|
-
labels:
|
27
|
-
- docs
|
28
|
-
- documentation
|
29
|
-
- doc
|
data/coelacanth.gemspec
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/coelacanth/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "coelacanth"
|
7
|
-
spec.version = Coelacanth::VERSION
|
8
|
-
spec.authors = ["Yusuke"]
|
9
|
-
spec.email = ["yusuke@slidict.io"]
|
10
|
-
|
11
|
-
spec.summary = "A gem for analyzing and extracting statistics from web pages."
|
12
|
-
spec.description = <<~DESC
|
13
|
-
coelacanth is a gem that allows you to easily parse and analyze web pages,
|
14
|
-
extracting key statistics and information for further use in various projects."
|
15
|
-
DESC
|
16
|
-
spec.homepage = "https://github.com/slidict/coelacanth"
|
17
|
-
spec.license = "MIT"
|
18
|
-
spec.required_ruby_version = ">= 3.3"
|
19
|
-
|
20
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
-
spec.metadata["source_code_uri"] = "https://github.com/slidict/coelacanth"
|
23
|
-
spec.metadata["changelog_uri"] = "https://github.com/slidict/coelacanth/blob/main/CHANGELOG.md"
|
24
|
-
|
25
|
-
spec.files = Dir.chdir(__dir__) do
|
26
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
spec.bindir = "exe"
|
32
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
|
-
spec.require_paths = ["lib"]
|
34
|
-
|
35
|
-
# Uncomment to register a new dependency of your gem
|
36
|
-
# spec.add_dependency "nokogiri", "~> 1.12"
|
37
|
-
end
|