dev_suite 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/dev_suite/directory_tree/config.rb +39 -0
- data/lib/dev_suite/directory_tree/node/directory.rb +0 -2
- data/lib/dev_suite/directory_tree/node/file.rb +0 -2
- data/lib/dev_suite/directory_tree/node/permission_denied.rb +0 -2
- data/lib/dev_suite/directory_tree/node.rb +1 -0
- data/lib/dev_suite/directory_tree/renderer/base.rb +12 -5
- data/lib/dev_suite/directory_tree/renderer/simple.rb +0 -3
- data/lib/dev_suite/directory_tree/renderer.rb +12 -0
- data/lib/dev_suite/directory_tree/visualizer.rb +13 -11
- data/lib/dev_suite/directory_tree.rb +3 -0
- data/lib/dev_suite/performance/analyzer.rb +9 -15
- data/lib/dev_suite/performance/profiler/benchmark.rb +0 -1
- data/lib/dev_suite/performance/profiler/memory.rb +0 -3
- data/lib/dev_suite/performance/profiler.rb +1 -0
- data/lib/dev_suite/performance/reportor/simple.rb +0 -2
- data/lib/dev_suite/performance/reportor.rb +1 -0
- data/lib/dev_suite/performance.rb +3 -0
- data/lib/dev_suite/utils/color/colorizer.rb +9 -6
- data/lib/dev_suite/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76f0e8870b8fe2bb1c8af41e541bd09f792662f49c1a869d5ddcf5fd4ae94584
|
4
|
+
data.tar.gz: 17a921feedc29e07133ce357fbb3b37ecd15800cd30f4fd3087d62f4a810970d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a32bb7865ee17f49b639d687950cfafeecc51df0dc9e2e7a7ef62018ea185fd522081f8c7b70c0346d0b77ec4d119030c7e9464cf38f4928dad11ee756baa01a
|
7
|
+
data.tar.gz: 668586bdbd2339888ef486a5e2fb424aa0f3532d8fa80e27f92f569e59506b2237852683725560e55109eb93c5af63d51e6333aceea5dcb018604574733be5ef
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -51,7 +51,7 @@ DevSuite::SomeUtility.do_something
|
|
51
51
|
```ruby
|
52
52
|
require 'dev_suite'
|
53
53
|
|
54
|
-
DevSuite::Performance
|
54
|
+
DevSuite::Performance.analyze(description: "My Code Block") do
|
55
55
|
sum = 0
|
56
56
|
1_000_000.times do |i|
|
57
57
|
sum += i
|
@@ -93,7 +93,7 @@ DevSuite::SomeUtility.do_something
|
|
93
93
|
base_path = "/path/to/your/directory"
|
94
94
|
|
95
95
|
# Perform the visualization
|
96
|
-
DevSuite::DirectoryTree
|
96
|
+
DevSuite::DirectoryTree.visualize(base_path)
|
97
97
|
```
|
98
98
|
|
99
99
|
**Example output**
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DevSuite
|
4
|
+
module DirectoryTree
|
5
|
+
class Config
|
6
|
+
attr_reader :renderer
|
7
|
+
|
8
|
+
def initialize(renderer: :simple)
|
9
|
+
@renderer = Renderer.create(renderer)
|
10
|
+
freeze # Make the instance of this class immutable as well
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
#
|
15
|
+
# Provide global access to a single instance of Config
|
16
|
+
#
|
17
|
+
def configuration
|
18
|
+
@configuration ||= new
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Allow block-based configuration
|
23
|
+
#
|
24
|
+
def configure
|
25
|
+
yield(configuration)
|
26
|
+
rescue StandardError => e
|
27
|
+
handle_configuration_error(e)
|
28
|
+
raise
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def handle_configuration_error(error)
|
34
|
+
puts "Configuration error: #{error.message}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -6,17 +6,24 @@ module DevSuite
|
|
6
6
|
module DirectoryTree
|
7
7
|
module Renderer
|
8
8
|
class Base
|
9
|
-
def
|
10
|
-
|
11
|
-
end
|
9
|
+
def render(path)
|
10
|
+
raise ArgumentError, "Invalid path" unless valid_path?(path)
|
12
11
|
|
13
|
-
|
14
|
-
root = build_tree(@base_path)
|
12
|
+
root = build_tree(Pathname.new(path))
|
15
13
|
render_node(root, "", true)
|
16
14
|
end
|
17
15
|
|
18
16
|
private
|
19
17
|
|
18
|
+
def valid_path?(path)
|
19
|
+
[
|
20
|
+
path.is_a?(String),
|
21
|
+
::File.exist?(path),
|
22
|
+
::File.directory?(path),
|
23
|
+
::File.readable?(path),
|
24
|
+
].all?
|
25
|
+
end
|
26
|
+
|
20
27
|
# Builds the tree structure
|
21
28
|
# @param path [Pathname] The path to build the tree from
|
22
29
|
# @return [Node::Base] The root node of the tree
|
@@ -3,7 +3,19 @@
|
|
3
3
|
module DevSuite
|
4
4
|
module DirectoryTree
|
5
5
|
module Renderer
|
6
|
+
require_relative "renderer/base"
|
6
7
|
require_relative "renderer/simple"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def create(type)
|
11
|
+
case type
|
12
|
+
when :simple
|
13
|
+
Simple.new
|
14
|
+
else
|
15
|
+
raise ArgumentError, "Unknown renderer type: #{type}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
7
19
|
end
|
8
20
|
end
|
9
21
|
end
|
@@ -1,25 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "pathname"
|
4
|
-
require_relative "renderer"
|
5
4
|
|
6
5
|
module DevSuite
|
7
6
|
module DirectoryTree
|
8
7
|
class Visualizer
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
new(base_path).visualize
|
14
|
-
end
|
8
|
+
attr_reader :config
|
9
|
+
|
10
|
+
def initialize(config = Config.configuration)
|
11
|
+
@config = config
|
15
12
|
end
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
# Visualizes the directory tree
|
15
|
+
# @param path [String] The base path of the directory
|
16
|
+
def visualize(path)
|
17
|
+
puts @config.renderer.render(path)
|
19
18
|
end
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
class << self
|
22
|
+
def visualize(path)
|
23
|
+
visualizer = Visualizer.new
|
24
|
+
visualizer.visualize(path)
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -1,23 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "reportor"
|
4
|
-
require_relative "profiler"
|
5
|
-
|
6
3
|
module DevSuite
|
7
4
|
module Performance
|
8
5
|
class Analyzer
|
9
|
-
class << self
|
10
|
-
# Generates a performance report
|
11
|
-
# @param benchmark_result [Benchmark::Tms] The benchmark result
|
12
|
-
# @param memory_stats [Hash] The memory statistics
|
13
|
-
def analyze(description: "Block", &block)
|
14
|
-
raise ArgumentError, "No block given" unless block_given?
|
15
|
-
|
16
|
-
analyzer = new(description: description)
|
17
|
-
analyzer.analyze(&block)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
6
|
def initialize(description: "Block")
|
22
7
|
@description = description
|
23
8
|
@benchmark_profiler = Profiler::Benchmark.new
|
@@ -29,6 +14,8 @@ module DevSuite
|
|
29
14
|
# @param block [Proc] The block to be analyzed
|
30
15
|
# @raise [ArgumentError] If no block is given
|
31
16
|
def analyze(&block)
|
17
|
+
raise ArgumentError, "No block given" unless block_given?
|
18
|
+
|
32
19
|
memory_before = @memory_usage.current
|
33
20
|
benchmark_result = profile_benchmark(&block)
|
34
21
|
memory_after = @memory_usage.current
|
@@ -61,5 +48,12 @@ module DevSuite
|
|
61
48
|
reportor.generate
|
62
49
|
end
|
63
50
|
end
|
51
|
+
|
52
|
+
class << self
|
53
|
+
def analyze(description: "Block", &block)
|
54
|
+
analyzer = Analyzer.new(description: description)
|
55
|
+
analyzer.analyze(&block)
|
56
|
+
end
|
57
|
+
end
|
64
58
|
end
|
65
59
|
end
|
@@ -3,12 +3,6 @@
|
|
3
3
|
module DevSuite
|
4
4
|
module Utils
|
5
5
|
module Color
|
6
|
-
class << self
|
7
|
-
def colorize(text, **kargs)
|
8
|
-
Colorizer.new(Config.configuration).colorize(text, **kargs)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
6
|
class Colorizer
|
13
7
|
attr_reader :config
|
14
8
|
|
@@ -20,6 +14,15 @@ module DevSuite
|
|
20
14
|
puts @config.strategy.colorize(text, **kargs)
|
21
15
|
end
|
22
16
|
end
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def colorize(text, **kargs)
|
20
|
+
raise ArgumentError, "Text to colorize must be a string" unless text.is_a?(String)
|
21
|
+
|
22
|
+
colorizer = Colorizer.new
|
23
|
+
colorizer.colorize(text, **kargs)
|
24
|
+
end
|
25
|
+
end
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
data/lib/dev_suite/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_suite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huy Nguyen
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- dev_suite.gemspec
|
63
63
|
- lib/dev_suite.rb
|
64
64
|
- lib/dev_suite/directory_tree.rb
|
65
|
+
- lib/dev_suite/directory_tree/config.rb
|
65
66
|
- lib/dev_suite/directory_tree/node.rb
|
66
67
|
- lib/dev_suite/directory_tree/node/base.rb
|
67
68
|
- lib/dev_suite/directory_tree/node/directory.rb
|