apt-kusa 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/lib/apt/kusa/cli.rb +19 -5
- data/lib/apt/kusa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '049f2c9a40941cd91d9b46cbc957f52b14d2e5638b2b91bf18c40a7c188e639e'
|
4
|
+
data.tar.gz: 27f281ad6cd332bc409ccf3323630debe74493286b1d84b26e3e1e3d9805ba3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74a47a52aa90e2b727c7bc039c3dc2414e86fdaee473b824e12eb96d5378b528c4ea8aecb369c5091fff5f1d5db39c8911aea5f9cbc3eb88f8d47850e7df2151
|
7
|
+
data.tar.gz: 459cf088edfd3f629e91ec2398535f83ca3118f226c8f086bf356e7c5036ef9df2609b8519f102c6cdd478c138966f7ea4a23211e967ef97c44be55ef7df1949
|
data/README.md
CHANGED
@@ -3,8 +3,17 @@ Send apt command activity to https://pxe.la
|
|
3
3
|
|
4
4
|
## Usage
|
5
5
|
|
6
|
+
|
6
7
|
```
|
7
|
-
$ export
|
8
|
-
$ export
|
9
|
-
|
8
|
+
$ export PIXELA_USER_NAME=<your pixe.la account>
|
9
|
+
$ export PIXELA_USER_TOKEN=<your pixe.la token>
|
10
|
+
|
11
|
+
or
|
12
|
+
|
13
|
+
$ cat ~/.apt-kusa
|
14
|
+
username: <your pixe.la account>
|
15
|
+
token: <your pixe.la token>
|
16
|
+
|
17
|
+
|
18
|
+
$ apt-kusa post --all --graph <your pixe.la graph_id
|
10
19
|
```
|
data/lib/apt/kusa/cli.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'thor'
|
2
|
+
require 'yaml'
|
2
3
|
require 'zlib'
|
3
4
|
require 'pixela'
|
4
5
|
require 'apt/history'
|
5
6
|
|
6
7
|
module Apt::Kusa
|
7
8
|
class CLI < Thor
|
9
|
+
class_option :config, type: :string, default: File.join(Dir.home, ".apt-kusa")
|
10
|
+
|
8
11
|
option :all, type: :boolean, default: false
|
9
12
|
desc "summary", "Summarize history.log"
|
10
13
|
def summary
|
@@ -16,24 +19,31 @@ module Apt::Kusa
|
|
16
19
|
|
17
20
|
option :all, type: :boolean, default: false
|
18
21
|
option :graph, type: :string, required: true
|
22
|
+
option :create,type: :boolean, default: false
|
19
23
|
desc "post", "Post to pixe.la"
|
20
24
|
def post
|
21
|
-
|
22
|
-
|
25
|
+
config = load_config
|
26
|
+
|
27
|
+
unless username = ENV["PIXELA_USER_NAME"] || config['username']
|
28
|
+
puts "Please set your username."
|
23
29
|
exit
|
24
30
|
end
|
25
|
-
unless token = ENV["
|
26
|
-
puts "Please set your
|
31
|
+
unless token = ENV["PIXELA_USER_TOKEN"] || config['token']
|
32
|
+
puts "Please set your API token"
|
27
33
|
exit
|
28
34
|
end
|
29
35
|
|
30
36
|
summary = parse_and_summarize
|
31
37
|
|
32
38
|
client = Pixela::Client.new(username: username, token: token)
|
39
|
+
graph = client.graph(options[:graph])
|
40
|
+
if options[:create]
|
41
|
+
graph.create(name:"Count of package install/upgrade", unit:"commit", type:"int", color:"shibafu")
|
42
|
+
end
|
33
43
|
|
34
44
|
summary.each do |date, count|
|
35
45
|
q = count.to_a.select{|h| [:install,:upgrade].include?(h[0])}.inject(0) {|s,h| s+=h[1]}
|
36
|
-
|
46
|
+
graph.pixel(Date.parse(date)).update(quantity: q)
|
37
47
|
end
|
38
48
|
end
|
39
49
|
|
@@ -43,6 +53,10 @@ module Apt::Kusa
|
|
43
53
|
end
|
44
54
|
|
45
55
|
no_commands do
|
56
|
+
def load_config(path=options[:config])
|
57
|
+
YAML.load_file(path)
|
58
|
+
end
|
59
|
+
|
46
60
|
def parse_and_summarize
|
47
61
|
summarize(parse(Apt::History::FILEPATH, options[:all]))
|
48
62
|
end
|
data/lib/apt/kusa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apt-kusa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Koya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|