teuton-get 0.1.0 → 0.2.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: dec6728e4afe5e3d3273d1391d5c968d3f3ad37f1c742c973e42ed990116518c
4
- data.tar.gz: 9a188d0781561d45e7e1aa6c9d722cfada8175e77d0fe4f374e897daecdd0f90
3
+ metadata.gz: c9a7d30a57e1d17315bdc1a70eca4bb76e397c901c46cb5a5709fd72802945ea
4
+ data.tar.gz: 12d9f68bfbd6a1f4c3107acb4059527b829def841e2049753f4ed77e3c70c362
5
5
  SHA512:
6
- metadata.gz: 462dbca5915bbb736940152eb7d36f00892889d9a69401b3cd9152b082f8211a055ad5c665e466ce1fde703b5cf1bcaf379d8d58229692c246697b31a26b6fb5
7
- data.tar.gz: 3e9ffcd01859e9102aaf385a0eab14540cbc8f406a3f722a56b09de0fd9975544e4fef89d0786a44860f30ca7a3be2c373d59ad3f01f5e66187e79f8fb9763ee
6
+ metadata.gz: 6b5a55be18579de050724e9cc48dfdd1aebd0e87108b3810d2a785034b94de87c392fdff0f85ba87858227bda8f604e77173193bd65b5efe9867aecf02e31011
7
+ data.tar.gz: 23a880ed0a732db0891947a828a12188a034cc4b6f9611b30748916751e7104f530eb77b61b95a492bc2db574a46b5a59e97ca7dcbf48354573e8adb25592909
data/README.md CHANGED
@@ -15,8 +15,20 @@
15
15
 
16
16
  * At first, create config file with `teutonget init`.
17
17
  * Then, search tests with `teutonget search FILTER`. Example: `teutonget search linux`, will show a list with "linux" related tests.
18
+
19
+
18
20
  * `teutonget download REPONAME:TESTPATH`
19
21
 
22
+ ## Example
23
+
24
+ * Search and download test:
25
+
26
+ ![](docs/images/teutonget-download.png)
27
+
28
+ * Refresh repos and show test details:
29
+
30
+ ![](docs/images/teutonget-info.png)
31
+
20
32
  # Contact
21
33
 
22
34
  * **Email**: `teuton.software@protonmail.com`
data/bin/teuton-get ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ system("teutonget #{ARGV.join(" ")}")
@@ -56,7 +56,7 @@ class Downloader
56
56
  end
57
57
 
58
58
  def download(reponame, url, path, files)
59
- @dev.writeln "==> Downloading #{path} from #{reponame}...", color: :light_yellow
59
+ @dev.writeln "==> Downloading '#{path}' from repo '#{reponame}'...", color: :light_yellow
60
60
  localpath = path.tr("/", "_")
61
61
  FileUtils.mkdir(localpath) unless File.exist? localpath
62
62
  files.each do |filename|
@@ -0,0 +1,23 @@
1
+ require "colorize"
2
+
3
+ module TeutonGet
4
+ module Format
5
+ COLORS = [:light_blue, :light_magenta, :light_cyan, :red, :green, :yellow]
6
+
7
+ def self.colorize(text = "", option = nil)
8
+ return text if option.nil?
9
+ color = if option.instance_of? Integer
10
+ if option < COLORS.size
11
+ COLORS[option]
12
+ else
13
+ COLORS[option - COLOR.size]
14
+ end
15
+ elsif option.instance_of? Symbol
16
+ option
17
+ else
18
+ :silver
19
+ end
20
+ text.colorize(color)
21
+ end
22
+ end
23
+ end
@@ -47,7 +47,7 @@ class LocalInfo
47
47
  @data[:name] = prompt.ask("name?", default: @data[:name])
48
48
  @data[:author] = prompt.ask("author?", default: @data[:author])
49
49
  @data[:date] = prompt.ask("date?", default: @data[:date])
50
- @data[:desc] = prompt.ask("desc?", default: @data[:desc])
50
+ @data[:desc] = sanityze(prompt.ask("desc?", default: @data[:desc]))
51
51
  input = prompt.ask("tags?", default: @data[:tags].join(","))
52
52
  @data[:tags] = input.split(",")
53
53
  end
@@ -68,4 +68,8 @@ class LocalInfo
68
68
 
69
69
  true
70
70
  end
71
+
72
+ def sanityze(text)
73
+ text.tr(":", " ")
74
+ end
71
75
  end
@@ -1,5 +1,6 @@
1
1
  require "fileutils"
2
2
  require_relative "../application"
3
+ require_relative "../format"
3
4
  require_relative "../reader/inifile_reader"
4
5
  require_relative "../writer/terminal_writer"
5
6
 
@@ -36,11 +37,13 @@ class RepoConfig
36
37
  rows << ["E", "NAME", "DESCRIPTION"]
37
38
  rows << :separator
38
39
 
40
+ index = 0
39
41
  @data.each_pair do |key, value|
40
42
  enable = "\u{2714}"
41
43
  enable = " " unless value["enable"]
42
44
  description = value["description"] || "?"
43
- rows << [enable, key, description]
45
+ rows << [enable, TeutonGet::Format.colorize(key, index), description]
46
+ index += 1
44
47
  end
45
48
  @dev.writeln "Repository list"
46
49
  @dev.write_table(rows)
@@ -44,7 +44,7 @@ class RepoData
44
44
 
45
45
  def show_testinfo(item)
