google_analytics_grabber 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7a284ded04afecf38baa9ed07bafb76b916cc9c075ab845755de671dc32a7d9e
4
+ data.tar.gz: 30e1ddd4c9ca8d3f8cc18b8c05b5965a37962cb64542d394a1da7b57b3d31cfb
5
+ SHA512:
6
+ metadata.gz: bc1321dd6083cec732c4210db465791b98b0ad33c5bca00742d4eda3a3d69978d49fe0bb80376ef44d341ef956f8bcb496d6dd80abe05fa95e81c01bf3509811
7
+ data.tar.gz: cefd420b2722454d11348457f297743ff5845d91db45fa43dac966459ca8bf8058ecc668f4692810c4969839017084f140ee72d9b78ae69cf879a47daa5ed6ff
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # GoogleAnalyticsGrabber
2
+ Grab the Google analytics from any sites that has one. It uses regexs to match the source code of the
3
+ site. If I find new ones I will keep adding them as needed.
4
+
5
+
6
+ ## Installation
7
+
8
+ If bundler is not being used to manage dependencies, install the gem by executing:
9
+
10
+ ```bash
11
+ gem install google_analytics_grabber
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ruby
17
+ require_relative "lib/google_analytics_grabber"
18
+
19
+ ga = GoogleAnalyticsGrabber::GA.new
20
+
21
+ ga.url = "g-form.com"
22
+ puts "RETURN THE GA: "
23
+ puts ga.extract(return_ga: true)
24
+
25
+
26
+ puts "PRINT THE GA: "
27
+ ga.extract
28
+
29
+ ```
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/google_analytics_grabber.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoogleAnalyticsGrabber
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ require 'net/http'
3
+ require 'uri'
4
+ require_relative "google_analytics_grabber/version"
5
+
6
+ module GoogleAnalyticsGrabber
7
+ class GA
8
+ attr_accessor :url
9
+ def url=(c)
10
+ @url = c
11
+ end
12
+ def extract(return_ga: false)
13
+ unless @url.match?("https://")
14
+ @url = "https://#{@url}"
15
+ end
16
+ uri = URI(@url)
17
+ r = Net::HTTP.get_response(uri).body
18
+ ga = ""
19
+ case r
20
+ when /UA-\d{8}-\d/
21
+ ga += r.match(/UA-\d{8}-\d/).to_s
22
+ when /GTM-[A-Z0-9]{7}/
23
+ ga += r.match(/GTM-[A-Z0-9]{7}/).to_s
24
+ when /G-([0-9]+([A-Za-z]+[0-9]+)+)/
25
+ ga += r.match(/G-([0-9]+([A-Za-z]+[0-9]+)+)/).to_s
26
+ when /G-[A-Za-z0-9]+/
27
+ ga += r.match(/G-[A-Za-z0-9]+/).to_s
28
+ when /GT-[A-Za-z0-9]+/
29
+ ga += r.match(/GT-[A-Za-z0-9]+/)
30
+ else
31
+ ga += '[+] No Google Analytics found :('
32
+ end
33
+ unless return_ga
34
+ puts ga
35
+ else
36
+ return ga
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,4 @@
1
+ module GoogleAnalyticsGrabber
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google_analytics_grabber
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael-Meade
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-11-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Extracts Google analytics from sites.
14
+ email:
15
+ - noway@lol.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - Rakefile
22
+ - lib/google_analytics_grabber.rb
23
+ - lib/google_analytics_grabber/version.rb
24
+ - sig/google_analytics_grabber.rbs
25
+ homepage:
26
+ licenses: []
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.4.20
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Extract Google analytics from sites.
47
+ test_files: []