class_loader 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake_ext'
2
2
 
3
3
  project(
4
4
  name: "class_loader",
5
- version: "0.4.1",
5
+ version: "0.4.2",
6
6
  summary: "Automatically finds, loads and reloads Classes",
7
7
 
8
8
  author: "Alexey Petrushin",
@@ -23,7 +23,7 @@ module ClassLoader
23
23
  end
24
24
  end
25
25
 
26
- def each_changed_class &block
26
+ def each_changed_class &block
27
27
  adapters.each{|a| a.each_changed_class &block}
28
28
  end
29
29
 
@@ -161,8 +161,8 @@ module ClassLoader
161
161
  protected
162
162
  def default_adapter
163
163
  adapter = ChainedAdapter.new
164
- adapter.adapters << FileSystemAdapter.new(CamelCaseTranslator)
165
164
  adapter.adapters << FileSystemAdapter.new(UnderscoredTranslator)
165
+ adapter.adapters << FileSystemAdapter.new(CamelCaseTranslator)
166
166
  adapter
167
167
  end
168
168
 
@@ -2,7 +2,7 @@ module ClassLoader
2
2
  class FileSystemAdapter
3
3
  attr_reader :translator
4
4
 
5
- def initialize class_name_translator
5
+ def initialize class_name_translator
6
6
  @translator = class_name_translator
7
7
  @paths, @watched_paths, @file_name_cache = [], [], {}
8
8
  @watched_files, @first_check = {}, true
@@ -47,8 +47,7 @@ module ClassLoader
47
47
 
48
48
  nil
49
49
  end
50
-
51
- @file_name_cache[class_name] = [file_path, true]
50
+ @file_name_cache[class_name] = [file_path, true]
52
51
  end
53
52
  file_path
54
53
  end
@@ -83,10 +82,10 @@ module ClassLoader
83
82
  end
84
83
 
85
84
  def each_changed_class &block
86
- if @first_check
85
+ unless @first_check == @watched_paths
86
+ @first_check = @watched_paths.clone
87
87
  each_watched_file{|file_path, file_name| remember_file file_path}
88
- @first_check = false
89
- else
88
+ else
90
89
  each_watched_file do |file_path, file_name|
91
90
  if file_changed? file_path
92
91
  remember_file file_path
@@ -94,7 +93,7 @@ module ClassLoader
94
93
  normalized_name = file_name.sub(/\.rb$/, "")
95
94
  block.call translator.to_class_name(normalized_name)
96
95
  end
97
- end
96
+ end
98
97
  end
99
98
  end
100
99
 
@@ -122,6 +121,10 @@ module ClassLoader
122
121
  end
123
122
  end
124
123
 
124
+ def inspect
125
+ "FileSystemAdapter (#{@paths.join(', ')})"
126
+ end
127
+
125
128
  protected
126
129
  attr_reader :paths, :watched_paths, :watcher, :watched_files
127
130
 
data/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- # Automatically finds and loads classes for your Ruby App
1
+ # Automatically finds and loads classes for Your Ruby App
2
2
 
3
3
  ## Overview
4
4
  There's only one method - :autoload_dir, kind of turbocharged :autoload, it understands namespaces, figure out dependencies and can watch and reload changed files.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: class_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-04-10 00:00:00.000000000 +04:00
12
+ date: 2011-05-19 00:00:00.000000000 +04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: