dev_suite 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +1 -1
- data/README.md +62 -4
- data/dev_suite.gemspec +1 -2
- data/lib/dev_suite/directory_tree/node/base.rb +19 -0
- data/lib/dev_suite/directory_tree/node/directory.rb +26 -0
- data/lib/dev_suite/directory_tree/node/file.rb +15 -0
- data/lib/dev_suite/directory_tree/node/permission_denied.rb +25 -0
- data/lib/dev_suite/directory_tree/node.rb +11 -0
- data/lib/dev_suite/directory_tree/renderer/base.rb +38 -0
- data/lib/dev_suite/directory_tree/renderer/simple.rb +61 -0
- data/lib/dev_suite/directory_tree/renderer.rb +9 -0
- data/lib/dev_suite/directory_tree/visualizer.rb +26 -0
- data/lib/dev_suite/directory_tree.rb +7 -0
- data/lib/dev_suite/performance/analyzer.rb +6 -7
- data/lib/dev_suite/performance/data.rb +9 -0
- data/lib/dev_suite/performance/{profiling/base_profiler.rb → profiler/base.rb} +2 -2
- data/lib/dev_suite/performance/{profiling/benchmark_profiler.rb → profiler/benchmark.rb} +4 -4
- data/lib/dev_suite/performance/{profiling/memory_profiler.rb → profiler/memory.rb} +3 -3
- data/lib/dev_suite/performance/profiler.rb +10 -0
- data/lib/dev_suite/performance/reportor/base.rb +13 -0
- data/lib/dev_suite/performance/{reporting/report_generator.rb → reportor/simple.rb} +5 -5
- data/lib/dev_suite/performance/reportor.rb +9 -0
- data/lib/dev_suite/performance.rb +7 -0
- data/lib/dev_suite/utils/table/column.rb +11 -0
- data/lib/dev_suite/utils/table/renderer.rb +12 -0
- data/lib/dev_suite/utils/table/row.rb +11 -0
- data/lib/dev_suite/utils/table/table.rb +1 -1
- data/lib/dev_suite/utils.rb +9 -0
- data/lib/dev_suite/version.rb +1 -1
- data/lib/dev_suite.rb +2 -1
- metadata +27 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b962be05b7f06443a5620effcba37759712b4a930654f28782280bdcfb975698
|
4
|
+
data.tar.gz: 3d3987ce785c0211d279a382fcd0dace11ce3e66861629b613e1857ddf9064c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5cc89b151a1224cd7fa29c65c05a0d873e400585ad949e5f5b6278bb23aacfda90367036372f659f5596e948217b63cc00a71c71cfcc1a20fe4c72076227257
|
7
|
+
data.tar.gz: 13998cef95d7658837462bb319f5af0664302eeeb54168fc1fe0c9049f3f287df8887665d27eaf69009789cac71541b3d0e457d3f456ce2af35557d2832b2248
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# DevSuite
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/dev_suite.svg)](https://badge.fury.io/rb/dev_suite)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/patrick204nqh/dev_suite/badges/gpa.svg)](https://codeclimate.com/github/patrick204nqh/dev_suite)
|
5
|
+
|
3
6
|
Welcome to DevSuite! This gem provides a suite of utilities for developers to enhance their productivity.
|
4
7
|
|
5
8
|
## Installation
|
@@ -40,7 +43,7 @@ DevSuite::SomeUtility.do_something
|
|
40
43
|
## Features
|
41
44
|
|
42
45
|
<details>
|
43
|
-
<summary><strong>Performance Analysis
|
46
|
+
<summary><strong>Performance Analysis</strong></summary>
|
44
47
|
|
45
48
|
Analyze the performance of your code blocks with detailed benchmark and memory usage reports.
|
46
49
|
|
@@ -49,10 +52,65 @@ DevSuite::SomeUtility.do_something
|
|
49
52
|
require 'dev_suite'
|
50
53
|
|
51
54
|
DevSuite::Performance::Analyzer.analyze(description: "My Code Block") do
|
52
|
-
|
55
|
+
sum = 0
|
56
|
+
1_000_000.times do |i|
|
57
|
+
sum += i
|
58
|
+
end
|
59
|
+
sum
|
53
60
|
end
|
54
61
|
```
|
55
|
-
|
62
|
+
|
63
|
+
**Example output**
|
64
|
+
```
|
65
|
+
| Performance Analysis |
|
66
|
+
+----------------------------+---------------+
|
67
|
+
| Metric | Value |
|
68
|
+
+----------------------------+---------------+
|
69
|
+
| Description | My Code Block |
|
70
|
+
| Total Time (s) | 0.056238 |
|
71
|
+
| User CPU Time (s) | 0.055662 |
|
72
|
+
| System CPU Time (s) | 0.000097 |
|
73
|
+
| User + System CPU Time (s) | 0.055759 |
|
74
|
+
| Memory Before (MB) | 25.39 |
|
75
|
+
| Memory After (MB) | 25.42 |
|
76
|
+
| Memory Used (MB) | 0.03 |
|
77
|
+
| Max Memory Used (MB) | 25.41 |
|
78
|
+
| Min Memory Used (MB) | 25.41 |
|
79
|
+
| Avg Memory Used (MB) | 25.41 |
|
80
|
+
```
|
81
|
+
</details>
|
82
|
+
|
83
|
+
<details>
|
84
|
+
<summary><strong>Directory Tree Visualization</strong></summary>
|
85
|
+
|
86
|
+
Visualize the structure of directories and their subdirectories with a detailed hierarchical representation. This tool is essential for understanding the organization of your files and directories at a glance.
|
87
|
+
|
88
|
+
**Usage:**
|
89
|
+
```ruby
|
90
|
+
require 'dev_suite'
|
91
|
+
|
92
|
+
# Set the base path for the directory you want to visualize
|
93
|
+
base_path = "/path/to/your/directory"
|
94
|
+
|
95
|
+
# Perform the visualization
|
96
|
+
DevSuite::DirectoryTree::Visualizer.visualize(base_path)
|
97
|
+
```
|
98
|
+
|
99
|
+
**Example output**
|
100
|
+
```
|
101
|
+
/path/to/your/directory/
|
102
|
+
├── project/
|
103
|
+
│ ├── src/
|
104
|
+
│ │ ├── main.rb
|
105
|
+
│ │ └── helper.rb
|
106
|
+
│ └── spec/
|
107
|
+
│ └── main_spec.rb
|
108
|
+
├── doc/
|
109
|
+
│ └── README.md
|
110
|
+
└── test/
|
111
|
+
└── test_helper.rb
|
112
|
+
```
|
113
|
+
</details>
|
56
114
|
|
57
115
|
## Development
|
58
116
|
|
@@ -84,4 +142,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
84
142
|
|
85
143
|
## Code of Conduct
|
86
144
|
|
87
|
-
Everyone interacting in the DevSuite project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/patrick204nqh/dev_suite/blob/master/CODE_OF_CONDUCT.md).
|
145
|
+
Everyone interacting in the DevSuite project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/patrick204nqh/dev_suite/blob/master/CODE_OF_CONDUCT.md).
|
data/dev_suite.gemspec
CHANGED
@@ -9,8 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["patrick204nqh@gmail.com"]
|
10
10
|
|
11
11
|
spec.summary = "A suite of development tools."
|
12
|
-
spec.description = "
|
13
|
-
"and custom curl command generation."
|
12
|
+
spec.description = "This gem provides a suite of utilities for developers to enhance their productivity."
|
14
13
|
spec.homepage = "https://patrick204nqh.github.io"
|
15
14
|
spec.license = "MIT"
|
16
15
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DevSuite
|
4
|
+
module DirectoryTree
|
5
|
+
module Node
|
6
|
+
class Base
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
def initialize(name)
|
10
|
+
@name = name
|
11
|
+
end
|
12
|
+
|
13
|
+
def directory?
|
14
|
+
raise NotImplementedError, "Must implement in subclass"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
|
5
|
+
module DevSuite
|
6
|
+
module DirectoryTree
|
7
|
+
module Node
|
8
|
+
class Directory < Base
|
9
|
+
attr_reader :children
|
10
|
+
|
11
|
+
def initialize(name)
|
12
|
+
super
|
13
|
+
@children = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def directory?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_child(child)
|
21
|
+
@children << child
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
|
5
|
+
module DevSuite
|
6
|
+
module DirectoryTree
|
7
|
+
module Node
|
8
|
+
class PermissionDenied < Base
|
9
|
+
# This class is used to represent a file or directory that the user does not have permission to access.
|
10
|
+
def initialize(name, is_directory)
|
11
|
+
super(name)
|
12
|
+
@is_directory = is_directory
|
13
|
+
end
|
14
|
+
|
15
|
+
def directory?
|
16
|
+
@is_directory
|
17
|
+
end
|
18
|
+
|
19
|
+
def children
|
20
|
+
[]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
|
5
|
+
module DevSuite
|
6
|
+
module DirectoryTree
|
7
|
+
module Renderer
|
8
|
+
class Base
|
9
|
+
def initialize(base_path)
|
10
|
+
@base_path = Pathname.new(base_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
root = build_tree(@base_path)
|
15
|
+
render_node(root, "", true)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Builds the tree structure
|
21
|
+
# @param path [Pathname] The path to build the tree from
|
22
|
+
# @return [Node::Base] The root node of the tree
|
23
|
+
def build_tree(path)
|
24
|
+
raise NotImplementedError, "You must implement the build_tree method"
|
25
|
+
end
|
26
|
+
|
27
|
+
# Renders a node in the tree
|
28
|
+
# @param node [Node::Base] The node to render
|
29
|
+
# @param prefix [String] The prefix to add to the node
|
30
|
+
# @param is_last [Boolean] Whether this is the last node in the list
|
31
|
+
# @return [String] The rendered node
|
32
|
+
def render_node(node, prefix, is_last)
|
33
|
+
raise NotImplementedError, "You must implement the render_node method"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
require_relative "../node"
|
5
|
+
|
6
|
+
module DevSuite
|
7
|
+
module DirectoryTree
|
8
|
+
module Renderer
|
9
|
+
class Simple < Base
|
10
|
+
private
|
11
|
+
|
12
|
+
def build_tree(path)
|
13
|
+
return Node::PermissionDenied.new(path.basename.to_s, path.directory?) unless path.readable?
|
14
|
+
|
15
|
+
if path.directory?
|
16
|
+
dir = Node::Directory.new(path.basename.to_s)
|
17
|
+
children = path.children.sort_by { |child| child.basename.to_s.downcase }
|
18
|
+
children.each do |child|
|
19
|
+
dir.add_child(build_tree(child))
|
20
|
+
end
|
21
|
+
dir
|
22
|
+
else
|
23
|
+
Node::File.new(path.basename.to_s)
|
24
|
+
end
|
25
|
+
rescue Errno::EACCES
|
26
|
+
Node::PermissionDenied.new(path.basename.to_s, path.directory?)
|
27
|
+
end
|
28
|
+
|
29
|
+
def render_node(node, prefix = "", is_last = true)
|
30
|
+
# Determine if this is the root node based on the prefix content
|
31
|
+
is_root = prefix.empty?
|
32
|
+
|
33
|
+
# Prepare the connector appropriately, omitting it for the root
|
34
|
+
connector = if is_root
|
35
|
+
""
|
36
|
+
else
|
37
|
+
(is_last ? "└── " : "├── ")
|
38
|
+
end
|
39
|
+
|
40
|
+
# Compute the new prefix for children
|
41
|
+
new_prefix = "#{prefix}#{is_last ? " " : "| "}"
|
42
|
+
|
43
|
+
# Construct the output for the current node, avoiding the connector for the root
|
44
|
+
output = "#{prefix}#{connector}#{node.name}"
|
45
|
+
output += "/\n" if node.directory?
|
46
|
+
|
47
|
+
# Recursively render children if it's a directory
|
48
|
+
if node.directory? && node.children.any?
|
49
|
+
node.children.each_with_index do |child, index|
|
50
|
+
output += render_node(child, new_prefix, index == node.children.size - 1)
|
51
|
+
end
|
52
|
+
elsif !node.directory?
|
53
|
+
output += "\n"
|
54
|
+
end
|
55
|
+
|
56
|
+
output
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
require_relative "renderer"
|
5
|
+
|
6
|
+
module DevSuite
|
7
|
+
module DirectoryTree
|
8
|
+
class Visualizer
|
9
|
+
class << self
|
10
|
+
# Visualizes the directory tree
|
11
|
+
# @param base_path [String] The base path of the directory
|
12
|
+
def visualize(base_path)
|
13
|
+
new(base_path).visualize
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(base_path, renderer: Renderer::Simple.new(base_path))
|
18
|
+
@renderer = renderer
|
19
|
+
end
|
20
|
+
|
21
|
+
def visualize
|
22
|
+
puts @renderer.render
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
4
|
-
require_relative "
|
5
|
-
require_relative "profiling/memory_profiler"
|
3
|
+
require_relative "reportor"
|
4
|
+
require_relative "profiler"
|
6
5
|
|
7
6
|
module DevSuite
|
8
7
|
module Performance
|
@@ -21,8 +20,8 @@ module DevSuite
|
|
21
20
|
|
22
21
|
def initialize(description: "Block")
|
23
22
|
@description = description
|
24
|
-
@benchmark_profiler =
|
25
|
-
@memory_profiler =
|
23
|
+
@benchmark_profiler = Profiler::Benchmark.new
|
24
|
+
@memory_profiler = Profiler::Memory.new
|
26
25
|
@memory_usage = Data::MemoryUsage.new
|
27
26
|
end
|
28
27
|
|
@@ -54,12 +53,12 @@ module DevSuite
|
|
54
53
|
# @param benchmark_result [Benchmark::Tms] The benchmark result
|
55
54
|
# @param memory_stats [Hash] The memory statistics
|
56
55
|
def generate_report(benchmark_result, memory_stats)
|
57
|
-
|
56
|
+
reportor = Reportor::Simple.new(
|
58
57
|
@description,
|
59
58
|
benchmark_result,
|
60
59
|
memory_stats,
|
61
60
|
)
|
62
|
-
|
61
|
+
reportor.generate
|
63
62
|
end
|
64
63
|
end
|
65
64
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "benchmark"
|
4
|
-
require_relative "
|
4
|
+
require_relative "base"
|
5
5
|
|
6
6
|
module DevSuite
|
7
7
|
module Performance
|
8
|
-
module
|
9
|
-
class
|
8
|
+
module Profiler
|
9
|
+
class Benchmark < Base
|
10
10
|
def run(&block)
|
11
|
-
Benchmark.measure do
|
11
|
+
::Benchmark.measure do
|
12
12
|
block.call
|
13
13
|
end
|
14
14
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
3
|
+
require_relative "base"
|
4
4
|
require_relative "../data/memory_usage"
|
5
5
|
|
6
6
|
module DevSuite
|
7
7
|
module Performance
|
8
|
-
module
|
9
|
-
class
|
8
|
+
module Profiler
|
9
|
+
class Memory < Base
|
10
10
|
attr_reader :max_memory, :min_memory, :average_memory
|
11
11
|
|
12
12
|
def initialize
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
4
|
-
require_relative "../../utils
|
5
|
-
require_relative "../../utils/table/renderer/simple"
|
3
|
+
require_relative "base"
|
4
|
+
require_relative "../../utils"
|
6
5
|
|
7
6
|
module DevSuite
|
8
7
|
module Performance
|
9
|
-
module
|
10
|
-
class
|
8
|
+
module Reportor
|
9
|
+
class Simple < Base
|
11
10
|
def initialize(description, benchmark_result, memory_stats)
|
11
|
+
super()
|
12
12
|
@description = description
|
13
13
|
@benchmark_result = benchmark_result
|
14
14
|
@memory_stats = memory_stats
|
data/lib/dev_suite/version.rb
CHANGED
data/lib/dev_suite.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_suite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huy Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark
|
@@ -38,8 +38,8 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.2'
|
41
|
-
description:
|
42
|
-
|
41
|
+
description: This gem provides a suite of utilities for developers to enhance their
|
42
|
+
productivity.
|
43
43
|
email:
|
44
44
|
- patrick204nqh@gmail.com
|
45
45
|
executables: []
|
@@ -61,19 +61,38 @@ files:
|
|
61
61
|
- bin/setup
|
62
62
|
- dev_suite.gemspec
|
63
63
|
- lib/dev_suite.rb
|
64
|
+
- lib/dev_suite/directory_tree.rb
|
65
|
+
- lib/dev_suite/directory_tree/node.rb
|
66
|
+
- lib/dev_suite/directory_tree/node/base.rb
|
67
|
+
- lib/dev_suite/directory_tree/node/directory.rb
|
68
|
+
- lib/dev_suite/directory_tree/node/file.rb
|
69
|
+
- lib/dev_suite/directory_tree/node/permission_denied.rb
|
70
|
+
- lib/dev_suite/directory_tree/renderer.rb
|
71
|
+
- lib/dev_suite/directory_tree/renderer/base.rb
|
72
|
+
- lib/dev_suite/directory_tree/renderer/simple.rb
|
73
|
+
- lib/dev_suite/directory_tree/visualizer.rb
|
74
|
+
- lib/dev_suite/performance.rb
|
64
75
|
- lib/dev_suite/performance/analyzer.rb
|
76
|
+
- lib/dev_suite/performance/data.rb
|
65
77
|
- lib/dev_suite/performance/data/memory_usage.rb
|
66
|
-
- lib/dev_suite/performance/
|
67
|
-
- lib/dev_suite/performance/
|
68
|
-
- lib/dev_suite/performance/
|
69
|
-
- lib/dev_suite/performance/
|
78
|
+
- lib/dev_suite/performance/profiler.rb
|
79
|
+
- lib/dev_suite/performance/profiler/base.rb
|
80
|
+
- lib/dev_suite/performance/profiler/benchmark.rb
|
81
|
+
- lib/dev_suite/performance/profiler/memory.rb
|
82
|
+
- lib/dev_suite/performance/reportor.rb
|
83
|
+
- lib/dev_suite/performance/reportor/base.rb
|
84
|
+
- lib/dev_suite/performance/reportor/simple.rb
|
85
|
+
- lib/dev_suite/utils.rb
|
86
|
+
- lib/dev_suite/utils/table/column.rb
|
70
87
|
- lib/dev_suite/utils/table/column/column.rb
|
71
88
|
- lib/dev_suite/utils/table/config.rb
|
72
89
|
- lib/dev_suite/utils/table/formatter/colorizer.rb
|
73
90
|
- lib/dev_suite/utils/table/formatter/column_width_calculator.rb
|
74
91
|
- lib/dev_suite/utils/table/formatter/text_aligner.rb
|
92
|
+
- lib/dev_suite/utils/table/renderer.rb
|
75
93
|
- lib/dev_suite/utils/table/renderer/base.rb
|
76
94
|
- lib/dev_suite/utils/table/renderer/simple.rb
|
95
|
+
- lib/dev_suite/utils/table/row.rb
|
77
96
|
- lib/dev_suite/utils/table/row/row.rb
|
78
97
|
- lib/dev_suite/utils/table/table.rb
|
79
98
|
- lib/dev_suite/version.rb
|