minitest-filesystem 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db73e422e4760423081870612b857aaa490430d8
4
- data.tar.gz: 77e25a5ca198b8b23706db1c57f182a123446eae
3
+ metadata.gz: a1f50869c9e1a8567409b58a165057b3e23766bc
4
+ data.tar.gz: f51c45d5eb02b7efa117ba22ae50086750379e04
5
5
  SHA512:
6
- metadata.gz: 5e58da2037fbc107914fdfbc7787c7040e203ce0b7081c79e1793050aacbdc20a84471e90f70f49362853e605cedf6e008626ba8979dec746729f662978a20cc
7
- data.tar.gz: d829f92388c3762ddadbf0e82342b72f8e21ab8ada64ca7f9f81334f4fb2cda0e3c1961b958c52bc34b6528ba1c7d6d85f845329f5fb6dca80a10b508d692341
6
+ metadata.gz: e482bc5bfe18c51fcc4288d57462f5927b9c6378b84e291d99eadd425731332beddaa6674ad66ecc021ba7f522d4e1c91e3922fe0f01a99b8c875da763e13de3
7
+ data.tar.gz: 5f4e68d4dc3563af02e74348e69c2fbb2c2c9ab647d3ccc8e338c54c6d69a95beea86209de2abeb3bf71492b950c847edd783a86ffd1d2f66849055a315a87c7
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -86,6 +86,10 @@ directories inside `root_dir` that the matcher won't care about).
86
86
 
87
87
  ## Changelog
88
88
 
89
+ ### 1.1.1
90
+
91
+ * Minor refactorings and project infrastructure updates.
92
+
89
93
  ### 1.1.0
90
94
 
91
95
  * Add support for testing symbolic links
data/Rakefile CHANGED
@@ -9,4 +9,14 @@ Rake::TestTask.new do |t|
9
9
  t.verbose = true
10
10
  end
11
11
 
12
+ desc "Analyze code duplication"
13
+ task :flay do
14
+ system "flay lib/**/*.rb"
15
+ end
16
+
17
+ desc "Analyze code complexity"
18
+ task :flog do
19
+ system "find lib -name \*.rb | xargs flog"
20
+ end
21
+
12
22
  task :default => :test
@@ -10,17 +10,17 @@ module Minitest
10
10
  end
11
11
 
12
12
  def file(file)
13
- entry(file, :file) && is_a?(file, :file)
13
+ exists?(file, :file)
14
14
  end
15
15
 
16
16
  def link(link, target=nil)
17
- entry(link, :symlink) && is_a?(link, :symlink) && is_target_correct?(link, target)
17
+ exists?(link, :symlink) && is_target_correct?(link, target)
18
18
  end
19
19
 
20
20
  def dir(dir, &block)
21
21
  matcher = self.class.new(@actual_tree.expand_path(dir), &block) if block_given?
22
22
 
23
- entry(dir, :directory) && is_a?(dir, :directory) && subtree(matcher)
23
+ exists?(dir, :directory) && subtree(matcher)
24
24
  end
25
25
 
26
26
  def match_found?
@@ -34,17 +34,33 @@ module Minitest
34
34
 
35
35
  private
36
36
 
37
+ # Checks existance of specified entry.
38
+ # Existance is defined both in terms of presence and of being of the
39
+ # right type (e.g. a file being a file and not a directory)
40
+ def exists?(entry, kind=:entry)
41
+ entry(entry, kind) && is_a?(entry, kind)
42
+ end
43
+
44
+ # Checks if an entry with given name exists.
37
45
  def entry(entry, kind=:entry)
38
46
  update_matching_status(
39
47
  @actual_tree.include?(entry),
40
48
  not_found_msg_for(entry, kind))
41
49
  end
42
50
 
51
+ # Checks if a specific entry (supposed to exist) is of a given kind.
52
+ def is_a?(entry, kind)
53
+ update_matching_status(
54
+ @actual_tree.is_a?(entry, kind),
55
+ mismatch_msg_for(entry, kind))
56
+ end
57
+
58
+ # Checks the target of a symbolic link.
43
59
  def is_target_correct?(link, target)
44
60
  return true unless target
45
61
 
46
62
  update_matching_status(
47
- @actual_tree.expand_path(target) == follow_link(@actual_tree.expand_path(link)),
63
+ @actual_tree.has_target?(link, target),
48
64
  link_target_mismatch_msg_for(link, target))
49
65
  end
50
66
 
@@ -52,16 +68,6 @@ module Minitest
52
68
  update_matching_status(matcher.match_found?, matcher.message) if matcher
53
69
  end
54
70
 
55
- def follow_link(link)
56
- Pathname.new(File.readlink(link))
57
- end
58
-
59
- def is_a?(entry, kind)
60
- update_matching_status(
61
- @actual_tree.is_a?(entry, kind),
62
- mismatch_msg_for(entry, kind))
63
- end
64
-
65
71
  def update_matching_status(check, msg)
66
72
  @is_matching = @is_matching && check
67
73
  set_failure_msg(msg) unless @is_matching
@@ -78,7 +84,7 @@ module Minitest
78
84
  end
79
85
 
80
86
  def link_target_mismatch_msg_for(link, target)
81
- "Expected `#{link}` to point to `#{target}`, but it pointed to #{File.readlink(@actual_tree.expand_path(link))}"
87
+ "Expected `#{link}` to point to `#{target}`, but it pointed to #{@actual_tree.follow_link(link)}"
82
88
  end
83
89
 
84
90
  def set_failure_msg(msg)
@@ -100,11 +106,19 @@ module Minitest
100
106
  def is_a?(entry, kind)
101
107
  (expand_path entry).send("#{kind}?")
102
108
  end
109
+
110
+ def has_target?(entry, target)
111
+ expand_path(target) == follow_link(entry)
112
+ end
103
113
 
104
114
  def expand_path(file)
105
115
  @root + Pathname.new(file)
106
116
  end
107
117
 
118
+ def follow_link(link)
119
+ Pathname.new(File.readlink(expand_path(link)))
120
+ end
121
+
108
122
  private
109
123
 
110
124
  def expand_tree_under(dir)
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Filesystem
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -27,6 +27,8 @@ Gem::Specification.new do |gem|
27
27
  gem.add_development_dependency "rake"
28
28
  gem.add_development_dependency "minitest"
29
29
  gem.add_development_dependency "coveralls"
30
+ gem.add_development_dependency "flog"
31
+ gem.add_development_dependency "flay"
30
32
 
31
33
  gem.signing_key = Pathname.new(signing_key_file).expand_path if signing_key_file
32
34
  gem.cert_chain = ["rubygems-stefanozanella.crt"]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-filesystem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Zanella
@@ -29,7 +29,7 @@ cert_chain:
29
29
  RigBD0E3/t/ABjCXkmqwp5gnAZmP8JiVUkn8rp5E0FXvC8T7nsPs2TW/TAmUV6rN
30
30
  hK25FX8YWgT9fD9y3PpWjiYcrCo=
31
31
  -----END CERTIFICATE-----
32
- date: 2013-09-04 00:00:00.000000000 Z
32
+ date: 2013-09-06 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: bundler
@@ -87,6 +87,34 @@ dependencies:
87
87
  - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
+ - !ruby/object:Gem::Dependency
91
+ name: flog
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ - !ruby/object:Gem::Dependency
105
+ name: flay
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
90
118
  description: Minitest exstension to check filesystem contents
91
119
  email:
92
120
  - zanella.stefano@gmail.com
metadata.gz.sig CHANGED
Binary file