Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Installation
The recommended way to install device detector

```
go get github.com/gamebtc/devicedetector
go get -u github.com/slipros/devicedetector
```

Examples
Expand All @@ -25,7 +25,7 @@ import (
"fmt"
"log"

. "github.com/gamebtc/devicedetector"
. "github.com/slipros/devicedetector"
)

func main() {
Expand Down Expand Up @@ -65,26 +65,6 @@ func main() {
}
```

## Tests

go test

### Running tests

```
cd devicedetector
go test

cd devicedetector/parser
go test

cd devicedetector/parser/client
go test

cd devicedetector/parser/device
go test
```

## Device Detector for other languages

There are already a few ports of this tool to other languages:
Expand All @@ -96,7 +76,6 @@ There are already a few ports of this tool to other languages:
- **Crystal** https://github.com/creadone/device_detector
- **Elixir** https://github.com/elixir-inspector/ua_inspector
- **Java** https://github.com/mngsk/device-detector
- **Go** https://github.com/gamebtc/devicedetector

## What Device Detector is able to detect

Expand Down
6 changes: 3 additions & 3 deletions device_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
regexp "github.com/dlclark/regexp2"
gover "github.com/mcuadros/go-version"

. "github.com/gamebtc/devicedetector/parser"
"github.com/gamebtc/devicedetector/parser/client"
"github.com/gamebtc/devicedetector/parser/device"
. "github.com/slipros/devicedetector/parser"
"github.com/slipros/devicedetector/parser/client"
"github.com/slipros/devicedetector/parser/device"
)

const UNKNOWN = "UNK"
Expand Down
12 changes: 6 additions & 6 deletions device_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package devicedetector
import (
regexp "github.com/dlclark/regexp2"

. "github.com/gamebtc/devicedetector/parser"
"github.com/gamebtc/devicedetector/parser/client"
"github.com/gamebtc/devicedetector/parser/device"
. "github.com/slipros/devicedetector/parser"
"github.com/slipros/devicedetector/parser/client"
"github.com/slipros/devicedetector/parser/device"
)

var (
Expand All @@ -17,9 +17,9 @@ var (
type DeviceInfo struct {
userAgent string
device.DeviceMatchResult
client *client.ClientMatchResult
os *OsMatchResult
bot *BotMatchResult
client *client.ClientMatchResult
os *OsMatchResult
bot *BotMatchResult
}

func (d *DeviceInfo) GetDeviceType() int {
Expand Down
8 changes: 4 additions & 4 deletions device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"gotest.tools/assert"

regexp "github.com/dlclark/regexp2"
. "github.com/gamebtc/devicedetector/parser"
"github.com/gamebtc/devicedetector/parser/client"
"github.com/gamebtc/devicedetector/parser/device"
. "github.com/slipros/devicedetector/parser"
"github.com/slipros/devicedetector/parser/client"
"github.com/slipros/devicedetector/parser/device"
)

var dd, _ = NewDeviceDetector("regexes")
Expand Down Expand Up @@ -205,4 +205,4 @@ func TestRegThread(t *testing.T) {
}
}
wg.Wait()
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/gamebtc/devicedetector
module github.com/slipros/devicedetector

go 1.13

Expand Down
2 changes: 1 addition & 1 deletion parser/client/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

gover "github.com/mcuadros/go-version"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
)

// Known browsers mapped to their internal short codes
Expand Down
2 changes: 1 addition & 1 deletion parser/client/browser_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"path/filepath"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
)

// Known browser engines mapped to their internal short codes
Expand Down
4 changes: 2 additions & 2 deletions parser/client/browser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

Expand All @@ -21,4 +21,4 @@ func TestBrowserParse(t *testing.T) {
r := ps.Parse(ua)
assert.DeepEqual(t, item.ClientMatchResult, r)
}
}
}
2 changes: 1 addition & 1 deletion parser/client/client_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sort"
"strings"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
)

type ClientMatchResult struct {
Expand Down
4 changes: 2 additions & 2 deletions parser/client/feed_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

Expand All @@ -21,4 +21,4 @@ func TestFeedReaderParse(t *testing.T) {
r := ps.Parse(ua)
assert.DeepEqual(t, item.ClientMatchResult, r)
}
}
}
4 changes: 2 additions & 2 deletions parser/client/library_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

func TestLibraryParse(t *testing.T) {
var ps= NewLibrary(filepath.Join(dir, FixtureFileLibrary))
var ps = NewLibrary(filepath.Join(dir, FixtureFileLibrary))
var list []*ClientFixture
err := ReadYamlFile(`fixtures/library.yml`, &list)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion parser/client/media_player_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion parser/client/mobile_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion parser/client/pim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions parser/device/camera_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

Expand Down Expand Up @@ -35,4 +35,4 @@ func TestCameraParse(t *testing.T) {
test := item.GetDeviceMatchResult()
assert.DeepEqual(t, test, r)
}
}
}
2 changes: 1 addition & 1 deletion parser/device/car_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

Expand Down
3 changes: 1 addition & 2 deletions parser/device/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
"gotest.tools/assert"
)

Expand All @@ -23,4 +23,3 @@ func TestConsoleParse(t *testing.T) {
assert.DeepEqual(t, test, r)
}
}

4 changes: 2 additions & 2 deletions parser/device/device_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sort"
"strings"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
)

const UnknownBrand = "Unknown"
Expand Down Expand Up @@ -125,4 +125,4 @@ func (d *DeviceParserAbstract) Parse(ua string) *DeviceMatchResult {
}
}
return r
}
}
10 changes: 5 additions & 5 deletions parser/device/device_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package device

import(
. "github.com/gamebtc/devicedetector/parser"
import (
. "github.com/slipros/devicedetector/parser"
)

const dir = "../../regexes/device"

type DeviceFixtureResult struct {
Type int `yaml:"type"`
Type int `yaml:"type"`
Model string `yaml:"model"`
Brand string `yaml:"brand"`
}
Expand All @@ -17,10 +17,10 @@ type DeviceFixture struct {
DeviceFixtureResult `yaml:"device"`
}

func (d *DeviceFixture)GetDeviceMatchResult()*DeviceMatchResult {
func (d *DeviceFixture) GetDeviceMatchResult() *DeviceMatchResult {
return &DeviceMatchResult{
Model: d.Model,
Brand: d.Brand,
Type: GetDeviceName(d.Type),
}
}
}
2 changes: 1 addition & 1 deletion parser/device/hbbtv.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package device
import (
"path/filepath"

. "github.com/gamebtc/devicedetector/parser"
. "github.com/slipros/devicedetector/parser"
)

const ParserNameHbbTv = `tv`
Expand Down