acts_as_extjs 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/Rakefile +12 -12
  2. data/VERSION +1 -1
  3. data/acts_as_extjs.gemspec +18 -21
  4. data/lib/acts_as_extjs.rb +44 -44
  5. metadata +10 -31
  6. data/.gitignore +0 -12
data/Rakefile CHANGED
@@ -12,26 +12,26 @@ begin
12
12
  gem.authors = ["Marco Scholl"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  gem.add_runtime_dependency "activerecord", ">= 3.0.0"
15
- gem.add_runtime_dependency "will_paginate", "~> 3.0.pre2"
15
+ gem.add_runtime_dependency "rails_paginate", ">= 0.0.0"
16
16
  end
17
17
  Jeweler::GemcutterTasks.new
18
18
  rescue LoadError
19
19
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
20
  end
21
21
 
22
- require 'spec/rake/spectask'
23
- Spec::Rake::SpecTask.new(:spec) do |spec|
24
- spec.libs << 'lib' << 'spec'
25
- spec.spec_files = FileList['spec/**/*_spec.rb']
26
- end
22
+ #require 'spec/rake/spectask'
23
+ #Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ # spec.libs << 'lib' << 'spec'
25
+ # spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ #end
27
27
 
28
- Spec::Rake::SpecTask.new(:rcov) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.pattern = 'spec/**/*_spec.rb'
31
- spec.rcov = true
32
- end
28
+ #Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ # spec.libs << 'lib' << 'spec'
30
+ # spec.pattern = 'spec/**/*_spec.rb'
31
+ # spec.rcov = true
32
+ #end
33
33
 
34
- task :spec => :check_dependencies
34
+ #task :spec => :check_dependencies
35
35
 
36
36
  begin
37
37
  require 'reek/adapters/rake_task'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{acts_as_extjs}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marco Scholl"]
12
- s.date = %q{2010-10-10}
12
+ s.date = %q{2011-04-19}
13
13
  s.description = %q{ActiveRecord Helper for Extjs}
14
14
  s.email = %q{develop@marco-scholl.de}
15
15
  s.extra_rdoc_files = [
@@ -17,44 +17,41 @@ Gem::Specification.new do |s|
17
17
  ]
18
18
  s.files = [
19
19
  ".gemspec",
20
- ".gitignore",
21
- "MIT-LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "acts_as_extjs.gemspec",
26
- "lib/acts_as_extjs.rb",
27
- "spec/acts_as_extjs_spec.rb",
28
- "spec/spec.opts",
29
- "spec/spec_helper.rb"
20
+ "MIT-LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "acts_as_extjs.gemspec",
25
+ "lib/acts_as_extjs.rb",
26
+ "spec/acts_as_extjs_spec.rb",
27
+ "spec/spec.opts",
28
+ "spec/spec_helper.rb"
30
29
  ]
31
30
  s.homepage = %q{http://github.com/traxanos/acts_as_extjs}
32
- s.rdoc_options = ["--charset=UTF-8"]
33
31
  s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.3.7}
32
+ s.rubygems_version = %q{1.6.2}
35
33
  s.summary = %q{ActiveRecord Helper for Extjs}
36
34
  s.test_files = [
37
- "spec/spec_helper.rb",
38
- "spec/acts_as_extjs_spec.rb"
35
+ "spec/acts_as_extjs_spec.rb",
36
+ "spec/spec_helper.rb"
39
37
  ]
40
38
 
41
39
  if s.respond_to? :specification_version then
42
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
40
  s.specification_version = 3
44
41
 
45
42
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
43
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
47
44
  s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
48
- s.add_runtime_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
45
+ s.add_runtime_dependency(%q<rails_paginate>, [">= 0.0.0"])
49
46
  else
50
47
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
51
48
  s.add_dependency(%q<activerecord>, [">= 3.0.0"])
52
- s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
49
+ s.add_dependency(%q<rails_paginate>, [">= 0.0.0"])
53
50
  end
54
51
  else
55
52
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
56
53
  s.add_dependency(%q<activerecord>, [">= 3.0.0"])
57
- s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
54
+ s.add_dependency(%q<rails_paginate>, [">= 0.0.0"])
58
55
  end
59
56
  end
60
57
 
data/lib/acts_as_extjs.rb CHANGED
@@ -1,6 +1,3 @@
1
- require 'rubygems'
2
- require 'active_record'
3
-
4
1
  module Extjs #:nodoc:
5
2
  module ActsAsExtjs #:nodoc:
6
3
 
@@ -12,16 +9,16 @@ module Extjs #:nodoc:
12
9
  # activate gem on ar-model with acts_as_extjs
13
10
  #
14
11
  # -----
15
- #
12
+ #
16
13
  # === Example:
17
- # class User
18
- # acts_as_extjs
19
- # end
20
- #
14
+ # class User
15
+ # acts_as_extjs
16
+ # end
17
+ #
21
18
  def acts_as_extjs
22
19
  scope :extjs
23
-
24
- include Extjs::ActsAsExtjs::InstanceMethods
20
+
21
+ include Extjs::ActsAsExtjs::InstanceMethods
25
22
  extend Extjs::ActsAsExtjs::SingletonMethods
26
23
  end
27
24
  end
@@ -34,28 +31,31 @@ module Extjs #:nodoc:
34
31
  # -----
35
32
  #
36
33
  # === Options:
37
- # <tt>:fields</tt>:: List with hashes like extjs store fields.
38
- # <tt>:name</tt>:: Name off field. This will be call on row if not use an custom handler
39
- # <tt>:custom</tt>:: can use with Proc.new for own field content
40
- # <tt>:mapping</tt>:: Client side mapping by extjs store
34
+ # <tt>:fields</tt>:: List with hashes like extjs store fields.
35
+ # <tt>:name</tt>:: Name off field. This will be call on row if not use an custom handler
36
+ # <tt>:custom</tt>:: can use with Proc.new for own field content
37
+ # <tt>:mapping</tt>:: Client side mapping by extjs store
41
38
  # <tt>:sort_mapping</tt>:: A Hash to map columns
42
- # :fieldname => "sqlfiels"
43
- # :user_name => "users.name"
44
- # <tt>:start</tt>:: start value from extjs paginate toolbar
45
- # <tt>:limit</tt>:: limit value from extjs paginate toolbar
46
- # <tt>:page</tt>:: page - will overritten if start/limit set
47
- # <tt>:per_page</tt>:: per_page - will overritten if start/limit set
48
- # <tt>:sort_by</tt>:: sort field. ignore fields that are not in sort_mapping and use this mapping
49
- # <tt>:group_by</tt>:: group field. ignore fields that are not in sort_mapping and use this mapping
50
- # <tt>:sort_dir</tt>:: direction: asc | desc
51
- # <tt>:group_dir</tt>:: direction: asc | desc
52
- #
39
+ # :fieldname => "sqlfiels"
40
+ # :user_name => "users.name"
41
+ # <tt>:start</tt>:: start value from extjs paginate toolbar
42
+ # <tt>:limit</tt>:: limit value from extjs paginate toolbar
43
+ # <tt>:page</tt>:: page - will overritten if start/limit set
44
+ # <tt>:per_page</tt>:: per_page - will overritten if start/limit set
45
+ # <tt>:sort_by</tt>:: sort field. ignore fields that are not in sort_mapping and use this mapping
46
+ # <tt>:group_by</tt>:: group field. ignore fields that are not in sort_mapping and use this mapping
47
+ # <tt>:sort_dir</tt>:: direction: asc | desc
48
+ # <tt>:group_dir</tt>:: direction: asc | desc
49
+ #
53
50
  # -----
54
- #
51
+ #
55
52
  # === Example:
56
- # render :json => User.extjs_result :fields = [{:name => :superid, :type => :id, :custom => Proc.new { |row| row.id }}]
53
+ # render :json => User.extjs_result :fields = [{:name => :superid, :type => :id, :custom => Proc.new { |row| row.id }}]
57
54
  #
58
55
  def extjs_result(*args)
56
+ extjs_scope = self.extjs
57
+
58
+
59
59
  options = args.extract_options!
60
60
  fields = options.delete(:fields)
61
61
  start = options.delete(:start).to_i
@@ -88,16 +88,17 @@ module Extjs #:nodoc:
88
88
  order = sort_mapping[group_by.to_sym].to_s + group_dir + ', ' + order
89
89
  end
90
90
 
91
- options[:order] = order if order
91
+ extjs_scope = extjs_scope.order(order) if order
92
92
  end
93
93
 
94
+
94
95
  if limit.to_i > 0 or options[:per_page].to_i > 0
95
96
  options[:per_page] = limit if limit > 0
96
97
  options[:page] = (start > 0) ? (start/limit)+1 : 1
97
- result = self.extjs.paginate options
98
- total = result.total_entries
98
+ result = extjs_scope.paginate options
99
+ total = result.total
99
100
  else
100
- result = self.extjs.all options
101
+ result = extjs_scope.all options
101
102
  total = result.size
102
103
  end
103
104
 
@@ -119,17 +120,17 @@ module Extjs #:nodoc:
119
120
  rows << row
120
121
  end
121
122
 
122
- return {
123
- :total => total,
124
- :data => rows,
125
- :metaData => {
126
- :root => :data,
127
- :messageProperty => 'message',
128
- :successProperty => 'success',
129
- :fields => fields,
130
- :idProperty => :id,
131
- :totalProperty => :total,
132
- }
123
+ {
124
+ :total => total,
125
+ :data => rows,
126
+ :metaData => {
127
+ :root => :data,
128
+ :messageProperty => 'message',
129
+ :successProperty => 'success',
130
+ :fields => fields,
131
+ :idProperty => :id,
132
+ :totalProperty => :total,
133
+ }
133
134
  }
134
135
  end
135
136
  end
@@ -159,10 +160,9 @@ module Extjs #:nodoc:
159
160
  end
160
161
  hash["#{self.class.name.downcase}[#{field}]"] = message
161
162
  end
162
- return hash
163
+ hash
163
164
  end
164
165
  end
165
166
  end
166
167
  end
167
-
168
168
  ActiveRecord::Base.send(:include, Extjs::ActsAsExtjs)
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_extjs
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
4
+ prerelease:
5
+ version: 0.3.3
10
6
  platform: ruby
11
7
  authors:
12
8
  - Marco Scholl
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-10-10 00:00:00 +02:00
13
+ date: 2011-04-19 00:00:00 +02:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,10 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 1
30
- - 2
31
- - 9
32
24
  version: 1.2.9
33
25
  type: :development
34
26
  version_requirements: *id001
@@ -40,26 +32,18 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- segments:
44
- - 3
45
- - 0
46
- - 0
47
35
  version: 3.0.0
48
36
  type: :runtime
49
37
  version_requirements: *id002
50
38
  - !ruby/object:Gem::Dependency
51
- name: will_paginate
39
+ name: rails_paginate
52
40
  prerelease: false
53
41
  requirement: &id003 !ruby/object:Gem::Requirement
54
42
  none: false
55
43
  requirements:
56
- - - ~>
44
+ - - ">="
57
45
  - !ruby/object:Gem::Version
58
- segments:
59
- - 3
60
- - 0
61
- - pre2
62
- version: 3.0.pre2
46
+ version: 0.0.0
63
47
  type: :runtime
64
48
  version_requirements: *id003
65
49
  description: ActiveRecord Helper for Extjs
@@ -72,7 +56,6 @@ extra_rdoc_files:
72
56
  - README.rdoc
73
57
  files:
74
58
  - .gemspec
75
- - .gitignore
76
59
  - MIT-LICENSE
77
60
  - README.rdoc
78
61
  - Rakefile
@@ -87,8 +70,8 @@ homepage: http://github.com/traxanos/acts_as_extjs
87
70
  licenses: []
88
71
 
89
72
  post_install_message:
90
- rdoc_options:
91
- - --charset=UTF-8
73
+ rdoc_options: []
74
+
92
75
  require_paths:
93
76
  - lib
94
77
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -96,24 +79,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
79
  requirements:
97
80
  - - ">="
98
81
  - !ruby/object:Gem::Version
99
- segments:
100
- - 0
101
82
  version: "0"
102
83
  required_rubygems_version: !ruby/object:Gem::Requirement
103
84
  none: false
104
85
  requirements:
105
86
  - - ">="
106
87
  - !ruby/object:Gem::Version
107
- segments:
108
- - 0
109
88
  version: "0"
110
89
  requirements: []
111
90
 
112
91
  rubyforge_project:
113
- rubygems_version: 1.3.7
92
+ rubygems_version: 1.6.2
114
93
  signing_key:
115
94
  specification_version: 3
116
95
  summary: ActiveRecord Helper for Extjs
117
96
  test_files:
118
- - spec/spec_helper.rb
119
97
  - spec/acts_as_extjs_spec.rb
98
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- # rcov generated
2
- coverage
3
-
4
- # rdoc generated
5
- rdoc
6
-
7
- # yard generated
8
- doc
9
- .yardoc
10
-
11
- # jeweler generated
12
- pkg