info: show Linux formulae details and analytics

- This makes use of the new /api/formula-linux and /api/analytics-linux
  endpoints in formulae.brew.sh to give Linux users up to date formula and
  analytics info for their installed core formulae.

Before, on Linux, the macOS stats for the `ack` formula:

```
$ brew info ack
[...]
==> Analytics
install: 12,422 (30 days), 32,742 (90 days), 97,788 (365 days)
install_on_request: 10,778 (30 days), 28,339 (90 days), 85,202 (365 days)
build_error: 0 (30 days)
```

Now, on Linux, the Linux stats for the `ack` formula:

```
$ brew info ack
[...]
==> Analytics
install: 95 (30 days), 242 (90 days), 737 (365 days)
install_on_request: 94 (30 days), 241 (90 days), 734 (365 days)
build_error: 0 (30 days)
```
This commit is contained in:
Issy Long 2019-10-23 21:24:08 +01:00 committed by Mike McQuaid
parent 28635a7fe4
commit 727f9671c7
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
3 changed files with 33 additions and 1 deletions

View File

@ -368,7 +368,7 @@ module Homebrew
end
def output_formula_analytics(f)
json = formulae_api_json("formula/#{f}.json")
json = formulae_api_json("#{formula_path}/#{f}.json")
return if json.blank? || json["analytics"].blank?
full_analytics = args.analytics? || args.verbose?
@ -431,4 +431,16 @@ module Homebrew
def format_percent(percent)
format("%<percent>.2f", percent: percent)
end
def formula_path
"formula"
end
alias_method :generic_formula_path, :formula_path
def analytics_path
"analytics"
end
alias_method :generic_analytics_path, :analytics_path
require "extend/os/cmd/info"
end

View File

@ -0,0 +1,3 @@
# frozen_string_literal: true
require "extend/os/linux/info" if OS.linux?

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
module Homebrew
module_function
def formula_path
return generic_formula_path if ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"]
"formula-linux"
end
def analytics_path
return generic_analytics_path if ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"]
"analytics-linux"
end
end