require_pattern 1.0 → 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: d5b24c83c3d4175da64ffc63b964fbbee9410c38
4
- data.tar.gz: 386c726201430bf9c08d13dbf2e59d7f3283dbec
3
+ metadata.gz: 306c0f36d5cf455c9a918f67e8aa751f46f4e674
4
+ data.tar.gz: d408e62fdfe7ed191913483a28b8e6d7ec8c60ff
5
5
  SHA512:
6
- metadata.gz: f7d74cab91a759eb53b0870a7f06b59564d09d9164747f86c8d1ba33dfd8a3f4e131fa2f5ce2882ffbb32cbcb33235921dfdc9932ad02b0a20248231c3ef06ae
7
- data.tar.gz: c7b9a4283358588402e3a9c3f5d1a28475c61d6e61b3fa8486b9a49e77eb12187f2ac209f1b0723051d822688e5d7c014a3d125b567ece2803fa4c85c8641454
6
+ metadata.gz: d5d518fe6dc8f76624d8b97606a0ca13eafb95d7dde695dfa69cf6dbb247c830217c2da68eeddd0a8e7a68b923561327f35dae39e93f6435bc6061ac6638b712
7
+ data.tar.gz: 8be2a0b4ff662265a041c73d7c4ed97ac8fdb484b7fc0a971e10c5fd6599cfd396c7ff9534553069e978fbea470fd7ec2739fcbcab4b01e73b20ec590ba5df9a
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -22,4 +22,12 @@ Usage is relatively intuitive. Simply call either `require_pattern` or `require_
22
22
  require_pattern 'lib/**/*.rb', 'models/**/*.rb'
23
23
  ```
24
24
 
25
- Any files that refuse to load will be reported to STDERR with backtrace information.
25
+ Any files that refuse to load will be reported to STDERR with backtrace information.
26
+
27
+
28
+ Tests
29
+ -----
30
+
31
+ ```bash
32
+ mtest spec
33
+ ```
@@ -0,0 +1,11 @@
1
+ module ReqPat
2
+ class Coloring
3
+ def self.red(msg)
4
+ "\033[31m#{msg}\033[0m\n"
5
+ end
6
+
7
+ def self.yellow(msg)
8
+ "\033[33m#{msg}\033[0m\n"
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,6 @@
1
- require 'term-colorizer'
1
+ require 'coloring'
2
2
 
3
3
  module Kernel
4
-
5
4
  # Requires all files matching the glob patterns provided.
6
5
  # If a file fails to load, it keeps retrying until all remaining files fail to load, in which case the exception is
7
6
  # output to STDERR for each failed file.
@@ -21,17 +20,20 @@ module Kernel
21
20
  if require_map.empty?
22
21
  break loaded
23
22
  elsif remaining.nil?
24
- STDERR.puts "\nSome files failed:".red
25
- require_map.each { |file, e| STDERR.puts " #{file}: ".red + "#{e.backtrace[0]} #{e}".yellow}
23
+ STDERR.puts ReqPat::Coloring.red("\nSome files failed:")
24
+ require_map.each { |file, e| STDERR.puts
25
+ ReqPat::Coloring.red(" #{file}: ") +
26
+ ReqPat::Coloring.yellow("#{e.backtrace[0]} #{e}")
27
+ }
26
28
  STDERR.puts
27
- raise LoadError, "One or more files failed to load. See STDERR output for details."
29
+ raise LoadError, "One or more files failed to load. See STDERR output for details."
28
30
  end
29
31
  end
30
32
  end
31
-
33
+
32
34
  def require_relative_pattern(*patterns)
33
35
  caller_path = caller_locations(1,1)[0].path
34
36
  patterns.map! { |pattern| File.join(File.dirname(caller_path), pattern) }
35
37
  require_pattern(*patterns)
36
38
  end
37
- end
39
+ end
@@ -1,6 +1,6 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
2
 
3
- Gem::Specification.new 'require_pattern', '1.0' do |s|
3
+ Gem::Specification.new 'require_pattern', '1.1' do |s|
4
4
  s.summary = 'Requires files based on a pattern in a robust and optimistic manner.'
5
5
  s.authors = ['Tom Wardrop']
6
6
  s.email = 'tom@tomwardrop.com'
@@ -11,6 +11,6 @@ Gem::Specification.new 'require_pattern', '1.0' do |s|
11
11
  s.rdoc_options = %w[--line-numbers --inline-source --title Scorched --encoding=UTF-8]
