activeadmin 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- data/CHANGELOG.md +16 -0
- data/lib/active_admin/application.rb +1 -1
- data/lib/active_admin/reloader.rb +39 -10
- data/lib/active_admin/sass/css_loader.rb +1 -1
- data/lib/active_admin/version.rb +1 -1
- data/spec/unit/reloader_spec.rb +54 -10
- metadata +44 -41
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,22 @@
|
|
2
2
|
|
3
3
|
Nothing yet
|
4
4
|
|
5
|
+
## 0.3.4
|
6
|
+
|
7
|
+
2 commits by 2 authors
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* Fix reloading issues across operating systems.
|
12
|
+
* Fix issue where SASS was recompiling on every request. This can seriously
|
13
|
+
decrease the load time of applications when running in development mode.
|
14
|
+
Thanks @dhiemstra for tracking this one down!
|
15
|
+
|
16
|
+
### Contributors
|
17
|
+
|
18
|
+
* Danny Hiemstra
|
19
|
+
* Greg Bell
|
20
|
+
|
5
21
|
## 0.3.3
|
6
22
|
|
7
23
|
1 commit by 1 author
|
@@ -1,28 +1,57 @@
|
|
1
1
|
module ActiveAdmin
|
2
|
+
|
3
|
+
class FileUpdateChecker < ::ActiveSupport::FileUpdateChecker
|
4
|
+
|
5
|
+
# Over-ride the default #updated_at to support the deletion of files
|
6
|
+
def updated_at
|
7
|
+
paths.map { |path| File.mtime(path) rescue Time.now }.max
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
|
2
12
|
# Deals with reloading Active Admin on each request in
|
3
13
|
# development and once in production.
|
4
14
|
class Reloader
|
5
15
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
16
|
+
attr_reader :active_admin_app,
|
17
|
+
:rails_app,
|
18
|
+
:file_update_checker
|
19
|
+
|
20
|
+
# @param [ActiveAdmin::Application] app
|
21
|
+
# @param [String] rails_version The version of Rails we're using.
|
22
|
+
# We use this to switch between the correcrt Rails reloader class.
|
23
|
+
def initialize(rails_app, active_admin_app, rails_version)
|
24
|
+
@rails_app = rails_app
|
25
|
+
@active_admin_app = active_admin_app
|
11
26
|
@rails_version = rails_version.to_s
|
27
|
+
@file_update_checker = FileUpdateChecker.new(watched_paths) do
|
28
|
+
reload!
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def reload!
|
33
|
+
active_admin_app.unload!
|
34
|
+
rails_app.reload_routes!
|
35
|
+
file_update_checker.paths.clear
|
36
|
+
watched_paths.each{|path| file_update_checker.paths << path }
|
12
37
|
end
|
13
38
|
|
14
39
|
# Attach to Rails and perform the reload on each request.
|
15
40
|
def attach!
|
16
|
-
|
17
|
-
|
18
|
-
Rails.application.reload_routes!
|
19
|
-
end
|
41
|
+
# Bring the checker into local scope for the ruby block
|
42
|
+
checker = file_update_checker
|
20
43
|
|
21
44
|
reloader_class.to_prepare do
|
22
|
-
|
45
|
+
checker.execute_if_updated
|
23
46
|
end
|
24
47
|
end
|
25
48
|
|
49
|
+
def watched_paths
|
50
|
+
paths = active_admin_app.load_paths
|
51
|
+
active_admin_app.load_paths.each{|path| paths += Dir[File.join(path, "**", "*.rb")]}
|
52
|
+
paths
|
53
|
+
end
|
54
|
+
|
26
55
|
def reloader_class
|
27
56
|
if @rails_version[0..2] == '3.1'
|
28
57
|
ActionDispatch::Reloader
|
@@ -9,7 +9,7 @@ class Sass::Importers::Filesystem
|
|
9
9
|
|
10
10
|
# We want to ensure that all *.css.scss files are loaded as scss files
|
11
11
|
def extensions_with_css
|
12
|
-
extensions_without_css.merge('css
|
12
|
+
extensions_without_css.merge('{css.,}scss' => :scss)
|
13
13
|
end
|
14
14
|
alias_method_chain :extensions, :css
|
15
15
|
|
data/lib/active_admin/version.rb
CHANGED
data/spec/unit/reloader_spec.rb
CHANGED
@@ -16,21 +16,65 @@ end
|
|
16
16
|
|
17
17
|
describe ActiveAdmin::Reloader do
|
18
18
|
|
19
|
-
let(:
|
19
|
+
let(:rails_app){ mock(:reload_routes! => true)}
|
20
|
+
let(:mock_app){ mock(:load_paths => ["app/admin"], :unload! => true)}
|
21
|
+
let(:reloader){ ActiveAdmin::Reloader.new(rails_app, mock_app, "3.1.0")}
|
20
22
|
|
21
|
-
it "should
|
22
|
-
|
23
|
-
|
23
|
+
it "should initialize a new file update checker" do
|
24
|
+
ActiveSupport::FileUpdateChecker.should_receive(:new).with(mock_app.load_paths).and_return(mock(:execute_if_updated => true))
|
25
|
+
ActiveAdmin::Reloader.new(rails_app, mock_app, '3.1.0').attach!
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
describe "#reloader_class" do
|
29
|
+
it "should use ActionDispatch::Reloader if rails 3.1" do
|
30
|
+
reloader = ActiveAdmin::Reloader.new rails_app, mock_app, '3.1.0'
|
31
|
+
reloader.reloader_class.should == ActionDispatch::Reloader
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should use ActionDispatch::Callbacks if rails 3.0" do
|
35
|
+
reloader = ActiveAdmin::Reloader.new rails_app, mock_app, '3.0.0'
|
36
|
+
reloader.reloader_class.should == ActionDispatch::Callbacks
|
37
|
+
end
|
29
38
|
end
|
30
39
|
|
31
|
-
|
32
|
-
|
33
|
-
|
40
|
+
describe "#reload!" do
|
41
|
+
|
42
|
+
it "should unload the active admin app" do
|
43
|
+
mock_app.should_receive(:unload!)
|
44
|
+
reloader.reload!
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should reload the rails app routes" do
|
48
|
+
rails_app.should_receive(:reload_routes!)
|
49
|
+
reloader.reload!
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should reset the files within the file_update_checker' do
|
53
|
+
reloader.file_update_checker.paths.should_receive(:clear)
|
54
|
+
reloader.file_update_checker.paths.should_receive(:<<).with("app/admin")
|
55
|
+
reloader.reload!
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#watched_paths" do
|
61
|
+
let(:mock_app){ ActiveAdmin::Application.new }
|
62
|
+
let(:admin_path){ File.join(Rails.root, "app", "admin") }
|
63
|
+
|
64
|
+
before do
|
65
|
+
mock_app.load_paths = [admin_path]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return the load path directories" do
|
69
|
+
reloader.watched_paths.should include(admin_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should include all files in the directory" do
|
73
|
+
root = Rails.root + "/app/admin"
|
74
|
+
reloader.watched_paths.should include(*Dir["#{admin_path}/**/*.rb"])
|
75
|
+
end
|
76
|
+
|
34
77
|
end
|
35
78
|
|
79
|
+
|
36
80
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 3
|
9
|
-
-
|
10
|
-
|
8
|
+
- 4
|
9
|
+
segments_generated: true
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Greg Bell
|
@@ -15,133 +15,134 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-08 00:00:00 -08:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
type: :runtime
|
22
|
+
name: rails
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 7
|
29
28
|
segments:
|
30
29
|
- 3
|
31
30
|
- 0
|
32
31
|
- 0
|
32
|
+
segments_generated: true
|
33
33
|
version: 3.0.0
|
34
|
-
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
35
36
|
version_requirements: *id001
|
36
37
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
38
|
-
type: :runtime
|
38
|
+
name: meta_search
|
39
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 63
|
45
44
|
segments:
|
46
45
|
- 0
|
47
46
|
- 9
|
48
47
|
- 2
|
48
|
+
segments_generated: true
|
49
49
|
version: 0.9.2
|
50
|
-
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
51
52
|
version_requirements: *id002
|
52
53
|
- !ruby/object:Gem::Dependency
|
53
|
-
|
54
|
-
type: :runtime
|
54
|
+
name: devise
|
55
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
hash: 23
|
61
60
|
segments:
|
62
61
|
- 1
|
63
62
|
- 1
|
64
63
|
- 2
|
64
|
+
segments_generated: true
|
65
65
|
version: 1.1.2
|
66
|
-
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
67
68
|
version_requirements: *id003
|
68
69
|
- !ruby/object:Gem::Dependency
|
69
|
-
|
70
|
-
type: :runtime
|
70
|
+
name: formtastic
|
71
71
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - <
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 15
|
77
76
|
segments:
|
78
77
|
- 2
|
79
78
|
- 0
|
80
79
|
- 0
|
80
|
+
segments_generated: true
|
81
81
|
version: 2.0.0
|
82
|
-
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
83
84
|
version_requirements: *id004
|
84
85
|
- !ruby/object:Gem::Dependency
|
85
|
-
|
86
|
-
type: :runtime
|
86
|
+
name: inherited_resources
|
87
87
|
requirement: &id005 !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
90
90
|
- - <
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 27
|
93
92
|
segments:
|
94
93
|
- 1
|
95
94
|
- 3
|
96
95
|
- 0
|
96
|
+
segments_generated: true
|
97
97
|
version: 1.3.0
|
98
|
-
|
98
|
+
type: :runtime
|
99
|
+
prerelease: false
|
99
100
|
version_requirements: *id005
|
100
101
|
- !ruby/object:Gem::Dependency
|
101
|
-
|
102
|
-
type: :runtime
|
102
|
+
name: kaminari
|
103
103
|
requirement: &id006 !ruby/object:Gem::Requirement
|
104
104
|
none: false
|
105
105
|
requirements:
|
106
106
|
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
hash: 39
|
109
108
|
segments:
|
110
109
|
- 0
|
111
110
|
- 12
|
112
111
|
- 4
|
112
|
+
segments_generated: true
|
113
113
|
version: 0.12.4
|
114
|
-
|
114
|
+
type: :runtime
|
115
|
+
prerelease: false
|
115
116
|
version_requirements: *id006
|
116
117
|
- !ruby/object:Gem::Dependency
|
117
|
-
|
118
|
-
type: :runtime
|
118
|
+
name: sass
|
119
119
|
requirement: &id007 !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
hash: 3
|
125
124
|
segments:
|
126
125
|
- 3
|
127
126
|
- 1
|
128
127
|
- 0
|
128
|
+
segments_generated: true
|
129
129
|
version: 3.1.0
|
130
|
-
|
130
|
+
type: :runtime
|
131
|
+
prerelease: false
|
131
132
|
version_requirements: *id007
|
132
133
|
- !ruby/object:Gem::Dependency
|
133
|
-
|
134
|
-
type: :runtime
|
134
|
+
name: fastercsv
|
135
135
|
requirement: &id008 !ruby/object:Gem::Requirement
|
136
136
|
none: false
|
137
137
|
requirements:
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
hash: 3
|
141
140
|
segments:
|
142
141
|
- 0
|
142
|
+
segments_generated: true
|
143
143
|
version: "0"
|
144
|
-
|
144
|
+
type: :runtime
|
145
|
+
prerelease: false
|
145
146
|
version_requirements: *id008
|
146
147
|
description: The administration framework for Ruby on Rails.
|
147
148
|
email:
|
@@ -490,6 +491,7 @@ files:
|
|
490
491
|
- tasks/docs.rake
|
491
492
|
- tasks/test.rake
|
492
493
|
- tasks/yard.rake
|
494
|
+
has_rdoc: true
|
493
495
|
homepage: http://activeadmin.info
|
494
496
|
licenses: []
|
495
497
|
|
@@ -503,23 +505,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
503
505
|
requirements:
|
504
506
|
- - ">="
|
505
507
|
- !ruby/object:Gem::Version
|
506
|
-
hash:
|
508
|
+
hash: 2097501069627714187
|
507
509
|
segments:
|
508
510
|
- 0
|
511
|
+
segments_generated: true
|
509
512
|
version: "0"
|
510
513
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
511
514
|
none: false
|
512
515
|
requirements:
|
513
516
|
- - ">="
|
514
517
|
- !ruby/object:Gem::Version
|
515
|
-
hash:
|
518
|
+
hash: 2097501069627714187
|
516
519
|
segments:
|
517
520
|
- 0
|
521
|
+
segments_generated: true
|
518
522
|
version: "0"
|
519
523
|
requirements: []
|
520
524
|
|
521
525
|
rubyforge_project:
|
522
|
-
rubygems_version: 1.
|
526
|
+
rubygems_version: 1.3.7
|
523
527
|
signing_key:
|
524
528
|
specification_version: 3
|
525
529
|
summary: The administration framework for Ruby on Rails.
|
@@ -642,4 +646,3 @@ test_files:
|
|
642
646
|
- spec/unit/views/components/table_for_spec.rb
|
643
647
|
- spec/unit/views/pages/layout_spec.rb
|
644
648
|
- spec/unit/views/tabbed_navigation_spec.rb
|
645
|
-
has_rdoc:
|