amiblocked 0.0.1

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
+ SHA1:
3
+ metadata.gz: b08fa5f1a980d8028d7fe383791647cac67f595b
4
+ data.tar.gz: 13f181948d43e2963a80b4d82ec4b2c2ee8af739
5
+ SHA512:
6
+ metadata.gz: b95421f68ebd482d5cb578a243c648c33a6557ad907574ce08b4503a3f105f2b4b3dd552c369e56c627cb0b750a6b5b37a999f1ee7ad00bd95413821d256e619
7
+ data.tar.gz: d35b82f113dfebb8c2489cdd155d24b8e946d127b438c55998da88c7fdcb394536c74402cdbb77d5bd14994a5f18f53213e05671372fb460f98d25e6542b9f6e
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gem 'notifaction'
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # gem::amiblocked
2
+
3
+ Checks to see if your service is on any of the lists on the [easylist](https://easylist.adblockplus.org/en/).
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ ruby tester.rb service_name
9
+
10
+ # Examples
11
+ # ruby tester.rb google
12
+ # ruby tester.rb doubleclick
13
+ ```
@@ -0,0 +1,15 @@
1
+ require "./lib/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'amiblocked'
5
+ s.version = AmIBlocked::VERSION
6
+ s.date = Date.today
7
+ s.summary = "Simple Adblock list testing"
8
+ s.description = "Check if your service blocked by adblockers"
9
+ s.authors = ["Ryan Priebe"]
10
+ s.email = 'hello@ryanpriebe.com'
11
+ s.files = `git ls-files`.split($\)
12
+ s.homepage = 'http://rubygems.org/gems/amiblocked'
13
+ s.license = 'MIT'
14
+ s.executables = 'amiblocked'
15
+ end
data/bin/amiblocked ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json'
4
+ require 'open-uri'
5
+ require 'notifaction'
6
+
7
+ require_relative '../lib/amiblocked'
8
+
9
+ # default configuration options
10
+ config = {
11
+ url: "https://easylist.adblockplus.org/en/",
12
+ service: ARGV[0]
13
+ }
14
+
15
+ # use local configuration options if they exist
16
+ local_config = File.expand_path('~') + '.amiblocked-config.json'
17
+
18
+ if File.exists?(local_config)
19
+ config = JSON.parse(local_config)
20
+ end
21
+
22
+ AmIBlocked.new(config)
data/lib/amiblocked.rb ADDED
@@ -0,0 +1,62 @@
1
+ class AmIBlocked
2
+ def initialize(config = {})
3
+ Notify.error("A URL is required") if config[:url].nil?
4
+ Notify.error("A service name is required, e.g.\namiblocked doubleclick") if config[:service].nil?
5
+
6
+ @url = config[:url]
7
+
8
+ execute_and_report(config)
9
+ end
10
+
11
+ private
12
+
13
+ def get_lists
14
+ lists = []
15
+
16
+ open(@url) do |res|
17
+ res.each_line do |line|
18
+ # grossness to follow
19
+ if list = /http(s):\/\/(.*)\.txt/.match(line)
20
+ if !@list.to_s.index('&')
21
+ lists.push list.to_s
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ lists.uniq
28
+ end
29
+
30
+ def parse_lists(lists)
31
+ matched_lists = []
32
+
33
+ lists.each do |list|
34
+ begin
35
+ open(list) do |res|
36
+ res.each_line do |line|
37
+ if /#{ARGV[0]}/.match(line)
38
+ matched_lists.push list
39
+ end
40
+ end
41
+ end
42
+ rescue
43
+ # do nothing for lists that can't be opened
44
+ end
45
+ end
46
+
47
+ matched_lists.uniq
48
+ end
49
+
50
+ def execute_and_report(config)
51
+ Notify.info("Checking if #{config[:service]} is on any adblock lists\nThis may take a few minutes...")
52
+
53
+ matched_lists = parse_lists(get_lists)
54
+
55
+ if matched_lists.size > 0
56
+ Notify.warning("Found #{config[:service]} on #{matched_lists.size} lists")
57
+ Notify.warning(matched_lists.join("\n"))
58
+ else
59
+ Notify.success("#{config[:service].capitalize} was not found on any lists, rejoice!")
60
+ end
61
+ end
62
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module AmIBlocked
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amiblocked
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Priebe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Check if your service blocked by adblockers
14
+ email: hello@ryanpriebe.com
15
+ executables:
16
+ - amiblocked
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - README.md
22
+ - amiblocked.gemspec
23
+ - bin/amiblocked
24
+ - lib/amiblocked.rb
25
+ - lib/version.rb
26
+ homepage: http://rubygems.org/gems/amiblocked
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.0.14
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Simple Adblock list testing
50
+ test_files: []