gpr 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95117424561ceb8c9d644bc5e205aa19839d016e
4
- data.tar.gz: ed65b1a5812176da694c3bd9b8c09f2e607c5621
3
+ metadata.gz: 09a37952ff672aa804dd9ed53da451b70f8de187
4
+ data.tar.gz: 2e78a77ee446ae0790f8919039edc87bc7040a99
5
5
  SHA512:
6
- metadata.gz: 297f2d0dba68cef4fa1ff32ab7375e106cc4af93e2251fcc72e4d9a51c69dc310abf5706d77712d09d0d9ab4978afb70c751f83c8e9aa1a50bf234c78900f1ba
7
- data.tar.gz: 4d814901a9a4bf82c63231557351810e73b14b3227d85365464ce6fcb3ebc4fc7af9bb48f8d87b0c54c5acc9e6426db7c44d0385d74c2942a87e766f5ffa59d4
6
+ metadata.gz: 4c90b35c596c6def17b6e917eb7b09ff0beaafdb539ce7b331772132260a0f6d15ff584671ee7ddea5de497ed733a35e36de1d2f9a70f52add6095f09558b685
7
+ data.tar.gz: 1739611ba31101e707b1c07ba8ced63b8fc8b55ea5d9e39e29e62ad55337b34ad6cf96483358e496ae5c3c20221f7e7f9d3a78a665682d8aa8b48d55127eba26
data/gpr.gemspec CHANGED
@@ -18,12 +18,10 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.add_dependency 'thor'
20
20
  spec.add_dependency 'rroonga'
21
- spec.add_dependency 'curses'
22
21
  spec.add_dependency 'safe_colorize'
23
22
  spec.add_dependency 'ifilter'
23
+ spec.add_dependency 'utils_drawer'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.6'
26
26
  spec.add_development_dependency 'rake'
27
- spec.add_development_dependency 'pry'
28
- spec.add_development_dependency 'awesome_print'
29
27
  end
data/lib/gpr/cli.rb CHANGED
@@ -2,15 +2,12 @@ require 'thor'
2
2
  require 'groonga'
3
3
  require 'safe_colorize'
4
4
  require 'ifilter'
5
-
6
- require 'table_builder'
7
- require 'graph_drawer'
5
+ require 'utils_drawer'
8
6
 
9
7
  module Gpr
10
8
  class CLI < Thor
11
9
  using SafeColorize
12
- include TableBuilder
13
- include GraphDrawer
10
+ include UtilsDrawer
14
11
 
15
12
  desc 'get', 'Get a repository'
16
13
  def get(param)
data/lib/gpr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gpr
2
- VERSION = '0.0.6'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaihar4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: curses
42
+ name: safe_colorize
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: safe_colorize
56
+ name: ifilter
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: ifilter
70
+ name: utils_drawer
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -108,34 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: pry
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: awesome_print
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
111
  description: Gitkeeper.
140
112
  email:
141
113
  - kaihar4@gmail.com
@@ -156,14 +128,6 @@ files:
156
128
  - lib/gpr/cli.rb
157
129
  - lib/gpr/git_helper.rb
158
130
  - lib/gpr/version.rb
159
- - lib/graph_drawer.rb
160
- - lib/graph_drawer/data.rb
161
- - lib/graph_drawer/graph.rb
162
- - lib/table_builder.rb
163
- - lib/table_builder/column.rb
164
- - lib/table_builder/column_validator.rb
165
- - lib/table_builder/row.rb
166
- - lib/table_builder/table.rb
167
131
  - zsh/gpr.zsh
168
132
  homepage: https://github.com/kaihar4/gpr
169
133
  licenses:
