dragoon_system 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/Rakefile +9 -0
- data/VERSION +1 -1
- data/config/locales/en.yml +7 -0
- data/config/locales/zh-CN.yml +9 -0
- data/dragoon_system.gemspec +10 -7
- data/lib/action_controller/base_patch.rb +60 -0
- data/lib/active_record/base_patch.rb +19 -0
- data/lib/dragoon_system.rb +2 -1
- data/lib/generators/dragoon_system/install_generator.rb +15 -0
- metadata +32 -15
- data/test/helper.rb +0 -17
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -44,6 +44,7 @@ GEM
|
|
44
44
|
mime-types (~> 1.16)
|
45
45
|
treetop (~> 1.4.8)
|
46
46
|
mime-types (1.16)
|
47
|
+
mysql2 (0.2.4)
|
47
48
|
polyglot (0.3.1)
|
48
49
|
rack (1.2.1)
|
49
50
|
rack-mount (0.6.13)
|
@@ -76,5 +77,6 @@ PLATFORMS
|
|
76
77
|
DEPENDENCIES
|
77
78
|
bundler (~> 1.0.10)
|
78
79
|
jeweler (~> 1.5.1)
|
80
|
+
mysql2
|
79
81
|
rails (~> 3.0.5)
|
80
82
|
rcov
|
data/Rakefile
CHANGED
@@ -51,3 +51,12 @@ Rake::RDocTask.new do |rdoc|
|
|
51
51
|
rdoc.rdoc_files.include('README*')
|
52
52
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
53
|
end
|
54
|
+
|
55
|
+
task :gs1 do
|
56
|
+
system("git instaweb --httpd=webrick --port=8625")
|
57
|
+
end
|
58
|
+
|
59
|
+
task :gs2 do
|
60
|
+
system("git instaweb --httpd=webrick --stop")
|
61
|
+
end
|
62
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/dragoon_system.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dragoon_system}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["zhanyinan"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-04}
|
13
13
|
s.description = %q{personal suit}
|
14
14
|
s.email = %q{toward7seas@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,37 +24,40 @@ Gem::Specification.new do |s|
|
|
24
24
|
"README.rdoc",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
|
+
"config/locales/en.yml",
|
28
|
+
"config/locales/zh-CN.yml",
|
27
29
|
"dragoon_system.gemspec",
|
30
|
+
"lib/action_controller/base_patch.rb",
|
28
31
|
"lib/active_record/base_patch.rb",
|
29
32
|
"lib/dragoon_system.rb",
|
33
|
+
"lib/generators/dragoon_system/install_generator.rb",
|
30
34
|
"lib/module_patch.rb",
|
31
|
-
"lib/string_patch.rb"
|
32
|
-
"test/helper.rb"
|
35
|
+
"lib/string_patch.rb"
|
33
36
|
]
|
34
37
|
s.homepage = %q{http://github.com/toward7seas01/dragoon_system}
|
35
38
|
s.licenses = ["MIT"]
|
36
39
|
s.require_paths = ["lib"]
|
37
40
|
s.rubygems_version = %q{1.5.2}
|
38
41
|
s.summary = %q{personal suit}
|
39
|
-
s.test_files = [
|
40
|
-
"test/helper.rb"
|
41
|
-
]
|
42
42
|
|
43
43
|
if s.respond_to? :specification_version then
|
44
44
|
s.specification_version = 3
|
45
45
|
|
46
46
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_runtime_dependency(%q<mysql2>, [">= 0"])
|
47
48
|
s.add_runtime_dependency(%q<rails>, ["~> 3.0.5"])
|
48
49
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.10"])
|
49
50
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
50
51
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
51
52
|
else
|
53
|
+
s.add_dependency(%q<mysql2>, [">= 0"])
|
52
54
|
s.add_dependency(%q<rails>, ["~> 3.0.5"])
|
53
55
|
s.add_dependency(%q<bundler>, ["~> 1.0.10"])
|
54
56
|
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
55
57
|
s.add_dependency(%q<rcov>, [">= 0"])
|
56
58
|
end
|
57
59
|
else
|
60
|
+
s.add_dependency(%q<mysql2>, [">= 0"])
|
58
61
|
s.add_dependency(%q<rails>, ["~> 3.0.5"])
|
59
62
|
s.add_dependency(%q<bundler>, ["~> 1.0.10"])
|
60
63
|
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module ActionController
|
2
|
+
class Base
|
3
|
+
extend ActiveSupport::Memoizable
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def reload_page
|
8
|
+
render :update do |page| page.reload end
|
9
|
+
end
|
10
|
+
|
11
|
+
def replace_html(part, content)
|
12
|
+
render :update do |page|
|
13
|
+
page.select(part).show().html(content)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def current_identifier
|
18
|
+
params[:controller].split("/").last.singularize
|
19
|
+
end
|
20
|
+
|
21
|
+
def current_model
|
22
|
+
current_identifier.classify.constantize
|
23
|
+
end
|
24
|
+
|
25
|
+
memoize :current_identifier, :current_model
|
26
|
+
|
27
|
+
def base_action(&block)
|
28
|
+
case current_model.each_with_transaction(params[:ids], &block)
|
29
|
+
when :success
|
30
|
+
flash.notice = t("dragoon_system.transaction.success")
|
31
|
+
when :empty
|
32
|
+
flash.alert = t("dragoon_system.transaction.empty")
|
33
|
+
else
|
34
|
+
flash.alert = t("dragoon_system.transaction.error")
|
35
|
+
end
|
36
|
+
redirect_to :back
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
class << self
|
41
|
+
|
42
|
+
def ajax_destroy
|
43
|
+
if instance_methods.include?("resource")
|
44
|
+
define_method :destroy do
|
45
|
+
super do |format|
|
46
|
+
format.js do
|
47
|
+
render :update do |page|
|
48
|
+
page.select(dom_id(resource)).remove()
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
else
|
54
|
+
raise l("lack_necessary_method")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -44,6 +44,25 @@ module ActiveRecord
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def each_with_transaction(ids)
|
48
|
+
if ids.blank?
|
49
|
+
return :empty
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
records = find(ids)
|
54
|
+
transaction do
|
55
|
+
records.each do |record|
|
56
|
+
raise unless yield(record)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
rescue
|
60
|
+
:error
|
61
|
+
else
|
62
|
+
:success
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
47
66
|
def newest
|
48
67
|
scoped(:order => "#{self.table_name}.updated_at desc")
|
49
68
|
end
|
data/lib/dragoon_system.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module DragoonSystem
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
7
|
+
|
8
|
+
def copy_locale
|
9
|
+
copy_file "../../../config/locales/en.yml", "config/locales/dragoon_system.en.yml"
|
10
|
+
copy_file "../../../config/locales/zh-CN.yml", "config/locales/dragoon_system.zh-CN.yml"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragoon_system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- zhanyinan
|
@@ -15,12 +15,26 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-04 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: mysql2
|
23
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
prerelease: false
|
33
|
+
type: :runtime
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rails
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
24
38
|
none: false
|
25
39
|
requirements:
|
26
40
|
- - ~>
|
@@ -33,10 +47,10 @@ dependencies:
|
|
33
47
|
version: 3.0.5
|
34
48
|
prerelease: false
|
35
49
|
type: :runtime
|
36
|
-
requirement: *
|
50
|
+
requirement: *id002
|
37
51
|
- !ruby/object:Gem::Dependency
|
38
52
|
name: bundler
|
39
|
-
version_requirements: &
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
40
54
|
none: false
|
41
55
|
requirements:
|
42
56
|
- - ~>
|
@@ -49,10 +63,10 @@ dependencies:
|
|
49
63
|
version: 1.0.10
|
50
64
|
prerelease: false
|
51
65
|
type: :development
|
52
|
-
requirement: *
|
66
|
+
requirement: *id003
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: jeweler
|
55
|
-
version_requirements: &
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
56
70
|
none: false
|
57
71
|
requirements:
|
58
72
|
- - ~>
|
@@ -65,10 +79,10 @@ dependencies:
|
|
65
79
|
version: 1.5.1
|
66
80
|
prerelease: false
|
67
81
|
type: :development
|
68
|
-
requirement: *
|
82
|
+
requirement: *id004
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rcov
|
71
|
-
version_requirements: &
|
85
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
72
86
|
none: false
|
73
87
|
requirements:
|
74
88
|
- - ">="
|
@@ -79,7 +93,7 @@ dependencies:
|
|
79
93
|
version: "0"
|
80
94
|
prerelease: false
|
81
95
|
type: :development
|
82
|
-
requirement: *
|
96
|
+
requirement: *id005
|
83
97
|
description: personal suit
|
84
98
|
email: toward7seas@gmail.com
|
85
99
|
executables: []
|
@@ -97,12 +111,15 @@ files:
|
|
97
111
|
- README.rdoc
|
98
112
|
- Rakefile
|
99
113
|
- VERSION
|
114
|
+
- config/locales/en.yml
|
115
|
+
- config/locales/zh-CN.yml
|
100
116
|
- dragoon_system.gemspec
|
117
|
+
- lib/action_controller/base_patch.rb
|
101
118
|
- lib/active_record/base_patch.rb
|
102
119
|
- lib/dragoon_system.rb
|
120
|
+
- lib/generators/dragoon_system/install_generator.rb
|
103
121
|
- lib/module_patch.rb
|
104
122
|
- lib/string_patch.rb
|
105
|
-
- test/helper.rb
|
106
123
|
has_rdoc: true
|
107
124
|
homepage: http://github.com/toward7seas01/dragoon_system
|
108
125
|
licenses:
|
@@ -137,5 +154,5 @@ rubygems_version: 1.5.2
|
|
137
154
|
signing_key:
|
138
155
|
specification_version: 3
|
139
156
|
summary: personal suit
|
140
|
-
test_files:
|
141
|
-
|
157
|
+
test_files: []
|
158
|
+
|
data/test/helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
|
12
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
-
require 'dragoon_system'
|
15
|
-
|
16
|
-
class Test::Unit::TestCase
|
17
|
-
end
|