12
12
 
13
13
  s.required_ruby_version = '>= 1.9.3'
14
- s.add_dependency 'term-colorizer'
15
- s.add_development_dependency 'rspec'
16
- end
14
+ s.add_development_dependency 'maxitest'
15
+ s.add_development_dependency 'mocha'
16
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,43 +1,48 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+ require "maxitest/autorun"
4
+ require "mocha/mini_test"
5
+
1
6
  require_relative '../lib/require_pattern'
2
7
  Dir.chdir File.expand_path('../dummy', __FILE__)
3
8
 
4
9
  describe 'require_pattern' do
5
10
  it "requires relative to the current working directory by default" do
6
11
  require_pattern 'colors/*.rb'
7
- $red.should be_true
8
- $green.should be_true
12
+ $red.must_equal true
13
+ $green.must_equal true
9
14
  end
10
15
 
11
16
  it "can require relative to the current file" do
12
17
  require_relative_pattern 'dummy/sizes/*.rb'
13
- $tall.should be_true
14
- $short.should be_true
18
+ $tall.must_equal true
19
+ $short.must_equal true
15
20
  end
16
-
21
+
17
22
  it "overcomes file ordering issues by intelligently retrying" do
18
23
  require_relative_pattern 'dummy/dependancies/*.rb'
19
24
  Golf
20
25
  end
21
-
26
+
22
27
  it "reports true only if a file was loaded" do
23
- require_pattern('loaded.rb').should be_true
24
- require_pattern('loaded.rb').should be_false
28
+ require_pattern('loaded.rb').must_equal true
29
+ require_pattern('loaded.rb').wont_equal true
25
30
  end
26
-
31
+
27
32
  it "can take multiple patterns" do
28
- require_pattern('colors/*.rb', 'shapes/*.rb').should be_true
29
- $circle.should be_true
30
- $square.should be_true
33
+ require_pattern('colors/*.rb', 'shapes/*.rb').must_equal true
34
+ assert $circle
35
+ assert $square
31
36
  end
32
-
37
+
33
38
  it "outputs to STDERR on failure" do
34
- STDERR.should_receive(:puts).at_least(2).times
35
- expect {
39
+ STDERR.expects(:puts).at_least(2)
40
+ lambda {
36
41
  require_pattern 'bad.*'
37
- }.to raise_error(LoadError)
42
+ }.must_raise LoadError
38
43
  end
39
-
44
+
40
45
  it "doesn't care if it doesn't match any files" do
41
- require_pattern('good luck matching this').should be_false
46
+ require_pattern('good luck matching this').must_equal false
42
47
  end
43
- end
48
+ end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_pattern
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Wardrop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-12 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: term-colorizer
14
+ name: maxitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- type: :runtime
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: mocha
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description:
@@ -47,6 +47,7 @@ files:
47
47
  - Gemfile
48
48
  - LICENSE
49
49
  - README.md
50
+ - lib/coloring.rb
50
51
  - lib/require_pattern.rb
51
52
  - require_pattern.gemspec
52
53
  - spec/dummy/bad.rb
@@ -61,35 +62,34 @@ files:
61
62
  - spec/dummy/shapes/square.rb
62
63
  - spec/dummy/sizes/short.rb
63
64
  - spec/dummy/sizes/tall.rb
64
- - spec/spec.rb
65
+ - spec/require_pattern_test.rb
65
66
  homepage: http://github.com/wardrop/RequirePattern
66
67
  licenses:
67
68
  - MIT
68
69
  metadata: {}
69
70
  post_install_message:
70
71
  rdoc_options:
71
- - --line-numbers
72
- - --inline-source
73
- - --title
72
+ - "--line-numbers"
73
+ - "--inline-source"
74
+ - "--title"
74
75
  - Scorched
75
- - --encoding=UTF-8
76
+ - "--encoding=UTF-8"
76
77
  require_paths:
77
78
  - lib
78
79
  required_ruby_version: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - '>='
81
+ - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: 1.9.3
83
84
  required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  requirements:
85
- - - '>='
86
+ - - ">="
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
90
  rubyforge_project:
90
- rubygems_version: 2.1.11
91
+ rubygems_version: 2.2.2
91
92
  signing_key:
92
93
  specification_version: 4
93
94
  summary: Requires files based on a pattern in a robust and optimistic manner.
94
- test_files:
95
- - spec/spec.rb
95
+ test_files: []