46
46
  return unless item
47
- @dev.writeln ""
47
+
48
48
  ["name", "author", "date", "desc"].each do |key|
49
49
  @dev.write "#{key.ljust(7)} : ", color: :white
50
50
  @dev.writeln item[key].to_s
@@ -1,6 +1,8 @@
1
1
  require_relative "../application"
2
2
 
3
3
  class Result
4
+ @@repoindex = Set.new
5
+
4
6
  attr_accessor :score
5
7
  attr_reader :reponame
6
8
  attr_reader :testname
@@ -9,6 +11,7 @@ class Result
9
11
  @score = args[:score] || 0
10
12
  @reponame = args[:reponame] || "???"
11
13
  @testname = args[:testname] || "???"
14
+ @@repoindex << @reponame
12
15
  end
13
16
 
14
17
  def id
@@ -16,6 +19,15 @@ class Result
16
19
  end
17
20
 
18
21
  def to_h
19
- {score: @score, id: id, reponame: @reponame, testname: @testname}
22
+ {
23
+ score: @score,
24
+ id: id, reponame: @reponame,
25
+ testname: @testname,
26
+ repoindex: repoindex
27
+ }
28
+ end
29
+
30
+ def repoindex
31
+ @@repoindex.to_a.index(@reponame)
20
32
  end
21
33
  end
@@ -1,4 +1,5 @@
1
1
  require_relative "application"
2
+ require_relative "format"
2
3
  require_relative "reader/yaml_reader"
3
4
  require_relative "repo/repo_data"
4
5
  require_relative "searcher/result"
@@ -30,10 +31,11 @@ class Searcher
30
31
  search_inside(reponame_filter, filters)
31
32
  end
32
33
 
33
- def show(result)
34
+ def show_result
34
35
  @results.each do |i|
35
36
  @dev.write "(x#{i[:score]}) ", color: :white
36
- @dev.writeln "#{i[:reponame]}#{Application::SEPARATOR}#{i[:testname]}"
37
+ reponame = TeutonGet::Format.colorize(i[:reponame], i[:repoindex])
38
+ @dev.writeln "#{reponame}#{Application::SEPARATOR}#{i[:testname]}"
37
39
  end
38
40
  end
39
41
 
@@ -1,6 +1,6 @@
1
1
  module Version
2
2
  NAME = "teuton-get"
3
3
  EXECUTABLE = "teutonget"
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  HOMEPAGE = "https://github.com/teuton-software/#{NAME}"
6
6
  end
@@ -1,7 +1,10 @@
1
1
  require_relative "writer"
2
+ require "fileutils"
2
3
 
3
4
  class FileWriter < Writer
4
5
  def open(filepath)
6
+ dirpath = File.dirname(filepath)
7
+ FileUtils.mkdir_p(dirpath) unless Dir.exist? dirpath
5
8
  @file = File.open(filepath, "w")
6
9
  end
7
10
 
@@ -1,11 +1,10 @@
1
- require "colorize"
2
1
  require "tty-table"
3
2
  require_relative "writer"
3
+ require_relative "../format"
4
4
 
5
5
  class TerminalWriter < Writer
6
6
  def write(text = "", args = {})
7
- color = args[:color] || :silver
8
- print text.colorize(color)
7
+ print TeutonGet::Format.colorize(text, args[:color])
9
8
  end
10
9
 
11
10
  def writeln(text = "", args = {})
data/lib/teuton-get.rb CHANGED
@@ -35,8 +35,8 @@ module TeutonGet
35
35
 
36
36
  def self.search(filter)
37
37
  searcher = Searcher.new_by_default
38
- result = searcher.get(filter)
39
- searcher.show(result)
38
+ searcher.get(filter)
39
+ searcher.show_result
40
40
  end
41
41
 
42
42
  def self.download(test_id)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton-get
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-29 00:00:00.000000000 Z
11
+ date: 2022-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inifile
@@ -84,17 +84,19 @@ description: " Find and download Teuton Test.\n"
84
84
  email: teuton.software@protonmail.com
85
85
  executables:
86
86
  - teutonget
87
+ - teuton-get
87
88
  extensions: []
88
89
  extra_rdoc_files:
89
90
  - README.md
90
91
  - LICENSE
91
92
  - docs/commands.md
92
93
  - docs/get.md
93
- - docs/settings.md
94
94
  - docs/repo.md
95
+ - docs/settings.md
95
96
  files:
96
97
  - LICENSE
97
98
  - README.md
99
+ - bin/teuton-get
98
100
  - bin/teutonget
99
101
  - docs/commands.md
100
102
  - docs/get.md
@@ -107,6 +109,7 @@ files:
107
109
  - lib/teuton-get/downloader.rb
108
110
  - lib/teuton-get/files/repos.ini
109
111
  - lib/teuton-get/files/tt-info.yaml
112
+ - lib/teuton-get/format.rb
110
113
  - lib/teuton-get/reader/inifile_reader.rb
111
114
  - lib/teuton-get/reader/linux_environment_reader.rb
112
115
  - lib/teuton-get/reader/reader.rb
@@ -142,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
145
  - !ruby/object:Gem::Version
143
146
  version: '0'
144
147
  requirements: []
145
- rubygems_version: 3.1.6
148
+ rubygems_version: 3.3.3
146
149
  signing_key:
147
150
  specification_version: 4
148
151
  summary: TeutonGet (Teuton Software)