Skip to content

Remove class methods#4

Closed
jnunemaker wants to merge 12 commits intomasterfrom
remove-class-methods
Closed

Remove class methods#4
jnunemaker wants to merge 12 commits intomasterfrom
remove-class-methods

Conversation

@jnunemaker
Copy link
Contributor

In master, the parser class is responsible for reading a path from disk, parsing it from yaml to ruby, converting all of the patterns into actual ruby regexes, and then finally matching those regexes/patterns to return browser family/version, operating system family/version, and device.

In this branch, the parser is responsible only for matching patterns. I used a file pattern loader which handles the read file, yaml parse, regex conversion and responds to call. The parser then takes an instance of anything that responds to call and returns a hash of patterns/regexes.

  • It removes the need for any class level methods.
  • Each parser instance defaults to a file pattern loader with the vendored ua-parser regexes path.

I added examples for basic usage and custom pattern loader usage. Also updated all readme and such. Should be good to go.

@toolmantim
Copy link
Contributor

Closing this for now in favour of #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants