apt-kusa 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8d7b36cd58b3a010434e5a3938613d1f9a1c599b9621c0aae0b2ebe5998fc11
4
- data.tar.gz: 67e20d87db89b0cfc352b6a48448189cc80aeeb01be2dac2541ce0d99a4be445
3
+ metadata.gz: '049f2c9a40941cd91d9b46cbc957f52b14d2e5638b2b91bf18c40a7c188e639e'
4
+ data.tar.gz: 27f281ad6cd332bc409ccf3323630debe74493286b1d84b26e3e1e3d9805ba3b
5
5
  SHA512:
6
- metadata.gz: 5a2f03be1220acee3d69d86d686c32834e6c6b9bbd6f7ddac32e6a67915ac15511c4d38f3ade6700b36641257f8f59067367ea13b2919bd3b1ed1f20c848abf6
7
- data.tar.gz: be1dd96943ad9accc37e5e621313a609159631b5f381c28a51462da5b238b6ecbd434165d5c74106842f46e80de0408a1f48165eea263b045efbe319433c2303
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 PIXELA_USER=<your pixe.la account>
8
- $ export PIXELA_TOKEN=<your pixe.la token>
9
- $ apt-kusa post --all --graph <your pixe.la graph_id>
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
- unless username = ENV["PIXELA_USER"]
22
- puts "Please set your $PIXELA_TOKEN"
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["PIXELA_TOKEN"]
26
- puts "Please set your $PIXELA_TOKEN"
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
- client.graph(options[:graph]).pixel(Date.parse(date)).update(quantity: q)
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
@@ -1,5 +1,5 @@
1
1
  module Apt
2
2
  module Kusa
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
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.0
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-05 00:00:00.000000000 Z
11
+ date: 2019-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor