windclutter 0.0.12 → 0.0.14
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 +4 -4
- data/README.md +32 -10
- data/lib/windclutter/analyser.rb +1 -1
- data/lib/windclutter/cli/core.rb +5 -3
- data/lib/windclutter/util/file_handler.rb +4 -2
- data/lib/windclutter/version.rb +1 -1
- data/test/test_windclutter.rb +7 -0
- data/test/windclutter/test_analyser.rb +10 -1
- data/test/windclutter/util/test_file_handler.rb +57 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b9b31ca076defb624a2eb5519dac480abbdd0bb0f1556a00e8929112c45ba6d
|
4
|
+
data.tar.gz: 47fc0066c41bd1486da953b28f1656f77c8617cec596044e3467301e4863f04b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ea8cd3ffda474356a83f0abb51cdb449113cf4e56ac9d06748aa56b57704768c5a8b7f62a01d0c404bc07cbb82552aca98e41c7d5f2b5c9830cd75e653812a
|
7
|
+
data.tar.gz: '069fe341466ce0eece2e7c147c4ca19ee394fe1daed3445529f1ccedc54baa3eab76fdd871eccf5479151b0bbece7848048bfceccce561118e1f164eab8c4b03'
|
data/README.md
CHANGED
@@ -51,33 +51,55 @@ humongous task of Tailwind CSS cleanup.
|
|
51
51
|
|
52
52
|
<hr/>
|
53
53
|
|
54
|
-
## Installation
|
54
|
+
## Quick Installation
|
55
55
|
|
56
56
|
```bash
|
57
57
|
# requires ruby 2.7 and above
|
58
58
|
$ gem install windclutter
|
59
59
|
|
60
|
-
$
|
60
|
+
$ cd your_project
|
61
|
+
$ windclutter use
|
61
62
|
```
|
62
63
|
|
63
64
|
## In Action
|
64
65
|
|
66
|
+
### 1. Single file analysis `-f`
|
67
|
+
```
|
68
|
+
$ windclutter analysis -f src/index.html
|
65
69
|
```
|
66
|
-
$ cd your_project
|
67
70
|
|
68
|
-
$ windclutter project use <your_project_name>
|
69
|
-
$ windclutter analysis file src/index.html
|
70
71
|
```
|
72
|
+
# output
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
74
|
+
Analysing src/index.html...
|
75
|
+
Done!
|
76
|
+
{
|
77
|
+
"flex" => 3,
|
78
|
+
"flex-col" => 3,
|
79
|
+
}
|
80
|
+
```
|
81
|
+
|
82
|
+
### 2. Project traversal `-t` (NEW)
|
83
|
+
|
84
|
+
Provide an option with your file extension, and let it do its magic! 🎉
|
85
|
+
|
86
|
+
```
|
87
|
+
$ windclutter analysis -t .html
|
76
88
|
```
|
77
89
|
|
78
90
|
```
|
79
91
|
# output
|
80
|
-
|
92
|
+
|
93
|
+
Analysing .html...
|
94
|
+
Traversed 22 .html file(s)... 🎉
|
95
|
+
{
|
96
|
+
"flex" => 44,
|
97
|
+
"flex-col" => 31,
|
98
|
+
"items-center" => 30,
|
99
|
+
"text-center" => 21,
|
100
|
+
"gap-2" => 14
|
101
|
+
}
|
102
|
+
...and 120 more
|
81
103
|
```
|
82
104
|
|
83
105
|
## Bleeding Edge!
|
data/lib/windclutter/analyser.rb
CHANGED
@@ -33,7 +33,7 @@ module WindClutter
|
|
33
33
|
collection = {}
|
34
34
|
scanned = FileHandler.scanners(suffix)
|
35
35
|
scanned.each do |file|
|
36
|
-
init(
|
36
|
+
init(FileHandler.read(file)).each { |k, v| collect(collection, k, v) }
|
37
37
|
end
|
38
38
|
|
39
39
|
sorted = sorter(collection)
|
data/lib/windclutter/cli/core.rb
CHANGED
@@ -31,6 +31,8 @@ module WindClutter
|
|
31
31
|
|
32
32
|
def call(*)
|
33
33
|
FileHandler.uninstall
|
34
|
+
|
35
|
+
puts 'Uninstall completed!'.green
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
@@ -41,7 +43,7 @@ module WindClutter
|
|
41
43
|
desc 'Debug the configuration of windclutter'
|
42
44
|
|
43
45
|
def call(*)
|
44
|
-
ap Config.wtf
|
46
|
+
ap Config.wtf?, indent: -2
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
@@ -57,8 +59,8 @@ module WindClutter
|
|
57
59
|
prefix.register 'config', Commands::Project::ConfigUpdate, aliases: ['-c']
|
58
60
|
end
|
59
61
|
|
60
|
-
register 'analysis', aliases: %w[a
|
61
|
-
prefix.register 'file', Commands::Analysis::FilePath, aliases: ['-
|
62
|
+
register 'analysis', aliases: %w[a] do |prefix|
|
63
|
+
prefix.register 'file', Commands::Analysis::FilePath, aliases: ['-f']
|
62
64
|
prefix.register 'traverse', Commands::Analysis::Traverse, aliases: ['-t']
|
63
65
|
end
|
64
66
|
|
@@ -32,8 +32,6 @@ module WindClutter
|
|
32
32
|
Dir['/tmp/windclutter'].each do |t|
|
33
33
|
FileUtils.rm_rf(t)
|
34
34
|
end
|
35
|
-
|
36
|
-
puts 'Uninstall completed!'.green
|
37
35
|
end
|
38
36
|
|
39
37
|
def self.create_project(value)
|
@@ -57,6 +55,10 @@ module WindClutter
|
|
57
55
|
def self.overwrite(file, content)
|
58
56
|
File.open(file, 'w') { |t| t.puts content }
|
59
57
|
end
|
58
|
+
|
59
|
+
def self.read(file)
|
60
|
+
File.open(file).read
|
61
|
+
end
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
data/lib/windclutter/version.rb
CHANGED
data/test/test_windclutter.rb
CHANGED
@@ -3,6 +3,13 @@
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'minitest/mock'
|
5
5
|
require 'mocha/minitest'
|
6
|
+
require 'mocha'
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter '/test/'
|
10
|
+
add_filter '/template/'
|
11
|
+
add_filter '/lib/windclutter/cli'
|
12
|
+
end
|
6
13
|
|
7
14
|
Dir['test/fixtures/**/*.rb'].sort.each { |f| require f.split('/')[1..].join('/') }
|
8
15
|
Dir['test/windclutter/**/*.rb'].sort.each { |f| require f.split('/')[1..].join('/') }
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'windclutter/analyser'
|
4
4
|
require 'windclutter/util/config'
|
5
|
+
require 'mocha/minitest'
|
5
6
|
|
6
7
|
class WindClutterAnalyserTest < Minitest::Test
|
7
8
|
include WindClutter
|
@@ -12,10 +13,18 @@ class WindClutterAnalyserTest < Minitest::Test
|
|
12
13
|
Config.any_instance.stubs(:exists?).returns(true)
|
13
14
|
YAML.stubs(:load_file).with('/tmp/windclutter/config.yml').returns(config_fixture)
|
14
15
|
|
15
|
-
# Config.expects(:read_project).with('test_project', 'class_key').returns('class')
|
16
16
|
assert_equal Analyser.init(dummy_content), expected_output
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_able_to_traverse
|
20
|
+
FileHandler.stubs(:scanners).with('.html').returns(['src/index.html'])
|
21
|
+
FileHandler.stubs(:read).returns(dummy_content)
|
22
|
+
Analyser.stubs(:init).returns(expected_output)
|
23
|
+
|
24
|
+
assert_equal Analyser.traverse('.html', 10),
|
25
|
+
[7, expected_output, 1]
|
26
|
+
end
|
27
|
+
|
19
28
|
private
|
20
29
|
|
21
30
|
def dummy_content
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'windclutter/util/file_handler'
|
4
|
+
|
5
|
+
class WindClutterUtilFileHandlerTest < Minitest::Test
|
6
|
+
include WindClutter::Util
|
7
|
+
|
8
|
+
def test_it_can_uninstall
|
9
|
+
FileUtils.stubs(:rm_rf).times(1)
|
10
|
+
FileHandler.uninstall
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_it_can_create_project
|
14
|
+
FileUtils.expects(:mkdir_p).with('/tmp/windclutter/projects/project_name').times(1)
|
15
|
+
FileHandler.create_project('project_name')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_it_can_list_projects
|
19
|
+
Dir.stubs(:[]).returns(['/tmp/windclutter/projects/project_name'])
|
20
|
+
assert_equal FileHandler.list_projects, ['project_name']
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_scanners
|
24
|
+
folder = '/project_folder'
|
25
|
+
Dir.stubs(:pwd).returns(folder)
|
26
|
+
Dir.stubs(:[]).returns(["#{folder}src/project_name/file.html"])
|
27
|
+
assert_equal FileHandler.scanners('.html'), ["#{folder}src/project_name/file.html"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_scan_one
|
31
|
+
Dir.stubs(:pwd).returns('/project_folder')
|
32
|
+
File.expects(:expand_path).with('src/index.html', '/project_folder').returns('/project_folder/src/index.html')
|
33
|
+
assert_equal FileHandler.scan_one('src/index.html'), '/project_folder/src/index.html'
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_overwrite
|
37
|
+
test_content = 'This is a test.'
|
38
|
+
|
39
|
+
file_mock = mock
|
40
|
+
file_mock.expects(:puts).with(test_content)
|
41
|
+
|
42
|
+
File.expects(:open).with('file.txt', 'w').yields(file_mock)
|
43
|
+
|
44
|
+
FileHandler.overwrite('file.txt', test_content)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_read
|
48
|
+
file_content = 'This is the file content.'
|
49
|
+
file_path = 'test_file.txt'
|
50
|
+
|
51
|
+
File.stubs(:open).with(file_path).returns(mock(read: file_content))
|
52
|
+
|
53
|
+
result = FileHandler.read(file_path)
|
54
|
+
|
55
|
+
assert_equal file_content, result
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: windclutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zafranudin Zafrin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Your buddy to skyrocket your development with TailwindCSS.
|
14
14
|
email: coffee@zafranudin.dev
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- test/windclutter/test_analyser.rb
|
40
40
|
- test/windclutter/test_processor.rb
|
41
41
|
- test/windclutter/util/test_config.rb
|
42
|
+
- test/windclutter/util/test_file_handler.rb
|
42
43
|
- test/windclutter/util/test_generator.rb
|
43
44
|
homepage: https://rubygems.org/gems/windclutter
|
44
45
|
licenses:
|