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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b51ba18dce6ea95e76c1fc67b267da6c2b8a688c5e40b402f68e2b688175485e
4
- data.tar.gz: 01cd7b7e605ac2524e581d5b97bd3367047a314f0337baec028eb8a4d6897615
3
+ metadata.gz: 25c5b81d90d4db4cfe123670105ad4cf91f3ff8a54ffa8c242385a39d1ef9827
4
+ data.tar.gz: 567ffbebc172d3747f85dd158610bc4e3baabadae8387306912f7bf4dd1dcc7f
5
5
  SHA512:
6
- metadata.gz: a568228270b45bb3e4ffa7da6889f44d232b10bdafbe6fd63c11a9fc65ca399feeeb56cdc2120a8ed680bcdf3f43c0df2ddae3af7c05093ad9a0468ff30e66f8
7
- data.tar.gz: b9bcff90f51c0186a6bc419fd36d70657a2ac1df8d6cbd090bd9c13106031e250c7744fdc442021232fddbb58fcf4b48759e5f2ffa0334f21479c547158c0521
6
+ metadata.gz: 3c05022d1bcca228c5c977776f89057087010dfd5da8617a529984d7cdaedcec8418a5167ef59afef2f0e628fbda425d4fffec528ade81413cf36a7fb6e1cbb4
7
+ data.tar.gz: e0560ede407f54ea6d840c9096bdfd67557832b4fd797c2fa60746b35f2295a55b5f016b94a7957704eb7457eb88f2710a3b76b2b01b5c2277d604140c6d7fba
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coelacanth (0.1.0)
4
+ coelacanth (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -73,4 +73,4 @@ DEPENDENCIES
73
73
  rubocop (~> 1.21)
74
74
 
75
75
  BUNDLED WITH
76
- 2.5.14
76
+ 2.5.7
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # coelacanth
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/coelacanth.svg)](https://badge.fury.io/rb/coelacanth)
4
- [![Build Status](https://github.com/slidict/coelacanth/actions/workflows/test.yml/badge.svg)](https://github.com/slidict/coelacanth/actions)
4
+ [![Build Status](https://github.com/slidict/coelacanth/actions/workflows/main.yml/badge.svg)](https://github.com/slidict/coelacanth/actions)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/123abc456def/maintainability)](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
 
@@ -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:
@@ -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 URI.parse(url)
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 Configure.new.read("use_remote_client")
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(URI.parse(url))
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 ||= Ferrum::Browser.new(
41
- ws_url: "ws://chrome:3000/chrome",
42
- timeout: 20
43
- ).create_page
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coelacanth
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/coelacanth.rb CHANGED
@@ -11,7 +11,8 @@ module Coelacanth
11
11
  class RedirectError < StandardError; end
12
12
  class DeepRedirectError < StandardError; end
13
13
 
14
- def self.analyze(_url)
14
+ def self.analyze(url)
15
+ Client.get_response(url)
15
16
  {
16
17
  todo: "implement me"
17
18
  }
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.0
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-24 00:00:00.000000000 Z
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/blob/main/CHANGELOG.md
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.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.5.7
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.
@@ -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