windclutter 0.0.13 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd8e4ea2e0a57f480acc24a90b019e7ad0b0733158ba96db81fd4cf3278197cb
4
- data.tar.gz: 9b59f08b8f5d70b1133dd6a008f99dbbb167b0e2d354a0dc30759ec12a933f80
3
+ metadata.gz: 2b9b31ca076defb624a2eb5519dac480abbdd0bb0f1556a00e8929112c45ba6d
4
+ data.tar.gz: 47fc0066c41bd1486da953b28f1656f77c8617cec596044e3467301e4863f04b
5
5
  SHA512:
6
- metadata.gz: 77609004646a587a69ac0122eb5de24df872588cf25ef7809d1db56c4e1ed4b2ad816ff694c0f9e6e817b939278a5ecdb98300b3d3bf07c0d3cb3cc3318dc2fb
7
- data.tar.gz: e8d3a3a8d97df76b0ce7c5815dcc0894aad76f14f20dc2f0ddc1444f9cddad1512bbb29743954bf40e61e385f4f85b00b2d7aa935f40a97723f7f69a794e370d
6
+ metadata.gz: 50ea8cd3ffda474356a83f0abb51cdb449113cf4e56ac9d06748aa56b57704768c5a8b7f62a01d0c404bc07cbb82552aca98e41c7d5f2b5c9830cd75e653812a
7
+ data.tar.gz: '069fe341466ce0eece2e7c147c4ca19ee394fe1daed3445529f1ccedc54baa3eab76fdd871eccf5479151b0bbece7848048bfceccce561118e1f164eab8c4b03'
@@ -33,7 +33,7 @@ module WindClutter
33
33
  collection = {}
34
34
  scanned = FileHandler.scanners(suffix)
35
35
  scanned.each do |file|
36
- init(File.open(file).read).each { |k, v| collect(collection, k, v) }
36
+ init(FileHandler.read(file)).each { |k, v| collect(collection, k, v) }
37
37
  end
38
38
 
39
39
  sorted = sorter(collection)
@@ -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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WindClutter
4
- VERSION = '0.0.13'
4
+ VERSION = '0.0.14'
5
5
  end
@@ -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.13
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-08 00:00:00.000000000 Z
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: