fume 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Gemfile +4 -0
- data/Gemfile.lock +105 -0
- data/{README → README.md} +0 -0
- data/Rakefile +4 -28
- data/VERSION +1 -0
- data/fume.gemspec +36 -119
- data/lib/fume.rb +15 -16
- data/lib/fume/authlogic.rb +8 -2
- data/lib/fume/cancan.rb +20 -11
- data/lib/fume/rails_ext.rb +25 -14
- data/lib/fume/railtie.rb +15 -0
- data/lib/fume/simple_theme.rb +31 -23
- metadata +96 -89
- data/VERSION.yml +0 -5
- data/depends.rb +0 -30
- data/lib/fume/daemon.rb +0 -86
- data/lib/fume/formtastic.rb +0 -22
- data/lib/fume/logger_support.rb +0 -22
- data/lib/fume/searchlogic.rb +0 -46
- data/lib/fume/smart_logger.rb +0 -20
- data/rails/init.rb +0 -8
- data/spec/fume/daemon_spec.rb +0 -91
- data/spec/fume/logger_support_spec.rb +0 -18
- data/spec/fume/smart_logger_spec.rb +0 -32
- data/spec/rails_stub.rb +0 -9
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fume (0.6.0)
|
5
|
+
addressable (~> 2.2.6)
|
6
|
+
authlogic (= 3.0.2)
|
7
|
+
cancan (= 1.6.4)
|
8
|
+
formtastic (= 1.2.3)
|
9
|
+
hashie (~> 1.0.0)
|
10
|
+
meta_search (= 1.0.5)
|
11
|
+
rails (= 3.0.7)
|
12
|
+
rake (~> 0.8.7)
|
13
|
+
symbolize (= 3.1.3)
|
14
|
+
timeliness (~> 0.3.4)
|
15
|
+
|
16
|
+
GEM
|
17
|
+
remote: http://rubygems.org/
|
18
|
+
specs:
|
19
|
+
abstract (1.0.0)
|
20
|
+
actionmailer (3.0.7)
|
21
|
+
actionpack (= 3.0.7)
|
22
|
+
mail (~> 2.2.15)
|
23
|
+
actionpack (3.0.7)
|
24
|
+
activemodel (= 3.0.7)
|
25
|
+
activesupport (= 3.0.7)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
erubis (~> 2.6.6)
|
28
|
+
i18n (~> 0.5.0)
|
29
|
+
rack (~> 1.2.1)
|
30
|
+
rack-mount (~> 0.6.14)
|
31
|
+
rack-test (~> 0.5.7)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activemodel (3.0.7)
|
34
|
+
activesupport (= 3.0.7)
|
35
|
+
builder (~> 2.1.2)
|
36
|
+
i18n (~> 0.5.0)
|
37
|
+
activerecord (3.0.7)
|
38
|
+
activemodel (= 3.0.7)
|
39
|
+
activesupport (= 3.0.7)
|
40
|
+
arel (~> 2.0.2)
|
41
|
+
tzinfo (~> 0.3.23)
|
42
|
+
activeresource (3.0.7)
|
43
|
+
activemodel (= 3.0.7)
|
44
|
+
activesupport (= 3.0.7)
|
45
|
+
activesupport (3.0.7)
|
46
|
+
addressable (2.2.6)
|
47
|
+
arel (2.0.10)
|
48
|
+
authlogic (3.0.2)
|
49
|
+
activerecord (~> 3.0.7)
|
50
|
+
activerecord (~> 3.0.7)
|
51
|
+
builder (2.1.2)
|
52
|
+
cancan (1.6.4)
|
53
|
+
erubis (2.6.6)
|
54
|
+
abstract (>= 1.0.0)
|
55
|
+
formtastic (1.2.3)
|
56
|
+
actionpack (>= 2.3.7)
|
57
|
+
activesupport (>= 2.3.7)
|
58
|
+
i18n (~> 0.4)
|
59
|
+
hashie (1.0.0)
|
60
|
+
i18n (0.5.0)
|
61
|
+
mail (2.2.19)
|
62
|
+
activesupport (>= 2.3.6)
|
63
|
+
i18n (>= 0.4.0)
|
64
|
+
mime-types (~> 1.16)
|
65
|
+
treetop (~> 1.4.8)
|
66
|
+
meta_search (1.0.5)
|
67
|
+
actionpack (~> 3.0.2)
|
68
|
+
activerecord (~> 3.0.2)
|
69
|
+
activesupport (~> 3.0.2)
|
70
|
+
arel (~> 2.0.2)
|
71
|
+
mime-types (1.16)
|
72
|
+
polyglot (0.3.1)
|
73
|
+
rack (1.2.3)
|
74
|
+
rack-mount (0.6.14)
|
75
|
+
rack (>= 1.0.0)
|
76
|
+
rack-test (0.5.7)
|
77
|
+
rack (>= 1.0)
|
78
|
+
rails (3.0.7)
|
79
|
+
actionmailer (= 3.0.7)
|
80
|
+
actionpack (= 3.0.7)
|
81
|
+
activerecord (= 3.0.7)
|
82
|
+
activeresource (= 3.0.7)
|
83
|
+
activesupport (= 3.0.7)
|
84
|
+
bundler (~> 1.0)
|
85
|
+
railties (= 3.0.7)
|
86
|
+
railties (3.0.7)
|
87
|
+
actionpack (= 3.0.7)
|
88
|
+
activesupport (= 3.0.7)
|
89
|
+
rake (>= 0.8.7)
|
90
|
+
thor (~> 0.14.4)
|
91
|
+
rake (0.8.7)
|
92
|
+
symbolize (3.1.3)
|
93
|
+
thor (0.14.6)
|
94
|
+
timeliness (0.3.4)
|
95
|
+
treetop (1.4.9)
|
96
|
+
polyglot (>= 0.3.1)
|
97
|
+
tzinfo (0.3.27)
|
98
|
+
version (1.0.0)
|
99
|
+
|
100
|
+
PLATFORMS
|
101
|
+
ruby
|
102
|
+
|
103
|
+
DEPENDENCIES
|
104
|
+
fume!
|
105
|
+
version (= 1.0.0)
|
data/{README → README.md}
RENAMED
File without changes
|
data/Rakefile
CHANGED
@@ -1,32 +1,8 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
+
require 'rake/version_task'
|
5
|
+
Rake::VersionTask.new
|
4
6
|
|
5
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
6
|
-
spec.libs << 'lib' << 'spec'
|
7
|
-
spec.spec_opts = ['--options', "spec/spec.opts"]
|
8
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
9
|
-
end
|
10
7
|
|
11
|
-
namespace :spec do
|
12
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
13
|
-
spec.libs << 'lib' << 'spec'
|
14
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
15
|
-
spec.rcov = true
|
16
|
-
end
|
17
|
-
end
|
18
8
|
|
19
|
-
|
20
|
-
Jeweler::Tasks.new do |spec|
|
21
|
-
spec.name = "fume"
|
22
|
-
spec.summary = "a simple rails scaffold."
|
23
|
-
spec.email = "Sunteya@gmail.com"
|
24
|
-
spec.homepage = "http://github.com/sunteya/fume"
|
25
|
-
spec.authors = ["Sunteya"]
|
26
|
-
GemLoader.gemspec.integrate(spec)
|
27
|
-
end
|
28
|
-
Jeweler::GemcutterTasks.new
|
29
|
-
|
30
|
-
|
31
|
-
task :spec => :check_dependencies
|
32
|
-
task :default => :spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.6.0
|
data/fume.gemspec
CHANGED
@@ -1,127 +1,44 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
5
3
|
|
6
4
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
5
|
+
s.name = "fume"
|
6
|
+
s.version = File.read(File.expand_path("../VERSION", __FILE__)).chomp
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Sunteya"]
|
9
|
+
s.email = ["Sunteya@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/sunteya/fume"
|
11
|
+
s.summary = %q{a simple rails scaffold.}
|
12
|
+
s.description = %q{a simple rails scaffold.}
|
9
13
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.email = %q{Sunteya@gmail.com}
|
14
|
-
s.extra_rdoc_files = [
|
15
|
-
"README"
|
16
|
-
]
|
17
|
-
s.files = [
|
18
|
-
".gitignore",
|
19
|
-
"README",
|
20
|
-
"Rakefile",
|
21
|
-
"VERSION.yml",
|
22
|
-
"depends.rb",
|
23
|
-
"fume.gemspec",
|
24
|
-
"lib/fume.rb",
|
25
|
-
"lib/fume/authlogic.rb",
|
26
|
-
"lib/fume/cancan.rb",
|
27
|
-
"lib/fume/daemon.rb",
|
28
|
-
"lib/fume/formtastic.rb",
|
29
|
-
"lib/fume/logger_support.rb",
|
30
|
-
"lib/fume/rails_ext.rb",
|
31
|
-
"lib/fume/searchlogic.rb",
|
32
|
-
"lib/fume/simple_theme.rb",
|
33
|
-
"lib/fume/smart_logger.rb",
|
34
|
-
"rails/init.rb",
|
35
|
-
"rails_generators/fume/fume_generator.rb",
|
36
|
-
"rails_generators/fume/rspec/rspec_gen.rb",
|
37
|
-
"rails_generators/fume/rspec/templates/spec/support/erb_macros.rb",
|
38
|
-
"rails_generators/fume/rspec/templates/spec/support/fume_controller_macros.rb",
|
39
|
-
"rails_generators/fume/simple_theme/simple_theme_gen.rb",
|
40
|
-
"rails_generators/fume/simple_theme/templates/public/stylesheets/reset.css",
|
41
|
-
"rails_generators/fume/simple_theme/templates/public/stylesheets/reset.less",
|
42
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/demo.html",
|
43
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/simple-theme-ie-patch.js",
|
44
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/simple-theme.css",
|
45
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/simple-theme.less",
|
46
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/src/base.less",
|
47
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/src/function.less",
|
48
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/src/layout.less",
|
49
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/src/reset.less",
|
50
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/src/vendor/yui-3.0/base.css",
|
51
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/src/vendor/yui-3.0/fonts.css",
|
52
|
-
"rails_generators/fume/simple_theme/templates/public/themes/simple_theme/src/vendor/yui-3.0/reset.css",
|
53
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-1.4.2.js",
|
54
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.js",
|
55
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness.css",
|
56
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_flat_30_cccccc_40x100.png",
|
57
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_flat_50_5c5c5c_40x100.png",
|
58
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_glass_20_555555_1x400.png",
|
59
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_glass_40_0078a3_1x400.png",
|
60
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_glass_40_ffc73d_1x400.png",
|
61
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_gloss-wave_25_333333_500x100.png",
|
62
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_highlight-soft_80_eeeeee_1x100.png",
|
63
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_inset-soft_25_000000_1x100.png",
|
64
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-bg_inset-soft_30_f58400_1x100.png",
|
65
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-icons_222222_256x240.png",
|
66
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-icons_4b8e0b_256x240.png",
|
67
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-icons_a83300_256x240.png",
|
68
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-icons_cccccc_256x240.png",
|
69
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-1.8.ui-darkness/ui-icons_ffffff_256x240.png",
|
70
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery-ui-i18n-1.8.js",
|
71
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery.ba-bbq-1.2.1.js",
|
72
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery.corner-2.09.js",
|
73
|
-
"rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery.timepicker-0.2.1.js",
|
74
|
-
"spec/fume/cancan_spec.rb",
|
75
|
-
"spec/fume/daemon_spec.rb",
|
76
|
-
"spec/fume/logger_support_spec.rb",
|
77
|
-
"spec/fume/smart_logger_spec.rb",
|
78
|
-
"spec/rails_stub.rb",
|
79
|
-
"spec/spec.opts",
|
80
|
-
"spec/spec_helper.rb"
|
81
|
-
]
|
82
|
-
s.homepage = %q{http://github.com/sunteya/fume}
|
83
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
84
17
|
s.require_paths = ["lib"]
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
18
|
+
|
19
|
+
|
20
|
+
# rails
|
21
|
+
s.add_runtime_dependency "rake", "~> 0.8.7"
|
22
|
+
s.add_runtime_dependency "rails", "3.0.7"
|
23
|
+
|
24
|
+
# library
|
25
|
+
s.add_runtime_dependency "timeliness", "~> 0.3.4"
|
26
|
+
s.add_runtime_dependency "hashie", "~> 1.0.0"
|
27
|
+
s.add_runtime_dependency "addressable", "~> 2.2.6"
|
28
|
+
|
29
|
+
# rails plugin
|
30
|
+
s.add_runtime_dependency "authlogic", "3.0.2"
|
31
|
+
s.add_runtime_dependency "formtastic", "1.2.3"
|
32
|
+
s.add_runtime_dependency "cancan", "1.6.4"
|
33
|
+
s.add_runtime_dependency "symbolize", "3.1.3"
|
34
|
+
s.add_runtime_dependency "meta_search", "1.0.5"
|
35
|
+
|
36
|
+
|
37
|
+
# development
|
38
|
+
s.add_development_dependency "version", "1.0.0"
|
39
|
+
# s.add_development_dependency "rspec", "~> 1.3.0"
|
40
|
+
end
|
41
|
+
|
95
42
|
|
96
|
-
if s.respond_to? :specification_version then
|
97
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
98
|
-
s.specification_version = 3
|
99
43
|
|
100
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
101
|
-
s.add_runtime_dependency(%q<gem_loader>, [">= 0.2.0"])
|
102
|
-
s.add_runtime_dependency(%q<actionpack>, ["~> 2.3.5"])
|
103
|
-
s.add_development_dependency(%q<authlogic>, [">= 2.1.3"])
|
104
|
-
s.add_development_dependency(%q<searchlogic>, [">= 2.4.12"])
|
105
|
-
s.add_development_dependency(%q<formtastic>, [">= 0.9.8"])
|
106
|
-
s.add_development_dependency(%q<cancan>, [">= 1.1.1"])
|
107
|
-
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
108
|
-
else
|
109
|
-
s.add_dependency(%q<gem_loader>, [">= 0.2.0"])
|
110
|
-
s.add_dependency(%q<actionpack>, ["~> 2.3.5"])
|
111
|
-
s.add_dependency(%q<authlogic>, [">= 2.1.3"])
|
112
|
-
s.add_dependency(%q<searchlogic>, [">= 2.4.12"])
|
113
|
-
s.add_dependency(%q<formtastic>, [">= 0.9.8"])
|
114
|
-
s.add_dependency(%q<cancan>, [">= 1.1.1"])
|
115
|
-
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
116
|
-
end
|
117
|
-
else
|
118
|
-
s.add_dependency(%q<gem_loader>, [">= 0.2.0"])
|
119
|
-
s.add_dependency(%q<actionpack>, ["~> 2.3.5"])
|
120
|
-
s.add_dependency(%q<authlogic>, [">= 2.1.3"])
|
121
|
-
s.add_dependency(%q<searchlogic>, [">= 2.4.12"])
|
122
|
-
s.add_dependency(%q<formtastic>, [">= 0.9.8"])
|
123
|
-
s.add_dependency(%q<cancan>, [">= 1.1.1"])
|
124
|
-
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
125
|
-
end
|
126
|
-
end
|
127
44
|
|
data/lib/fume.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
require
|
2
|
-
GemLoader.require(:runtime)
|
1
|
+
require "active_support"
|
3
2
|
|
4
|
-
|
5
|
-
require
|
6
|
-
require 'fume/simple_theme'
|
7
|
-
require 'fume/rails_ext'
|
8
|
-
require 'fume/formtastic'
|
9
|
-
require 'fume/smart_logger'
|
10
|
-
require 'fume/logger_support'
|
11
|
-
require 'fume/daemon'
|
12
|
-
require 'fume/cancan'
|
3
|
+
# rails
|
4
|
+
require File.expand_path("../fume/railtie", __FILE__)
|
13
5
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
6
|
+
module Fume
|
7
|
+
VERSION = File.read(File.expand_path("../../VERSION", __FILE__)).chomp
|
8
|
+
end
|
9
|
+
|
10
|
+
module Fume
|
11
|
+
extend ActiveSupport::Autoload
|
12
|
+
|
13
|
+
autoload :Authlogic
|
14
|
+
autoload :RailsExt
|
15
|
+
autoload :Cancan
|
16
|
+
autoload :SimpleTheme
|
17
|
+
end
|
data/lib/fume/authlogic.rb
CHANGED
@@ -2,12 +2,17 @@ module Fume
|
|
2
2
|
module Authlogic
|
3
3
|
def self.try_enable
|
4
4
|
if defined? ::Authlogic
|
5
|
-
ActionController::Base.send :include, ControllerExtensions
|
6
|
-
ActionController::Base.send :helper_method, :current_user_session, :current_user
|
5
|
+
ActionController::Base.send :include, ControllerExtensions
|
7
6
|
end
|
8
7
|
end
|
9
8
|
|
10
9
|
module ControllerExtensions
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
helper_method :current_user_session, :current_user
|
14
|
+
end
|
15
|
+
|
11
16
|
module InstanceMethods
|
12
17
|
|
13
18
|
protected
|
@@ -20,6 +25,7 @@ module Fume
|
|
20
25
|
return @current_user if defined?(@current_user)
|
21
26
|
@current_user = current_user_session && current_user_session.user
|
22
27
|
end
|
28
|
+
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
data/lib/fume/cancan.rb
CHANGED
@@ -7,28 +7,37 @@ module Fume
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module ControllerExtensions
|
10
|
-
|
11
|
-
base.send :extend, ClassMehtods
|
12
|
-
base.send :include, InstanceMethods
|
13
|
-
end
|
10
|
+
extend ActiveSupport::Concern
|
14
11
|
|
15
|
-
module
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
module ClassMethods
|
13
|
+
|
14
|
+
def authorize_object(options = {})
|
15
|
+
filter_options = options.slice(:only, :except) if options.is_a?(Hash)
|
16
|
+
before_filter(filter_options || {}) do |controller|
|
17
|
+
controller.send :authorize_object!, options
|
18
|
+
end
|
19
19
|
end
|
20
|
+
|
20
21
|
end
|
21
22
|
|
22
23
|
module InstanceMethods
|
24
|
+
|
23
25
|
protected
|
24
|
-
def
|
25
|
-
|
26
|
-
|
26
|
+
def authorize_object!(options)
|
27
|
+
action = params[:action].to_sym
|
28
|
+
case options
|
29
|
+
when Hash
|
30
|
+
authorize! action, options[:object]
|
31
|
+
else
|
32
|
+
authorize! action, options
|
33
|
+
end
|
27
34
|
end
|
35
|
+
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
31
39
|
end
|
40
|
+
|
32
41
|
end
|
33
42
|
|
34
43
|
|
data/lib/fume/rails_ext.rb
CHANGED
@@ -1,32 +1,43 @@
|
|
1
1
|
module Fume
|
2
2
|
module RailsExt
|
3
|
-
|
4
3
|
def self.try_enable
|
5
|
-
|
6
|
-
|
4
|
+
if defined? ::ActionController
|
5
|
+
ActionController::Base.send :include, ControllerExtensions
|
6
|
+
end
|
7
7
|
end
|
8
8
|
|
9
9
|
module ControllerExtensions
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
helper_method :public_path, :public_url
|
14
|
+
end
|
15
|
+
|
10
16
|
module InstanceMethods
|
11
17
|
|
12
18
|
protected
|
13
19
|
def redirect_to_ok_url_or_default(default)
|
14
20
|
redirect_to params[:ok_url] || default
|
15
21
|
end
|
22
|
+
|
23
|
+
def public_url(source)
|
24
|
+
if source.include?("://")
|
25
|
+
source
|
26
|
+
else
|
27
|
+
request.protocol + request.host_with_port + url_for("#{controller.config.relative_url_root}#{source}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def public_path(source)
|
32
|
+
if source.include?("://")
|
33
|
+
source
|
34
|
+
else
|
35
|
+
url_for("#{controller.config.relative_url_root}#{source}")
|
36
|
+
end
|
37
|
+
end
|
16
38
|
end
|
17
39
|
end
|
18
40
|
|
19
|
-
module RailsHelpers
|
20
|
-
def public_path(source)
|
21
|
-
url_for("#{ActionController::Base.relative_url_root}#{source}")
|
22
|
-
end
|
23
|
-
|
24
|
-
def translate_attribute(klass, attribute_name)
|
25
|
-
klass.human_attribute_name(attribute_name)
|
26
|
-
end
|
27
|
-
|
28
|
-
alias :ta :translate_attribute
|
29
|
-
end
|
30
41
|
end
|
31
42
|
end
|
32
43
|
|
data/lib/fume/railtie.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rails/railtie"
|
2
|
+
|
3
|
+
module Fume
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
initializer 'fume.initialize', :after => :after_initialize do
|
6
|
+
Fume.constants.each do |name|
|
7
|
+
ext_module = Fume.const_get(name)
|
8
|
+
|
9
|
+
if ext_module.respond_to?(:try_enable)
|
10
|
+
ext_module.try_enable
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/fume/simple_theme.rb
CHANGED
@@ -2,11 +2,17 @@ module Fume
|
|
2
2
|
module SimpleTheme
|
3
3
|
|
4
4
|
def self.try_enable
|
5
|
-
ActionController::Base.send :
|
6
|
-
ActionController::Base.send :helper, RailsHelpers
|
5
|
+
ActionController::Base.send :include, ControllerExtensions
|
7
6
|
end
|
8
7
|
|
9
8
|
module ControllerExtensions
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
helper_method :sec_nav, :main_nav
|
13
|
+
helper RailsHelpers
|
14
|
+
end
|
15
|
+
|
10
16
|
module ClassMethods
|
11
17
|
def sec_nav_highlight(name)
|
12
18
|
class_eval do
|
@@ -20,32 +26,34 @@ module Fume
|
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
|
30
|
+
module RailsHelpers
|
31
|
+
|
32
|
+
def sec_nav(name, options = {}, &block)
|
33
|
+
if @sec_nav == name
|
34
|
+
if options[:class]
|
35
|
+
options[:class] += " active"
|
36
|
+
else
|
37
|
+
options[:class] = "active"
|
38
|
+
end
|
32
39
|
end
|
40
|
+
content = capture(&block)
|
41
|
+
content_tag(:li, content, options)
|
33
42
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
else
|
43
|
-
options[:class] = "active"
|
43
|
+
|
44
|
+
def main_nav(name, options = {}, &block)
|
45
|
+
if @main_nav == name
|
46
|
+
if options[:class]
|
47
|
+
options[:class] += " active"
|
48
|
+
else
|
49
|
+
options[:class] = "active"
|
50
|
+
end
|
44
51
|
end
|
52
|
+
content = capture(&block)
|
53
|
+
content_tag(:li, content, options)
|
45
54
|
end
|
46
|
-
content = capture(&block)
|
47
|
-
concat content_tag(:li, content, options)
|
48
55
|
end
|
56
|
+
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fume
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 5
|
8
|
-
- 3
|
9
|
-
version: 0.5.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.6.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Sunteya
|
@@ -14,133 +10,153 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-05-31 00:00:00 +08:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
17
|
+
name: rake
|
22
18
|
prerelease: false
|
23
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
24
21
|
requirements:
|
25
|
-
- -
|
22
|
+
- - ~>
|
26
23
|
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
- 2
|
30
|
-
- 0
|
31
|
-
version: 0.2.0
|
24
|
+
version: 0.8.7
|
32
25
|
type: :runtime
|
33
26
|
version_requirements: *id001
|
34
27
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
28
|
+
name: rails
|
36
29
|
prerelease: false
|
37
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
38
32
|
requirements:
|
39
|
-
- -
|
33
|
+
- - "="
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 2
|
43
|
-
- 3
|
44
|
-
- 5
|
45
|
-
version: 2.3.5
|
35
|
+
version: 3.0.7
|
46
36
|
type: :runtime
|
47
37
|
version_requirements: *id002
|
48
38
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
39
|
+
name: timeliness
|
50
40
|
prerelease: false
|
51
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
52
43
|
requirements:
|
53
|
-
- -
|
44
|
+
- - ~>
|
54
45
|
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
- 1
|
58
|
-
- 3
|
59
|
-
version: 2.1.3
|
60
|
-
type: :development
|
46
|
+
version: 0.3.4
|
47
|
+
type: :runtime
|
61
48
|
version_requirements: *id003
|
62
49
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
50
|
+
name: hashie
|
64
51
|
prerelease: false
|
65
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
66
54
|
requirements:
|
67
|
-
- -
|
55
|
+
- - ~>
|
68
56
|
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
|
71
|
-
- 4
|
72
|
-
- 12
|
73
|
-
version: 2.4.12
|
74
|
-
type: :development
|
57
|
+
version: 1.0.0
|
58
|
+
type: :runtime
|
75
59
|
version_requirements: *id004
|
76
60
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
61
|
+
name: addressable
|
78
62
|
prerelease: false
|
79
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
80
65
|
requirements:
|
81
|
-
- -
|
66
|
+
- - ~>
|
82
67
|
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
|
85
|
-
- 9
|
86
|
-
- 8
|
87
|
-
version: 0.9.8
|
88
|
-
type: :development
|
68
|
+
version: 2.2.6
|
69
|
+
type: :runtime
|
89
70
|
version_requirements: *id005
|
90
71
|
- !ruby/object:Gem::Dependency
|
91
|
-
name:
|
72
|
+
name: authlogic
|
92
73
|
prerelease: false
|
93
74
|
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
94
76
|
requirements:
|
95
|
-
- - "
|
77
|
+
- - "="
|
96
78
|
- !ruby/object:Gem::Version
|
97
|
-
|
98
|
-
|
99
|
-
- 1
|
100
|
-
- 1
|
101
|
-
version: 1.1.1
|
102
|
-
type: :development
|
79
|
+
version: 3.0.2
|
80
|
+
type: :runtime
|
103
81
|
version_requirements: *id006
|
104
82
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
83
|
+
name: formtastic
|
106
84
|
prerelease: false
|
107
85
|
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
108
87
|
requirements:
|
109
|
-
- - "
|
88
|
+
- - "="
|
110
89
|
- !ruby/object:Gem::Version
|
111
|
-
|
112
|
-
|
113
|
-
- 3
|
114
|
-
- 0
|
115
|
-
version: 1.3.0
|
116
|
-
type: :development
|
90
|
+
version: 1.2.3
|
91
|
+
type: :runtime
|
117
92
|
version_requirements: *id007
|
118
|
-
|
119
|
-
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: cancan
|
95
|
+
prerelease: false
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - "="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.6.4
|
102
|
+
type: :runtime
|
103
|
+
version_requirements: *id008
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: symbolize
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - "="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 3.1.3
|
113
|
+
type: :runtime
|
114
|
+
version_requirements: *id009
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: meta_search
|
117
|
+
prerelease: false
|
118
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - "="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 1.0.5
|
124
|
+
type: :runtime
|
125
|
+
version_requirements: *id010
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: version
|
128
|
+
prerelease: false
|
129
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - "="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 1.0.0
|
135
|
+
type: :development
|
136
|
+
version_requirements: *id011
|
137
|
+
description: a simple rails scaffold.
|
138
|
+
email:
|
139
|
+
- Sunteya@gmail.com
|
120
140
|
executables: []
|
121
141
|
|
122
142
|
extensions: []
|
123
143
|
|
124
|
-
extra_rdoc_files:
|
125
|
-
|
144
|
+
extra_rdoc_files: []
|
145
|
+
|
126
146
|
files:
|
127
147
|
- .gitignore
|
128
|
-
-
|
148
|
+
- Gemfile
|
149
|
+
- Gemfile.lock
|
150
|
+
- README.md
|
129
151
|
- Rakefile
|
130
|
-
- VERSION
|
131
|
-
- depends.rb
|
152
|
+
- VERSION
|
132
153
|
- fume.gemspec
|
133
154
|
- lib/fume.rb
|
134
155
|
- lib/fume/authlogic.rb
|
135
156
|
- lib/fume/cancan.rb
|
136
|
-
- lib/fume/daemon.rb
|
137
|
-
- lib/fume/formtastic.rb
|
138
|
-
- lib/fume/logger_support.rb
|
139
157
|
- lib/fume/rails_ext.rb
|
140
|
-
- lib/fume/
|
158
|
+
- lib/fume/railtie.rb
|
141
159
|
- lib/fume/simple_theme.rb
|
142
|
-
- lib/fume/smart_logger.rb
|
143
|
-
- rails/init.rb
|
144
160
|
- rails_generators/fume/fume_generator.rb
|
145
161
|
- rails_generators/fume/rspec/rspec_gen.rb
|
146
162
|
- rails_generators/fume/rspec/templates/spec/support/erb_macros.rb
|
@@ -181,10 +197,6 @@ files:
|
|
181
197
|
- rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery.corner-2.09.js
|
182
198
|
- rails_generators/fume/simple_theme/templates/public/themes/vendor/jquery.timepicker-0.2.1.js
|
183
199
|
- spec/fume/cancan_spec.rb
|
184
|
-
- spec/fume/daemon_spec.rb
|
185
|
-
- spec/fume/logger_support_spec.rb
|
186
|
-
- spec/fume/smart_logger_spec.rb
|
187
|
-
- spec/rails_stub.rb
|
188
200
|
- spec/spec.opts
|
189
201
|
- spec/spec_helper.rb
|
190
202
|
has_rdoc: true
|
@@ -192,35 +204,30 @@ homepage: http://github.com/sunteya/fume
|
|
192
204
|
licenses: []
|
193
205
|
|
194
206
|
post_install_message:
|
195
|
-
rdoc_options:
|
196
|
-
|
207
|
+
rdoc_options: []
|
208
|
+
|
197
209
|
require_paths:
|
198
210
|
- lib
|
199
211
|
required_ruby_version: !ruby/object:Gem::Requirement
|
212
|
+
none: false
|
200
213
|
requirements:
|
201
214
|
- - ">="
|
202
215
|
- !ruby/object:Gem::Version
|
203
|
-
segments:
|
204
|
-
- 0
|
205
216
|
version: "0"
|
206
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
|
+
none: false
|
207
219
|
requirements:
|
208
220
|
- - ">="
|
209
221
|
- !ruby/object:Gem::Version
|
210
|
-
segments:
|
211
|
-
- 0
|
212
222
|
version: "0"
|
213
223
|
requirements: []
|
214
224
|
|
215
225
|
rubyforge_project:
|
216
|
-
rubygems_version: 1.
|
226
|
+
rubygems_version: 1.6.2
|
217
227
|
signing_key:
|
218
228
|
specification_version: 3
|
219
229
|
summary: a simple rails scaffold.
|
220
230
|
test_files:
|
221
231
|
- spec/fume/cancan_spec.rb
|
222
|
-
- spec/
|
223
|
-
- spec/fume/logger_support_spec.rb
|
224
|
-
- spec/fume/smart_logger_spec.rb
|
225
|
-
- spec/rails_stub.rb
|
232
|
+
- spec/spec.opts
|
226
233
|
- spec/spec_helper.rb
|
data/VERSION.yml
DELETED
data/depends.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
gem "gem_loader", ">= 0.1.3"
|
3
|
-
require "gem_loader"
|
4
|
-
|
5
|
-
|
6
|
-
GemLoader.setup do
|
7
|
-
|
8
|
-
scope :runtime do
|
9
|
-
gem "actionpack", "~> 2.3.5", :require => ["action_pack", "action_view", "action_controller"]
|
10
|
-
end
|
11
|
-
|
12
|
-
scope :optional do
|
13
|
-
gem "authlogic", ">= 2.1.3"
|
14
|
-
gem "searchlogic", ">= 2.4.12"
|
15
|
-
gem "formtastic", ">= 0.9.8"
|
16
|
-
gem "cancan", ">= 1.1.1"
|
17
|
-
end
|
18
|
-
|
19
|
-
scope :test do
|
20
|
-
gem "rspec", ">= 1.3.0", :require => nil
|
21
|
-
end
|
22
|
-
|
23
|
-
scope :development => [:optional, :test]
|
24
|
-
|
25
|
-
scope :rakefile do
|
26
|
-
gem "rake", ">= 0.8.7"
|
27
|
-
gem "jeweler", ">= 1.4.0"
|
28
|
-
gem "rspec", :require => "spec/rake/spectask"
|
29
|
-
end
|
30
|
-
end
|
data/lib/fume/daemon.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
|
3
|
-
module Fume
|
4
|
-
module Daemon
|
5
|
-
|
6
|
-
def self.included(base)
|
7
|
-
base.instance_eval do
|
8
|
-
include LoggerSupport
|
9
|
-
|
10
|
-
include InstanceMethods
|
11
|
-
extend ClassMethods
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module ClassMethods
|
16
|
-
end
|
17
|
-
|
18
|
-
module InstanceMethods
|
19
|
-
attr_accessor :pid_file_path
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
self.pid_file_path = Rails.root.join("tmp", "pids", "#{daemon_name}.pid")
|
23
|
-
end
|
24
|
-
|
25
|
-
def daemon_name
|
26
|
-
self.class.name
|
27
|
-
end
|
28
|
-
|
29
|
-
def register_trap
|
30
|
-
%w{TERM INT HUP}.each do |signal_name|
|
31
|
-
Signal.trap(signal_name) do
|
32
|
-
self.stop
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def pid_file_path
|
38
|
-
ENV["PID_FILE"] || @pid_file_path
|
39
|
-
end
|
40
|
-
|
41
|
-
def write_pid_file(pid)
|
42
|
-
if self.pid_file_path
|
43
|
-
File.open(self.pid_file_path, "w") { |f| f << pid }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def remove_pid_file
|
48
|
-
FileUtils.rm(pid_file_path, :force => true) if self.pid_file_path && File.exists?(self.pid_file_path)
|
49
|
-
end
|
50
|
-
|
51
|
-
def already_running?
|
52
|
-
if self.pid_file_path && File.exists?(self.pid_file_path)
|
53
|
-
pid = File.read(self.pid_file_path)
|
54
|
-
return Process.kill(0, pid.to_i) == 1 if pid # test running
|
55
|
-
end
|
56
|
-
return false
|
57
|
-
rescue Errno::ESRCH # NOT running or zombied
|
58
|
-
return false
|
59
|
-
end
|
60
|
-
|
61
|
-
def start
|
62
|
-
return if already_running?
|
63
|
-
begin
|
64
|
-
register_trap
|
65
|
-
write_pid_file(Process.pid)
|
66
|
-
logger.info { "Daemon: #{daemon_name} starting ... PID: #{Process.pid}" }
|
67
|
-
|
68
|
-
@run = true
|
69
|
-
|
70
|
-
while @run
|
71
|
-
self.execute
|
72
|
-
end
|
73
|
-
logger.info { "Daemon: #{daemon_name} stoped ..." }
|
74
|
-
rescue Exception => e
|
75
|
-
logger.error(e)
|
76
|
-
ensure
|
77
|
-
remove_pid_file
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def stop
|
82
|
-
@run = false
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
data/lib/fume/formtastic.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Fume
|
2
|
-
module Formtastic
|
3
|
-
|
4
|
-
def self.try_enable
|
5
|
-
return unless defined? ::Formtastic
|
6
|
-
|
7
|
-
::Formtastic::SemanticFormBuilder.class_exec do
|
8
|
-
alias_method :humanized_attribute_name_without_instance, :humanized_attribute_name
|
9
|
-
|
10
|
-
def humanized_attribute_name(method)
|
11
|
-
if @object && @object.respond_to?(:human_attribute_name)
|
12
|
-
@object.human_attribute_name(method.to_s)
|
13
|
-
else
|
14
|
-
humanized_attribute_name_without_instance(method)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
data/lib/fume/logger_support.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Fume
|
2
|
-
module LoggerSupport
|
3
|
-
def self.included(base)
|
4
|
-
base.instance_eval do
|
5
|
-
extend ClassMethods
|
6
|
-
include InstanceMethods
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def logger
|
12
|
-
@logger ||= Rails.logger || Logger.new(STDOUT)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module InstanceMethods
|
17
|
-
def logger
|
18
|
-
@logger ||= self.class.logger
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/fume/searchlogic.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
module Fume
|
2
|
-
module Searchlogic
|
3
|
-
|
4
|
-
def self.try_enable
|
5
|
-
if defined? ::Searchlogic
|
6
|
-
ActionController::Base.send :helper, RailsHelpers
|
7
|
-
::Searchlogic::Search.send :include, SearchExtensions
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
module SearchExtensions
|
12
|
-
def self.included(base)
|
13
|
-
base.instance_eval do
|
14
|
-
include InstanceMethods
|
15
|
-
extend ClassMethods
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module ClassMethods
|
20
|
-
def human_name
|
21
|
-
"Search"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
module InstanceMethods
|
26
|
-
|
27
|
-
def human_attribute_name(name)
|
28
|
-
klass.human_attribute_name(name)
|
29
|
-
end
|
30
|
-
|
31
|
-
def new_record?
|
32
|
-
true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
module RailsHelpers
|
38
|
-
def i18n_order(search, options = {}, html_options = {})
|
39
|
-
attribute_name = options[:attr] || options[:by]
|
40
|
-
options[:as] ||= translate_attribute(search.klass, attribute_name)
|
41
|
-
order(search, options, html_options)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
data/lib/fume/smart_logger.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require "logger"
|
2
|
-
|
3
|
-
module Fume
|
4
|
-
class SmartLogger
|
5
|
-
def self.create(name, log_level = Logger::DEBUG)
|
6
|
-
logger = case name
|
7
|
-
when "STDOUT"
|
8
|
-
Logger.new(STDOUT)
|
9
|
-
when /(\w+)/
|
10
|
-
Logger.new(Rails.root.join("log", "#{$1}.log"))
|
11
|
-
when /(\w+\.\w+)/
|
12
|
-
Logger.new(Rails.root.join("log", $1))
|
13
|
-
else
|
14
|
-
Logger.new(Rails.root.join("log", "#{Rails.env}.log"))
|
15
|
-
end
|
16
|
-
logger.level = log_level
|
17
|
-
logger
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/rails/init.rb
DELETED
data/spec/fume/daemon_spec.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fileutils"
|
3
|
-
|
4
|
-
describe Fume::Daemon do
|
5
|
-
class TestDaemon
|
6
|
-
include Fume::Daemon
|
7
|
-
|
8
|
-
attr_writer :callback
|
9
|
-
|
10
|
-
def callback(&block)
|
11
|
-
if block
|
12
|
-
@callback = block
|
13
|
-
else
|
14
|
-
@callback
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
callback.call if callback
|
20
|
-
sleep 0.05
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
before(:each) do
|
25
|
-
ENV["PID_FILE"] = nil
|
26
|
-
@pid_path = Rails.root.join("tmp", "pids", "test.pid").to_s
|
27
|
-
FileUtils.rm(@pid_path, :force => true)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be create pid file by path" do
|
31
|
-
build_and_start_test_daemon do |d|
|
32
|
-
d.callback { File.exists?(@pid_path).should be_true }
|
33
|
-
d.pid_file_path = @pid_path
|
34
|
-
end
|
35
|
-
File.exists?(@pid_path).should be_false
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should be create pid file by ENV" do
|
39
|
-
ENV["PID_FILE"] = @pid_path
|
40
|
-
build_and_start_test_daemon do |d|
|
41
|
-
d.callback { File.exists?(@pid_path).should be_true }
|
42
|
-
end
|
43
|
-
File.exists?(@pid_path).should be_false
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should be create pid file by default" do
|
47
|
-
build_and_start_test_daemon do |d|
|
48
|
-
d.pid_file_path.should_not be_nil
|
49
|
-
d.callback { File.exists?(d.pid_file_path).should be_true }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should be not create pid file" do
|
54
|
-
build_and_start_test_daemon do |d|
|
55
|
-
pid_path = d.pid_file_path
|
56
|
-
d.pid_file_path = nil
|
57
|
-
d.callback { File.exists?(pid_path).should be_false }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should be catch exception" do
|
62
|
-
daemon = build_and_start_test_daemon do |d|
|
63
|
-
d.callback { raise "exception" }
|
64
|
-
end
|
65
|
-
|
66
|
-
File.exists?(daemon.pid_file_path).should be_false
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should be exit if pid file exists" do
|
70
|
-
build_and_start_test_daemon do |d|
|
71
|
-
d.pid_file_path = @pid_path
|
72
|
-
d.write_pid_file(Process.pid)
|
73
|
-
d.callback { fail("MUST exit at start") }
|
74
|
-
end
|
75
|
-
File.exists?(@pid_path).should be_true
|
76
|
-
end
|
77
|
-
|
78
|
-
def build_and_start_test_daemon
|
79
|
-
Thread.new do
|
80
|
-
sleep 0.5
|
81
|
-
Process.kill("INT", $$)
|
82
|
-
end
|
83
|
-
|
84
|
-
daemon = TestDaemon.new
|
85
|
-
daemon.logger.level = Logger::FATAL
|
86
|
-
yield(daemon) if block_given?
|
87
|
-
|
88
|
-
daemon.start
|
89
|
-
daemon
|
90
|
-
end
|
91
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Fume::LoggerSupport do
|
4
|
-
class TestLog
|
5
|
-
include Fume::LoggerSupport
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should be return rails logger" do
|
9
|
-
Rails.logger = "Test"
|
10
|
-
TestLog.logger.should be_eql "Test"
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
it "should be return STDOUT logger" do
|
15
|
-
Rails.logger = nil
|
16
|
-
TestLog.logger.should_not be_nil
|
17
|
-
end
|
18
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Fume::SmartLogger do
|
4
|
-
before(:each) do
|
5
|
-
@logger = Logger.new(STDOUT)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should be create STDOUT logger" do
|
9
|
-
Logger.should_receive(:new).with(STDOUT).and_return(@logger)
|
10
|
-
result = SmartLogger.create("STDOUT")
|
11
|
-
result.should be_eql @logger
|
12
|
-
result.level.should be_eql Logger::DEBUG
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should be create log file logger" do
|
16
|
-
Logger.should_receive(:new).with(Rails.root.join("log", "file.log")).and_return(@logger)
|
17
|
-
result = SmartLogger.create("file", Logger::INFO)
|
18
|
-
result.should be_eql @logger
|
19
|
-
result.level.should be_eql Logger::INFO
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should be create log file logger with ext" do
|
23
|
-
Logger.should_receive(:new).with(Rails.root.join("log", "file.log")).and_return(@logger)
|
24
|
-
SmartLogger.create("file.log").should be_eql @logger
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should be create log file by Rails env" do
|
28
|
-
Logger.should_receive(:new).with(Rails.root.join("log", "development.log")).and_return(@logger)
|
29
|
-
Rails.env = "development"
|
30
|
-
SmartLogger.create(nil).should be_eql @logger
|
31
|
-
end
|
32
|
-
end
|