sencha-model 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -22,6 +22,9 @@ GEM
22
22
  i18n (0.5.0)
23
23
  mocha (0.9.12)
24
24
  shoulda (2.11.3)
25
+ sqlite3 (1.3.6)
26
+ sqlite3-ruby (1.3.3)
27
+ sqlite3 (>= 1.3.3)
25
28
  tzinfo (0.3.27)
26
29
 
27
30
  PLATFORMS
@@ -33,3 +36,4 @@ DEPENDENCIES
33
36
  mocha
34
37
  sencha-model!
35
38
  shoulda
39
+ sqlite3-ruby
data/README.rdoc CHANGED
@@ -4,9 +4,13 @@ A simple Model mixin with adapters for various ORM frameworks such as ActiveReco
4
4
 
5
5
 
6
6
  === Installation
7
- % sudo gem install gemcutter
8
- % sudo gem install sencha-model
7
+ % gem install sencha-model
9
8
 
9
+ or add the following line to your Rails Gemfile:
10
+ require 'sencha-model'
11
+
12
+ then run
13
+ bundle install
10
14
 
11
15
  === An ORM Model mixin: Sencha::Model
12
16
  sencha-model contains Model mixin named <tt>Sencha::Model</tt> which works for <b>three</b> popular ORM frameworks, ActiveRecord, DataMapper and MongoMapper. The API for each framework is identical and an adapter can be created for just about any
@@ -14,27 +18,26 @@ ORM in about an hour.
14
18
 
15
19
  Simply include the mixin into your model. Use the class-method <tt>sencha_fields</tt> to specify those
16
20
  fields with will be used to render a record to Hash for later JSON-encoding.
17
-
18
21
  class User < ActiveRecord::Base
19
22
  include Sencha::Model
20
23
 
21
24
  sencha_fields :exclude => [:password, :password_confirmation]
22
-
25
+
23
26
  # OR
24
27
  sencha_fields :name, :description
25
-
28
+
26
29
  # OR
27
30
  sencha_fields :only => [:name, :description] # actually the same as above
28
-
31
+
29
32
  # OR
30
33
  sencha_fields :additional => [:computed] # includes all database columns and an additional computed field
31
-
34
+
32
35
  # OR define a column as a Hash
33
36
  sencha_fields :description, :name => {"sortDir" => "ASC"}, :created_at => {"dateFormat" => "c"}
34
-
37
+
35
38
  # OR render associations, association-fields will have their "mapping" property set automatically
36
39
  sencha_fields :name, :description, :company => [:name, :description]
37
-
40
+
38
41
  def computed
39
42
  name.blank? ? login : name
40
43
  end
@@ -49,30 +52,28 @@ After including the model mixin <tt>Sencha::Model</tt>, try typing the following
49
52
  {:type=>'string', :allowBlank=>false, :name=>"email", :defaultValue => nil}
50
53
  ]}
51
54
 
