active_connect 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0d2bd3e27629d16544e40a2cbf963e3060b95c043f88754a84f1be54a11518cd
4
+ data.tar.gz: 11fe76063af6c27f221e80eec5a197d9cea4c255e5129179905f79e583553c6a
5
+ SHA512:
6
+ metadata.gz: 2bc3bd1853322a7a1c553f85487155e9323dd8c8e71e5c95a46de886bde589169f460373c0aaf1c3717eb60cbf53eda503c570f9a09d4f271951854480f11080
7
+ data.tar.gz: bcc9dd43b9b9182188f0c152ebc4359226e62ed361eac1f3f3a94ae16d19886118170608c90fd32f98d4508d2f624516ce5251ad6b74180a5b2133273f34c2f6
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2024 andersmarkc
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # ActiveConnect
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+
8
+ # Guide ME
9
+ RAILS_ENV=test rails generate active_connect:install
10
+
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem "active_connect"
16
+ ```
17
+
18
+ And then execute:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+ ```bash
25
+ $ gem install active_connect
26
+ ```
27
+
28
+ ## Contributing
29
+ Contribution directions go here.
30
+
31
+ ## License
32
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/active_connect .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module ActiveConnect
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveConnect
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveConnect
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module ActiveConnect
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveConnect
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Active connect</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "active_connect/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Path: config/routes.rb
3
+
4
+ ActiveConnect::Engine.routes.draw do
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # Path: lib/active_connect/engine.rb
3
+
4
+ module ActiveConnect
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace ActiveConnect
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # Path: lib/active_connect/version.rb
3
+
4
+ module ActiveConnect
5
+ VERSION = "0.1.0"
6
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ # Path: lib/active_connect.rb
3
+
4
+ require "active_connect/version"
5
+ require "active_connect/engine"
6
+
7
+ module ActiveConnect
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ # lib/generators/active_connect/install_generator.rb
3
+
4
+ module ActiveConnect
5
+ class InstallGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ # Implement the required interface for Rails::Generators::Migration.
11
+ def self.next_migration_number(dirname)
12
+ if @migration_number
13
+ @migration_number += 1
14
+ else
15
+ @migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
16
+ end
17
+ @migration_number.to_s
18
+ end
19
+
20
+ def copy_scrape_yml
21
+ template "connect.yml", "config/connect.yml"
22
+ end
23
+
24
+ def copy_migrations
25
+ migration_template "create_active_connect_data.rb", "db/migrate/create_active_connect_data.rb"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,50 @@
1
+ # lib/generators/active_connect/templates/connect.yml
2
+
3
+ default: &default
4
+ request_timeout: 10
5
+ request_retries: 3
6
+ request_delay: 1
7
+
8
+
9
+ http_party:
10
+ <<: *default
11
+ engine: "httparty"
12
+ proxy: "http://your-proxy-server:port:username:password"
13
+ request_headers:
14
+ user_agent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36"
15
+ request_type: "get"
16
+
17
+ selenium_chrome:
18
+ <<: *default
19
+ engine: "selenium_chrome"
20
+ proxy: "http://your-proxy-server:port"
21
+ request_headers:
22
+ user_agent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36"
23
+
24
+ selenium_firefox:
25
+ <<: *default
26
+ engine: "selenium_firefox"
27
+ proxy: "http://your-proxy-server:port"
28
+ request_headers:
29
+ user_agent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36"
30
+
31
+ apparition:
32
+ <<: *default
33
+ engine: "apparition"
34
+ proxy: "http://your-proxy-server:port"
35
+ request_headers:
36
+ user_agent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36"
37
+
38
+ cuprite:
39
+ <<: *default
40
+ engine: "cuprite"
41
+ proxy: "http://your-proxy-server:port"
42
+ request_headers:
43
+ user_agent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36"
44
+
45
+ mechanize:
46
+ <<: *default
47
+ engine: "mechanize"
48
+ proxy: "http://your-proxy-server:port:username:password"
49
+ request_headers:
50
+ user_agent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36"
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ # lib/generators/active_connect/templates/create_active_connect_data.rb
3
+ #
4
+ class CreateScrapeData < ActiveRecord::Migration[7.0]
5
+ def change
6
+ create_table :active_connect_data do |t|
7
+ t.references :connectable, polymorphic: true, index: true
8
+ t.json :data
9
+ t.datetime :run_at
10
+ t.integer :status
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ # Path: lib/tasks/active_connect_tasks.rake
3
+
4
+ require "active_connect/version"
5
+ require "active_connect/engine"
6
+
7
+ module ActiveConnect
8
+ extend ActiveSupport::Concern
9
+
10
+ class_methods do
11
+ def has_connect(connect_name)
12
+ # Define scraping settings or initializations here
13
+ # You can store configurations in scrape.yml
14
+ end
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_connect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - andersmarkc
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 7.0.6
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 7.0.6
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.0'
33
+ description: ActiveConnect provides an easy-to-use scraping framework for Rails applications,
34
+ allowing models to declare 'has_connect' associations to fetch and store scraped
35
+ data. Compatible with Rails 7 and higher.
36
+ email:
37
+ - andersmarkc@gmail.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - MIT-LICENSE
43
+ - README.md
44
+ - Rakefile
45
+ - app/assets/config/active_connect_manifest.js
46
+ - app/assets/stylesheets/active_connect/application.css
47
+ - app/controllers/active_connect/application_controller.rb
48
+ - app/helpers/active_connect/application_helper.rb
49
+ - app/jobs/active_connect/application_job.rb
50
+ - app/mailers/active_connect/application_mailer.rb
51
+ - app/models/active_connect/application_record.rb
52
+ - app/views/layouts/active_connect/application.html.erb
53
+ - config/routes.rb
54
+ - lib/active_connect.rb
55
+ - lib/active_connect/engine.rb
56
+ - lib/active_connect/version.rb
57
+ - lib/generators/active_scrape/install_generator.rb
58
+ - lib/generators/active_scrape/templates/connect.yml
59
+ - lib/generators/active_scrape/templates/create_active_connect_data.rb
60
+ - lib/tasks/active_connect_tasks.rake
61
+ homepage: https://github.com/andersmarkc/active_connect
62
+ licenses:
63
+ - MIT
64
+ metadata:
65
+ homepage_uri: https://github.com/andersmarkc/active_connect
66
+ source_code_uri: https://github.com/andersmarkc/active_connect
67
+ changelog_uri: https://github.com/andersmarkc/active_connect/blob/main/CHANGELOG.md
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubygems_version: 3.1.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: A scraping utility for Rails applications, designed to work similarly to
87
+ ActiveStorage.
88
+ test_files: []