pod_ident 1.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
+ SHA256:
3
+ metadata.gz: 13df0ae00878072c9d526babf494bd2f3b9d6f919ae64b6d7df79345e90de260
4
+ data.tar.gz: 6f6c4af09bf690f379962561d9aca88d17635492a8e31928ba62c19362011900
5
+ SHA512:
6
+ metadata.gz: 49145c7f5dc4304fa270472ec19c422011625922732f6742730fe3830c532d64de7cee44dbac794c8bfea638fe2a9d1f95e114516886cdd484001f398b8b281c
7
+ data.tar.gz: 94d1a1b3e7786d7d00bd6b929f4e9e7bd76acb41edd0f451c5677c70b21fd90ffd3bb7f7dd11f5f017705a4a07fcecc0062a86cf099281080a4bf1fc7ccc2157
@@ -0,0 +1,52 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.6.0
11
+
12
+ working_directory: ~/repo
13
+
14
+ steps:
15
+ - checkout
16
+
17
+ # Download and cache dependencies
18
+ - restore_cache:
19
+ keys:
20
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
21
+ # fallback to using the latest cache if no exact match is found
22
+ - v1-dependencies-
23
+
24
+ - run:
25
+ name: install dependencies
26
+ command: |
27
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
28
+
29
+ - save_cache:
30
+ paths:
31
+ - ./vendor/bundle
32
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
33
+
34
+ # run tests!
35
+ - run:
36
+ name: run tests
37
+ command: |
38
+ mkdir /tmp/test-results
39
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
40
+
41
+ bundle exec rspec --format progress \
42
+ --format RspecJunitFormatter \
43
+ --out /tmp/test-results/rspec.xml \
44
+ --format progress \
45
+ $TEST_FILES
46
+
47
+ # collect reports
48
+ - store_test_results:
49
+ path: /tmp/test-results
50
+ - store_artifacts:
51
+ path: /tmp/test-results
52
+ destination: test-results
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ Exclude:
4
+ - 'db/schema.rb'
5
+ - 'Gemfile'
6
+ Style/Documentation:
7
+ Enabled: false
8
+ Style/StructInheritance:
9
+ Enabled: false
10
+ Metrics/LineLength:
11
+ Max: 100
12
+ Metrics/MethodLength:
13
+ Max: 15
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - 'Rakefile'
17
+ - '**/*.rake'
18
+ - 'spec/**/*.rb'
19
+ Lint/UnneededCopDisableDirective:
20
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.5
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in pod_ident.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pod_ident (1.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ method_source (0.9.2)
12
+ pry (0.12.2)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.9.0)
15
+ rake (13.0.1)
16
+ rspec (3.8.0)
17
+ rspec-core (~> 3.8.0)
18
+ rspec-expectations (~> 3.8.0)
19
+ rspec-mocks (~> 3.8.0)
20
+ rspec-core (3.8.0)
21
+ rspec-support (~> 3.8.0)
22
+ rspec-expectations (3.8.2)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-mocks (3.8.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-support (3.8.0)
29
+ rspec_junit_formatter (0.4.1)
30
+ rspec-core (>= 2, < 4, != 2.12.0)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.16)
37
+ pod_ident!
38
+ pry
39
+ rake (~> 13.0)
40
+ rspec (~> 3.0)
41
+ rspec_junit_formatter
42
+
43
+ BUNDLED WITH
44
+ 1.17.3
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # PodIdent - Podcast Client Detector without the clutter
2
+
3
+ ## Rationale
4
+
5
+ ### Focus
6
+
7
+ There are plenty of libraries that can parse and detect user agents in a generic way.
8
+
9
+ `PodIdent` takes a different approach here: it puts a lot of effort into getting the most used Podcast clients right, leaving the job of detecting browsers and more obscure
10
+ devices to generic user agent detecting libraries.
11
+
12
+ ### Simplicity
13
+
14
+ Version numbers might be interesting for some use cases, but are not relevant at all to podcasters - podcasters want to know where their listeners are, and what platforms / clients work the best.
15
+
16
+ There is a great deal of confusion about what is a device, an operating system or a platform in general. To keep things simple, `PodIdent` uses `platform` as a generic term to describe the place where software runs. It can be an iPhone (device), iOS (operating system) or even just an "Apple device" (category).
17
+
18
+ `PodIdent` has no production dependencies. Keep it simple, and all that.
19
+
20
+ ### Preciseness
21
+
22
+ User agents are known to be confusing and difficult to understand. Most vendors don't document their user agents explicitly, and most of the detection rules are created by trying and collecting information from other sources.
23
+
24
+ This is why `PodIdent` tries to be always as precise as possible (if it knows that a client runs on an iPad, it will return `platform: 'iPad'`, instead of a generic `iOS`.
25
+
26
+ ### Performance, memory usage
27
+
28
+ The detection rules always try to match substrings first, before using full-fledged regular expressions. This should make detection a lot faster. Also, since there are not even 100 podcast clients out there, there is no need to support a billion different browsers and devices.
29
+
30
+ ## Installation
31
+
32
+ Add this line to your application's Gemfile:
33
+
34
+ ```ruby
35
+ gem 'pod_ident'
36
+ ```
37
+
38
+ And then execute:
39
+
40
+ $ bundle
41
+
42
+ Or install it yourself as:
43
+
44
+ $ gem install pod_ident
45
+
46
+ ## Usage
47
+
48
+ ```ruby
49
+ require 'pod_ident'
50
+
51
+ user_agent = 'AppleCoreMedia/1.0.0.10B500 (iPod; U; CPU OS 6_1_6 like Mac OS X; en_gb)'
52
+ result = PodIdent.detect(user_agent)
53
+
54
+ puts result.app
55
+ => 'Apple Podcasts'
56
+ puts result.platform
57
+ => 'iPod'
58
+ ```
59
+
60
+ ## Development
61
+
62
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
63
+
64
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
65
+
66
+ The detection rules are found as a yaml file under `lib/detection_rules.yml`.
67
+
68
+ Please, only edit this file, and afterwards run `bin/parse-rules` in order to generate both the detection rules as a `rb` file for production usage, and the complete rules with their corresponding test cases for testing.
69
+
70
+ ## Contributing
71
+
72
+ Bug reports and pull requests are welcome on GitHub at https://github.com/podigee/pod_ident.rb.
73
+
74
+ ## Future implementations
75
+
76
+ It would be nice to have the following features in future versions:
77
+
78
+ - bot & crawler detection (instead of having to use a generic user agent parser)
79
+ - adding custom detection rules (this can be achieved today by pushing rules into the rules array, but there should be a better way)
80
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pod_ident"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "pry"
14
+ Pry.start
data/bin/parse-rules ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'pod_ident/rule_parser'
6
+
7
+ parser = PodIdent::RuleParser.new
8
+ parser.call
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here