conscious_concern 1.0.0 → 1.0.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: 09274c5c2bfd29266342c8d7fe175475dd33b9bd
4
- data.tar.gz: c800ab2890c4c61a322e9ddfdb19dcf03901b84b
3
+ metadata.gz: 71b18d40b670b9cf4739fdde84fe8fcf85b92f2f
4
+ data.tar.gz: e2e5652dcd519f9f4db51c0da7c43235b250957c
5
5
  SHA512:
6
- metadata.gz: d36abdb2c800622d66163a3906c764a0233864f9f0d463c562bf77fef7f9141e64b2794b9fa8dbedc7c5a1bab49b37ffeca6d81437be642c7b6c8ad8149dbeed
7
- data.tar.gz: 4c8c86e86cfcbf711858181f9c09e436ac04a82d96a367c278010920e59d929f3c4553ae7621092fc7b2428bc5a31941b532fb7f6c0012e31ad814fb7821405a
6
+ metadata.gz: c8608c78ee0ffb5f40542867cce0b34de150d5b60e256defef212c8396863ea9f681b5c26ca61a658cb161a16b47c80971111da2dd16af4ab806750274fdc401
7
+ data.tar.gz: e322e2de45911414c6e329d7b8ff2b4469a73806908b2784545511ed8f121549485d5286e77c79b1d36d69476d7154a864fdcbdde2e5fc61a3e5b29645936a8e
@@ -3,32 +3,35 @@ module ConsciousConcern
3
3
  # Recursively finds Ruby Classes in a given directory.
4
4
  #
5
5
  class EagerLoader
6
- DEBUG = false
6
+ class_attribute :debug
7
7
 
8
8
  def self.load_classes_in_rails_dir(name)
9
9
  rails = Object.const_defined?('Rails') ? 'Rails'.constantize : nil
10
10
  unless rails && rails.root
11
- puts 'no initialized Rails application' if DEBUG
11
+ puts 'no initialized Rails application' if debug
12
12
  return false
13
13
  end
14
- load_classes_in(rails.root.join('app', name))
14
+ load_classes_in_dir(rails.root.join('app', name))
15
15
  end
16
16
 
17
- def self.load_classes_in(dir)
17
+ def self.load_classes_in_dir(dir)
18
+ unless File.exist?(dir)
19
+ puts "eager-loading directory #{dir} not found" if debug
20
+ return false
21
+ end
18
22
  Dir.foreach(dir) do |entry|
19
- if entry.end_with?('.rb')
20
- class_from_filename(entry)
21
- elsif File.directory?(dir.join(entry)) && entry[0] != '.'
22
- load_classes_in(dir.join(entry))
23
- end
23
+ path = File.join(dir, entry)
24
+ load_class_at_path(path) if path.end_with?('.rb')
25
+ load_classes_in_dir(path) if File.directory?(path) && entry[0] != '.'
24
26
  end
25
27
  end
26
28
 
27
- def self.class_from_filename(filename)
28
- clazz = filename[0..-4].classify.constantize
29
- puts "eager loaded class '#{clazz}'" if DEBUG
30
- rescue => e
31
- puts e.message if DEBUG
29
+ def self.load_class_at_path(path)
30
+ require path
31
+ clazz = File.basename(path, '.*').classify.constantize
32
+ puts "eager loaded class '#{clazz}'" if debug
33
+ rescue LoadError, StandardError => e
34
+ puts e.message if debug
32
35
  end
33
36
  end
34
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conscious_concern
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janosch Müller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2015-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,8 +24,92 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4'
27
- description: ConsciousConcern is a decorator for ActiveSupport::Concernthat adds several
28
- metaprogramming features.
27
+ - !ruby/object:Gem::Dependency
28
+ name: codeclimate-test-reporter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.3'
111
+ description: ConsciousConcern is a decorator for ActiveSupport::Concern that adds
112
+ several metaprogramming features.
29
113
  email:
30
114
  - janosch84@gmail.com
31
115
  executables: []
@@ -54,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
138
  version: '0'
55
139
  requirements: []
56
140
  rubyforge_project:
57
- rubygems_version: 2.4.5
141
+ rubygems_version: 2.4.8
58
142
  signing_key:
59
143
  specification_version: 4
60
144
  summary: Enhances ActiveSupport::Concern