data/lib/graph_drawer.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'graph_drawer/graph.rb'
2
- require 'graph_drawer/data.rb'
3
-
4
- module GraphDrawer
5
- def graph
6
- @graph = Graph.new
7
- yield
8
- @graph.datas_init
9
- @graph.to_s
10
- end
11
-
12
- def data(item, value)
13
- @data = Data.new(item, value)
14
- @graph.add(@data)
15
- end
16
- end
@@ -1,39 +0,0 @@
1
- require 'safe_colorize'
2
-
3
- module GraphDrawer
4
- class Data
5
- using SafeColorize
6
-
7
- attr_accessor :item
8
- attr_accessor :value
9
- attr_accessor :level
10
-
11
- def initialize(item, value)
12
- @item = item
13
- @value = value
14
- @level = nil
15
- end
16
-
17
- def to_s
18
- color =
19
- case @level
20
- when 1
21
- :green
22
- when 2
23
- :cyan
24
- when 3
25
- :blue
26
- end
27
-
28
- if @value.zero?
29
- draw_str = "#{@item}|"
30
- else
31
- bar = ' ' * (@value - @value.to_s.size)
32
- data_label = @value.to_s.color(:black)
33
- draw_str = "#{@item}|#{(bar + data_label).bg_color(color)}"
34
- end
35
-
36
- draw_str
37
- end
38
- end
39
- end
@@ -1,98 +0,0 @@
1
- module GraphDrawer
2
- class Graph
3
- def initialize
4
- @datas = []
5
- @max_item_size = 0
6
- @max_value_size = 0
7
- end
8
-
9
- def add(data)
10
- @datas << data
11
- @max_item_size = data.item.size if @max_item_size < data.item.size
12
- @max_value_size = data.value if @max_value_size < data.value
13
- end
14
-
15
- def datas_init
16
- @datas.each do |data|
17
- # Adjust the data item size
18
- data.item = adjust_item_size(data)
19
-
20
- # Set the data level
21
- data.level = calc_data_level(data)
22
- end
23
- end
24
-
25
- def to_s
26
- puts separate
27
-
28
- ommit_flag = false
29
- omitted = false
30
-
31
- @datas.each.with_index do |data, index|
32
- ommit_flag = false if ommit_flag == true && !data.value.zero?
33
-
34
- # First and Last
35
- if index.zero? || index == @datas.size - 1
36
- puts data.to_s
37
-
38
- # Omission
39
- elsif ommit_flag == true && omitted == false && @datas[index + 1].value.zero?
40
- puts draw_omission
41
-
42
- omitted = true
43
-
44
- # Omitted already
45
- elsif ommit_flag == true && omitted == true && @datas[index + 1].value.zero?
46
- next
47
-
48
- else
49
- puts data.to_s
50
-
51
- omitted = false
52
- end
53
-
54
- ommit_flag = true if ommit_flag == false && data.value.zero?
55
- end
56
-
57
- puts separate
58
- end
59
-
60
- private
61
-
62
- def adjust_item_size(data)
63
- missing_size = @max_item_size - data.item.size
64
-
65
- # Nothing to do
66
- return data.item if missing_size.zero?
67
-
68
- if missing_size.even?
69
- ' ' * (missing_size / 2) + data.item + ' ' * (missing_size / 2)
70
- else
71
- ' ' * (missing_size / 2) + data.item + ' ' * (missing_size / 2 + 1)
72
- end
73
- end
74
-
75
- def calc_data_level(data)
76
- basis = (@max_value_size / 3).round
77
- if data.value <= basis * 1
78
- 1
79
- elsif data.value <= basis * 2
80
- 2
81
- else
82
- 3
83
- end
84
- end
85
-
86
- def separate
87
- '=' * (@max_item_size + 1 + (@max_value_size * 2))
88
- end
89
-
90
- def draw_omission
91
- if @max_item_size.even?
92
- ' ' * (@max_item_size / 2) + '|' + ' ' * (@max_item_size / 2 - 1) + '|'
93
- else
94
- ' ' * (@max_item_size / 2) + '|' + ' ' * (@max_item_size / 2) + '|'
95
- end
96
- end
97
- end
98
- end
data/lib/table_builder.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'table_builder/table'
2
- require 'table_builder/row'
3
- require 'table_builder/column_validator'
4
- require 'table_builder/column'
5
-
6
- module TableBuilder
7
- def table(min_column_size = 10)
8
- @table = Table.new(min_column_size)
9
- yield
10
- @table.to_s
11
- end
12
-
13
- def row
14
- @row = Row.new
15
- yield
16
- @table.add(@row)
17
- end
18
-
19
- def column(text, size = nil)
20
- @column = Column.new(text, size)
21
- @row.add(@column)
22
- end
23
- end
@@ -1,18 +0,0 @@
1
- require 'safe_colorize'
2
-
3
- module TableBuilder
4
- class Column
5
- using SafeColorize
6
- prepend ColumnValidator
7
-
8
- attr_accessor :text
9
-
10
- def initialize(text, size)
11
- # Ignore ANSI escape sequences
12
- pure_text = text.to_pure
13
-
14
- text += ' ' * (size - pure_text.size) if !size.nil? && size > pure_text.size
15
- @text = text
16
- end
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- module TableBuilder
2
- module ColumnValidator
3
- def initialize(text, size)
4
- fail 'Invalid multibyte char' if text =~ /[^\x01-\x7E]/
5
-
6
- super
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module TableBuilder
2
- class Row
3
- attr_accessor :columns
4
-
5
- def initialize
6
- @columns = []
7
- end
8
-
9
- def add(column)
10
- @columns << column
11
- end
12
- end
13
- end
@@ -1,83 +0,0 @@
1
- require 'safe_colorize'
2
-
3
- module TableBuilder
4
- class Table
5
- using SafeColorize
6
-
7
- def initialize(min_column_size)
8
- @rows = []
9
- @header_column_sizes = []
10
- @min_column_size = min_column_size
11
- end
12
-
13
- def add(row)
14
- # Means the header
15
- if @rows.size.zero?
16
- set_header_column_size(row)
17
-
18
- else
19
- if row.columns.size != @header_column_sizes.size
20
- fail "Bud number of columns (#{row.columns.size} for #{@header_column_sizes.size})"
21
- end
22
- end
23
-
24
- @rows << row
25
- end
26
-
27
- def to_s
28
- puts separate
29
-
30
- @rows.each.with_index do |row, index|
31
- puts format_line(row)
32
- puts separate if index != @rows.size - 1
33
- end
34
-
35
- puts separate
36
- end
37
-
38
- private
39
-
40
- def set_header_column_size(row)
41
- row.columns.each.with_index do |column, index|
42
- # Ignore ANSI escape sequences
43
- pure_text = column.text.to_pure
44
-
45
- if pure_text.size > @min_column_size
46
- @header_column_sizes[index] = pure_text.size
47
- else
48
- @header_column_sizes[index] = @min_column_size
49
- end
50
- end
51
- end
52
-
53
- def format_line(row)
54
- line = '| '
55
-
56
- row.columns.each.with_index do |column, index|
57
- # Ignore ANSI escape sequences
58
- pure_text = column.text.to_pure
59
-
60
- if pure_text.size < @header_column_sizes[index]
61
- line << column.text + ' ' * (@header_column_sizes[index] - pure_text.size)
62
-
63
- elsif pure_text.size > @header_column_sizes[index]
64
- line << column.text[0, @header_column_sizes[index] - 3] + '...'
65
-
66
- else
67
- line << column.text
68
- end
69
-
70
- line << ' | ' if index != row.columns.size - 1
71
- end
72
-
73
- line << ' |'
74
- end
75
-
76
- def separate
77
- left = middle = right = '+'
78
- bar = '-'
79
-
80
- left + @header_column_sizes.map { |size| bar * (size + 2) }.join(middle) + right
81
- end
82
- end
83
- end