52
- An auto-generated schema. This field-names were originally designed to be consumed by an <tt>Ext.data.Store</tt> from the {Ext JS Framework}[http://extjs.com]. TODO: make the field-names configurable.
55
+ An auto-generated schema. These field-names were originally designed to be consumed by an <tt>Ext.data.Store</tt> from the {Ext JS Framework}[http://extjs.com].
56
+ TODO: make the field-names configurable.
53
57
 
54
58
  You can also define different sets of fields for different representations of your model.
55
59
 
56
60
  E.g. with the following definition:
61
+ class User < ActiveRecord::Base
62
+ include Sencha::Model
63
+
64
+ sencha_fieldset :grid, [
65
+ :name, :description, {:company => [:name, :description]}
66
+ ]
57
67
 
58
- class User < ActiveRecord::Base
59
- include ExtJS::Model
60
-
61
- sencha_fieldset :grid, [
62
- :name,
63
- :description,
64
- {:company => [:name, :description]}
65
- ]
66
-
67
- sencha_fieldset :combo, [:full_name]
68
-
69
- ##
70
- # computed field
71
- #
72
- def full_name
73
- "#{first_name} #{name}"
74
- end
75
- end
68
+ sencha_fieldset :combo, [:full_name]
69
+
70
+ ##
71
+ # computed field
72
+ #
73
+ def full_name
74
+ "#{first_name} #{name}"
75
+ end
76
+ end
76
77
 
77
78
  You can get store configs for both representations with
78
79
  User.sencha_schema(:grid)
@@ -110,4 +111,4 @@ In individual model unit tests:
110
111
 
111
112
  == Copyright
112
113
 
113
- Copyright (c) 2009 Chris Scott. See LICENSE for details.
114
+ Copyright (c) 2009-2012 Chris Scott. See LICENSE for details.
@@ -219,7 +219,13 @@ module Sencha
219
219
  def sencha_fieldset(*params)
220
220
  fieldset, options = Util.extract_fieldset_and_options params
221
221
  var_name = :"@sencha_fieldsets__#{fieldset}"
222
- self.instance_variable_set( var_name, self.process_fields(*options[:fields]) )
222
+
223
+ begin
224
+ self.instance_variable_set( var_name, self.process_fields(*options[:fields]) )
225
+ rescue ActiveRecord::StatementInvalid => e
226
+ # check to see if we're running db:migrate here, swallow the exception if so.
227
+ raise e unless ( File.basename($0) == "rake" && ARGV.include?("db:migrate") )
228
+ end
223
229
  end
224
230
 
225
231
  def sencha_get_fields_for_fieldset(fieldset)
@@ -1,5 +1,5 @@
1
1
  module Sencha
2
2
  module Model
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
- end
5
+ end
data/sencha-model.gemspec CHANGED
@@ -8,92 +8,18 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Chris Scott"]
10
10
  s.email = ["christocracy@gmail.com"]
11
- s.homepage = "http://www.440solutions.com"
11
+ s.homepage = "http://www.transistorsoft.com"
12
12
  s.summary = %q{This gem auto-generates ExtJS compatible model specifications from your ORM (eg: ActiveRecord, DataMapper, MongoMapper)}
13
13
  s.description = %q{This gem auto-generates ExtJS compatible model specifications from your ORM (eg: ActiveRecord, DataMapper, MongoMapper)}
14
-
14
+
15
15
  s.add_development_dependency "shoulda"
16
16
  s.add_development_dependency "mocha"
17
17
  s.add_development_dependency "extlib"
18
18
  s.add_development_dependency "activerecord", ">= 3.0.0"
19
+ s.add_development_dependency "sqlite3-ruby"
19
20
 
20
21
  s.files = `git ls-files`.split("\n")
21
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
23
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
24
  s.require_paths = ["lib"]
24
25
  end
25
-
26
-
27
-
28
- # Generated by jeweler
29
- # DO NOT EDIT THIS FILE DIRECTLY
30
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
31
- # -*- encoding: utf-8 -*-
32
-
33
- #Gem::Specification.new do |s|
34
- # s.name = %q{whorm}
35
- # s.version = "0.4.0"
36
-
37
- # s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
38
- # s.authors = ["Chris Scott"]
39
- # s.date = %q{2010-03-09}
40
- # s.description = %q{Whorm contains a Model-mixin named Whorm::Model. Once included, your Model now exposes a class-method named #whorm_schema which will return Hash representation of the Model-schema.}
41
- # s.email = %q{christocracy@gmail.com}
42
- # s.extra_rdoc_files = [
43
- ## "LICENSE",
44
- # "README.rdoc"
45
- # ]
46
- # s.files = [
47
- # "LICENSE",
48
- # "README.rdoc",
49
- # "Rakefile",
50
- # "VERSION",
51
- # "lib/test/macros.rb",
52
- # "lib/whorm.rb",
53
- # "lib/whorm/adapters/active_record.rb",
54
- # "lib/whorm/adapters/data_mapper.rb",
55
- # "lib/whorm/adapters/mongo_mapper.rb",
56
- # "lib/whorm/model.rb",
57
- # "test/active_record_test.rb",
58
- # "test/app/config/application.rb",
59
- # "test/app/config/database.yml",
60
- # "test/app/db/schema.rb",
61
- # "test/app/models/active_record/address.rb",
62
- # "test/app/models/active_record/data_type.rb",
63
- # "test/app/models/active_record/group.rb",
64
- # "test/app/models/active_record/house.rb",
65
- # "test/app/models/active_record/location.rb",
66
- # "test/app/models/active_record/person.rb",
67
- # "test/app/models/active_record/user.rb",
68
- # "test/app/models/active_record/user_group.rb",
69
- # "test/data_mapper_test.rb",
70
- # "test/model_test.rb",
71
- # "test/mongo_mapper_test.rb",
72
- # "test/test_helper.rb"
73
- # ]
74
- # s.homepage = %q{http://github.com/christocracy/whorm}
75
- # s.rdoc_options = ["--charset=UTF-8"]
76
- # s.require_paths = ["lib"]
77
- # s.rubygems_version = %q{1.3.6}
78
- # s.summary = %q{Ruby ORM-inspecting tools to assist with generating JSON representations of database schemas and recordsets.}
79
-
80
- # if s.respond_to? :specification_version then
81
- # current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
82
- # s.specification_version = 3
83
-
84
- # if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
85
- # s.add_development_dependency(%q<shoulda>, [">= 0"])
86
- # s.add_development_dependency(%q<mocha>, [">= 0"])
87
- # s.add_development_dependency(%q<extlib>, [">= 0"])
88
- # else
89
- # s.add_dependency(%q<shoulda>, [">= 0"])
90
- ## s.add_dependency(%q<mocha>, [">= 0"])
91
- # s.add_dependency(%q<extlib>, [">= 0"])
92
- # end
93
- # else
94
- # s.add_dependency(%q<shoulda>, [">= 0"])
95
- # s.add_dependency(%q<mocha>, [">= 0"])
96
- # s.add_dependency(%q<extlib>, [">= 0"])
97
- # end
98
- #end
99
-
data/test/model_test.rb CHANGED
@@ -163,6 +163,12 @@ class ModelTest < Test::Unit::TestCase
163
163
  assert_array_has_item(fields, 'has person_last') {|f| f[:name] === "person_last" and f[:mapping] == "person.last" }
164
164
  assert_array_has_item(fields, 'has person_first') {|f| f[:name] === "person_first" and f[:mapping] == "person.first" }
165
165
  end
166
+ should "produce ExtJS 4 compatible belongsTo associations in schema" do
167
+ schema = User.sencha_schema
168
+ assert schema[:associations].length > 0
169
+ # TODO fix Ext4 associations
170
+ end
171
+
166
172
  should "produce a valid to_record record" do
167
173
  person = Person.create!(:first => 'first', :last => 'last', :email => 'email')
168
174
  user = User.create!(:person_id => person.id, :password => 'password')
metadata CHANGED
@@ -1,72 +1,104 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sencha-model
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
4
5
  prerelease:
5
- version: 0.5.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Chris Scott
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-30 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: shoulda
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
25
22
  type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: mocha
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: mocha
32
+ requirement: !ruby/object:Gem::Requirement
31
33
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
36
38
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: extlib
40
39
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: extlib
48
+ requirement: !ruby/object:Gem::Requirement
42
49
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
47
54
  type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
50
63
  name: activerecord
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 3.0.0
70
+ type: :development
51
71
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
53
73
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
57
77
  version: 3.0.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: sqlite3-ruby
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
58
86
  type: :development
59
- version_requirements: *id004
60
- description: "This gem auto-generates ExtJS compatible model specifications from your ORM (eg: ActiveRecord, DataMapper, MongoMapper)"
61
- email:
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: ! 'This gem auto-generates ExtJS compatible model specifications from
95
+ your ORM (eg: ActiveRecord, DataMapper, MongoMapper)'
96
+ email:
62
97
  - christocracy@gmail.com
63
98
  executables: []
64
-
65
99
  extensions: []
66
-
67
100
  extra_rdoc_files: []
68
-
69
- files:
101
+ files:
70
102
  - .document
71
103
  - .gitignore
72
104
  - Gemfile
@@ -74,7 +106,6 @@ files:
74
106
  - LICENSE
75
107
  - README.rdoc
76
108
  - Rakefile
77
- - VERSION
78
109
  - lib/sencha-model.rb
79
110
  - lib/sencha-model/adapters/active_record.rb
80
111
  - lib/sencha-model/adapters/data_mapper.rb
@@ -100,35 +131,32 @@ files:
100
131
  - test/model_test.rb
101
132
  - test/mongo_mapper_test.rb
102
133
  - test/test_helper.rb
103
- has_rdoc: true
104
- homepage: http://www.440solutions.com
134
+ homepage: http://www.transistorsoft.com
105
135
  licenses: []
106
-
107
136
  post_install_message:
108
137
  rdoc_options: []
109
-
110
- require_paths:
138
+ require_paths:
111
139
  - lib
112
- required_ruby_version: !ruby/object:Gem::Requirement
140
+ required_ruby_version: !ruby/object:Gem::Requirement
113
141
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
147
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: "0"
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
124
152
  requirements: []
125
-
126
153
  rubyforge_project:
127
- rubygems_version: 1.5.0
154
+ rubygems_version: 1.8.23
128
155
  signing_key:
129
156
  specification_version: 3
130
- summary: "This gem auto-generates ExtJS compatible model specifications from your ORM (eg: ActiveRecord, DataMapper, MongoMapper)"
131
- test_files:
157
+ summary: ! 'This gem auto-generates ExtJS compatible model specifications from your
158
+ ORM (eg: ActiveRecord, DataMapper, MongoMapper)'
159
+ test_files:
132
160
  - test/active_record_test.rb
133
161
  - test/app/config/application.rb
134
162
  - test/app/config/database.yml
@@ -145,3 +173,4 @@ test_files:
145
173
  - test/model_test.rb
146
174
  - test/mongo_mapper_test.rb
147
175
  - test/test_helper.rb
176
+ has_rdoc:
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.0