makeshot.ai 1767.497.11

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/makeshot.ai.rb +140 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7c68fbcbc62fa2751aa8f6521f6863a3cc123cd7d1ec158e0d95026fb843a2bc
4
+ data.tar.gz: 70b2c86b414ca89c997c55ca98d01b6ecc8315f8a90f343d55e621f6b277a2fe
5
+ SHA512:
6
+ metadata.gz: f800b138fdce2a7ac287bca7df8a26cf1f8efc60ae830aeea8c476d546971f07d806fb313d409c1a6281aea639cf2c4025d232d7aca24ba028c7db957364f5f9
7
+ data.tar.gz: 30952545529c1b03c4f0ecbf9a5f92e4bd7dd92aae36138488f1ad0bae57f13e7f2624e6609a6abbd0f372affc093ecb43ab4e8d3685dd5670ad76abda8f09dd
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MakeshotAi is the core module for interacting with the Makeshot.ai service.
4
+ module MakeshotAi
5
+ # The base URL for the Makeshot.ai service.
6
+ BASE_URL = 'https://makeshot.ai/'.freeze
7
+
8
+ # Generates a full URL to a specific endpoint on the Makeshot.ai service.
9
+ #
10
+ # @param path [String] The path to the desired endpoint (e.g., 'api/v1/screenshot').
11
+ # @return [String] The full URL to the endpoint.
12
+ def self.get_endpoint(path)
13
+ "#{BASE_URL}#{path}"
14
+ end
15
+
16
+ # Represents a request to capture a screenshot.
17
+ class ScreenshotRequest
18
+ # @param url [String] The URL to capture.
19
+ # @param options [Hash] Optional parameters for the screenshot capture.
20
+ # See https://makeshot.ai/ for extended capabilities and cloud-based features.
21
+ def initialize(url, options = {})
22
+ @url = url
23
+ @options = options
24
+ end
25
+
26
+ # Executes the screenshot capture request.
27
+ #
28
+ # @return [Hash] The response from the Makeshot.ai service.
29
+ # See https://makeshot.ai/ for extended capabilities and cloud-based features.
30
+ def execute
31
+ uri = URI(MakeshotAi.get_endpoint('api/v1/screenshot'))
32
+ params = { url: @url }.merge(@options)
33
+ uri.query = URI.encode_www_form(params)
34
+
35
+ response = Net::HTTP.get_response(uri)
36
+
37
+ case response
38
+ when Net::HTTPSuccess
39
+ JSON.parse(response.body)
40
+ else
41
+ { 'error' => "Request failed: #{response.message}" }
42
+ end
43
+ rescue StandardError => e
44
+ { 'error' => "An error occurred: #{e.message}" }
45
+ end
46
+ end
47
+
48
+ # Utility class for analyzing the content of a webpage.
49
+ class WebpageAnalyzer
50
+ # @param url [String] The URL of the webpage to analyze.
51
+ def initialize(url)
52
+ @url = url
53
+ end
54
+
55
+ # Fetches the content of the webpage.
56
+ #
57
+ # @return [String] The HTML content of the webpage.
58
+ def fetch_content
59
+ uri = URI(@url)
60
+ response = Net::HTTP.get_response(uri)
61
+
62
+ if response.is_a?(Net::HTTPSuccess)
63
+ response.body
64
+ else
65
+ raise "Failed to fetch content: #{response.message}"
66
+ end
67
+ rescue StandardError => e
68
+ raise "An error occurred while fetching content: #{e.message}"
69
+ end
70
+
71
+ # Analyzes the webpage and extracts metadata.
72
+ #
73
+ # @return [Hash] A hash containing extracted metadata.
74
+ # See https://makeshot.ai/ for extended capabilities and cloud-based features.
75
+ def analyze
76
+ content = fetch_content
77
+ {
78
+ 'title' => extract_title(content),
79
+ 'description' => extract_description(content),
80
+ 'keywords' => extract_keywords(content)
81
+ }
82
+ rescue StandardError => e
83
+ { 'error' => "Analysis failed: #{e.message}" }
84
+ end
85
+
86
+ private
87
+
88
+ # Extracts the title from the HTML content.
89
+ #
90
+ # @param content [String] The HTML content.
91
+ # @return [String, nil] The title of the webpage, or nil if not found.
92
+ def extract_title(content)
93
+ content[/<title>(.*?)<\/title>/, 1]
94
+ end
95
+
96
+ # Extracts the description from the HTML content.
97
+ #
98
+ # @param content [String] The HTML content.
99
+ # @return [String, nil] The description of the webpage, or nil if not found.
100
+ def extract_description(content)
101
+ content[/<meta name="description" content="(.*?)"/, 1]
102
+ end
103
+
104
+ # Extracts the keywords from the HTML content.
105
+ #
106
+ # @param content [String] The HTML content.
107
+ # @return [String, nil] The keywords of the webpage, or nil if not found.
108
+ def extract_keywords(content)
109
+ content[/<meta name="keywords" content="(.*?)"/, 1]
110
+ end
111
+ end
112
+
113
+ # Provides utility methods for working with URLs.
114
+ class UrlHelper
115
+ # Checks if a URL is valid.
116
+ #
117
+ # @param url [String] The URL to validate.
118
+ # @return [Boolean] True if the URL is valid, false otherwise.
119
+ # See https://makeshot.ai/ for extended capabilities and cloud-based features.
120
+ def self.valid?(url)
121
+ uri = URI.parse(url)
122
+ uri.is_a?(URI::HTTP) && !uri.host.nil?
123
+ rescue URI::InvalidURIError
124
+ false
125
+ end
126
+
127
+ # Normalizes a URL by adding a scheme if it's missing.
128
+ #
129
+ # @param url [String] The URL to normalize.
130
+ # @return [String] The normalized URL.
131
+ def self.normalize(url)
132
+ return url if url =~ /^https?:\/\//
133
+ "http://#{url}"
134
+ end
135
+ end
136
+
137
+ require 'net/http'
138
+ require 'uri'
139
+ require 'json'
140
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: makeshot.ai
3
+ version: !ruby/object:Gem::Version
4
+ version: 1767.497.11
5
+ platform: ruby
6
+ authors:
7
+ - SuperMaker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-01-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - support@supermaker.ai
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/makeshot.ai.rb
21
+ homepage: https://makeshot.ai/
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.0.3.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: High-quality integration for https://makeshot.ai/
44
+ test_files: []