sample_models 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,40 +1,25 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.1.0)
5
- activesupport (= 3.1.0)
6
- bcrypt-ruby (~> 3.0.0)
7
- builder (~> 3.0.0)
8
- i18n (~> 0.6)
9
- activerecord (3.1.0)
10
- activemodel (= 3.1.0)
11
- activesupport (= 3.1.0)
12
- arel (~> 2.2.1)
13
- tzinfo (~> 0.3.29)
14
- activesupport (3.1.0)
15
- multi_json (~> 1.0)
16
- arel (2.2.1)
17
- bcrypt-ruby (3.0.1)
18
- builder (3.0.0)
4
+ activerecord (2.3.14)
5
+ activesupport (= 2.3.14)
6
+ activesupport (2.3.14)
19
7
  git (1.2.5)
20
- i18n (0.6.0)
21
8
  jeweler (1.6.0)
22
9
  bundler (~> 1.0.0)
23
10
  git (>= 1.2.5)
24
11
  rake
25
- multi_json (1.0.3)
26
12
  rake (0.8.7)
27
13
  sqlite3 (1.3.4)
28
- tzinfo (0.3.29)
29
- validates_email_format_of (1.5.2)
14
+ validates_email_format_of (1.4.7)
30
15
 
31
16
  PLATFORMS
32
17
  ruby
33
18
 
34
19
  DEPENDENCIES
35
- activerecord (= 3.1.0)
36
- activesupport (= 3.1.0)
20
+ activerecord (= 2.3.14)
21
+ activesupport (= 2.3.14)
37
22
  bundler (~> 1.0.0)
38
23
  jeweler (~> 1.6.0)
39
24
  sqlite3
40
- validates_email_format_of (~> 1.5.0)
25
+ validates_email_format_of (~> 1.4.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.1
@@ -32,16 +32,22 @@ module SampleModels
32
32
  def run
33
33
  attrs = @specified_attrs.clone
34
34
  @sampler.defaults.each do |attr, val|
35
- attrs[attr] = val unless attrs.member?(attr)
35
+ unless attrs.member?(attr) ||
36
+ ((assoc = model.belongs_to_association(attr)) &&
37
+ (attrs.member?(assoc.name) || attrs.member?(assoc.foreign_key)))
38
+ attrs[attr] = val
39
+ end
36
40
  end
37
- columns_to_fill = model.columns.clone
41
+ columns_to_fill = model.columns.clone.reject { |c|
42
+ c.name == 'id' || timestamp?(c.name)
43
+ }
38
44
  model.validated_attr_accessors.each do |attr|
39
45
  columns_to_fill << VirtualColumn.new(attr)
40
46
  end
41
47
  columns_to_fill.each do |column|
42
48
  unless attrs.member?(column.name) ||
43
49
  specified_association_value?(column.name) ||
44
- ((assoc = belongs_to_assoc(column.name)) && attrs.member?(assoc.name)) || timestamp?(column.name)
50
+ ((assoc = belongs_to_assoc(column.name)) && attrs.member?(assoc.name))
45
51
  sequence = @sampler.first_pass_attribute_sequence(column)
46
52
  attrs[column.name] = sequence.value
47
53
  end
@@ -55,8 +55,8 @@ module SampleModels
55
55
  Attribute.new(@sampler, meth)
56
56
  elsif @sampler.model.belongs_to_association(meth)
57
57
  Attribute.new(@sampler, meth)
58
- elsif @sampler.model.instance_methods.include?(meth.to_s) &&
59
- @sampler.model.instance_methods.include?("#{meth.to_s}=")
58
+ elsif @sampler.model.instance_methods.map(&:to_sym).include?(meth) &&
59
+ @sampler.model.instance_methods.map(&:to_sym).include?("#{meth.to_s}=".to_sym)
60
60
  Attribute.new(@sampler, meth)
61
61
  elsif meth.to_s =~ /(.*)_sample$/
62
62
  @sampler.named_samples[$1] = args.first
data/log/.gitkeep ADDED
File without changes
@@ -4,21 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{sample_models}
8
- s.version = "2.0.0"
7
+ s.name = "sample_models"
8
+ s.version = "2.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Francis Hwang"]
12
- s.date = %q{2011-11-22}
13
- s.description = %q{
14
- A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:
15
-
16
- * meet all your validations automatically
17
- * only make you specify the attributes you care about
18
- * give you a rich set of features so you can specify associated values as concisely as possible
19
- * do this with as little configuration as possible
20
- }
21
- s.email = %q{francis.hwang@profitably.com}
12
+ s.date = "2012-03-02"
13
+ s.description = "\nA library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:\n\n* meet all your validations automatically\n* only make you specify the attributes you care about\n* give you a rich set of features so you can specify associated values as concisely as possible\n* do this with as little configuration as possible\n"
14
+ s.email = "francis.hwang@profitably.com"
22
15
  s.extra_rdoc_files = [
23
16
  "README.markdown"
24
17
  ]
@@ -37,6 +30,7 @@ A library for making it extremely fast for Rails developers to set up and save A
37
30
  "lib/sample_models/initializer.rb",
38
31
  "lib/sample_models/model.rb",
39
32
  "lib/sample_models/sampler.rb",
33
+ "log/.gitkeep",
40
34
  "sample_models.gemspec",
41
35
  "tasks/sample_models_tasks.rake",
42
36
  "test/db/placeholder",
@@ -51,11 +45,11 @@ A library for making it extremely fast for Rails developers to set up and save A
51
45
  "test/unit/sample_test.rb",
52
46
  "uninstall.rb"
53
47
  ]
54
- s.homepage = %q{http://github.com/fhwang/sample_models}
48
+ s.homepage = "http://github.com/fhwang/sample_models"
55
49
  s.licenses = ["MIT"]
56
50
  s.require_paths = ["lib"]
57
- s.rubygems_version = %q{1.6.2}
58
- s.summary = %q{A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases}
51
+ s.rubygems_version = "1.8.17"
52
+ s.summary = "A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases"
59
53
 
60
54
  if s.respond_to? :specification_version then
61
55
  s.specification_version = 3
data/test/test_helper.rb CHANGED
@@ -8,11 +8,11 @@ rescue Bundler::BundlerError => e
8
8
  exit e.status_code
9
9
  end
10
10
 
11
- require 'test/setup/schema'
11
+ require File.expand_path(File.join(File.dirname(__FILE__), 'setup/schema'))
12
12
  require 'validates_email_format_of'
13
13
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
14
  require 'sample_models'
15
- require 'test/setup/models'
15
+ require File.expand_path(File.join(File.dirname(__FILE__), 'setup/models'))
16
16
  require 'test/unit'
17
17
 
18
18
  class SampleModelsTestCase < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + "/../test_helper"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '/../test_helper'))
2
2
 
3
3
  class ConfigurationTest < SampleModelsTestCase
4
4
  def test_model_with_configured_default
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sample_models
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
4
  prerelease:
6
- segments:
7
- - 2
8
- - 0
9
- - 0
10
- version: 2.0.0
5
+ version: 2.0.1
11
6
  platform: ruby
12
7
  authors:
13
8
  - Francis Hwang
@@ -15,78 +10,58 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-11-22 00:00:00 -05:00
19
- default_executable:
13
+ date: 2012-03-02 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: activerecord
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &id001 !ruby/object:Gem::Requirement
24
18
  none: false
25
19
  requirements:
26
20
  - - ">="
27
21
  - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
22
  version: "0"
32
- prerelease: false
33
23
  type: :runtime
34
- requirement: *id001
24
+ prerelease: false
25
+ version_requirements: *id001
35
26
  - !ruby/object:Gem::Dependency
36
27
  name: activesupport
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &id002 !ruby/object:Gem::Requirement
38
29
  none: false
39
30
  requirements:
40
31
  - - ">="
41
32
  - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
33
  version: "0"
46
- prerelease: false
47
34
  type: :runtime
48
- requirement: *id002
35
+ prerelease: false
36
+ version_requirements: *id002
49
37
  - !ruby/object:Gem::Dependency
50
38
  name: bundler
51
- version_requirements: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &id003 !ruby/object:Gem::Requirement
52
40
  none: false
53
41
  requirements:
54
42
  - - ~>
55
43
  - !ruby/object:Gem::Version
56
- hash: 23
57
- segments:
58
- - 1
59
- - 0
60
- - 0
61
44
  version: 1.0.0
62
- prerelease: false
63
45
  type: :development
64
- requirement: *id003
46
+ prerelease: false
47
+ version_requirements: *id003
65
48
  - !ruby/object:Gem::Dependency
66
49
  name: jeweler
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &id004 !ruby/object:Gem::Requirement
68
51
  none: false
69
52
  requirements:
70
53
  - - ~>
71
54
  - !ruby/object:Gem::Version
72
- hash: 15
73
- segments:
74
- - 1
75
- - 6
76
- - 0
77
55
  version: 1.6.0
78
- prerelease: false
79
56
  type: :development
80
- requirement: *id004
81
- description: |
82
-
83
- A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:
84
-
85
- * meet all your validations automatically
86
- * only make you specify the attributes you care about
87
- * give you a rich set of features so you can specify associated values as concisely as possible
88
- * do this with as little configuration as possible
89
-
57
+ prerelease: false
58
+ version_requirements: *id004
59
+ description: "\n\
60
+ A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:\n\n\
61
+ * meet all your validations automatically\n\
62
+ * only make you specify the attributes you care about\n\
63
+ * give you a rich set of features so you can specify associated values as concisely as possible\n\
64
+ * do this with as little configuration as possible\n"
90
65
  email: francis.hwang@profitably.com
91
66
  executables: []
92
67
 
@@ -109,6 +84,7 @@ files:
109
84
  - lib/sample_models/initializer.rb
110
85
  - lib/sample_models/model.rb
111
86
  - lib/sample_models/sampler.rb
87
+ - log/.gitkeep
112
88
  - sample_models.gemspec
113
89
  - tasks/sample_models_tasks.rake
114
90
  - test/db/placeholder
@@ -122,7 +98,6 @@ files:
122
98
  - test/unit/polymorphic_belongs_to_test.rb
123
99
  - test/unit/sample_test.rb
124
100
  - uninstall.rb
125
- has_rdoc: true
126
101
  homepage: http://github.com/fhwang/sample_models
127
102
  licenses:
128
103
  - MIT
@@ -136,23 +111,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
111
  requirements:
137
112
  - - ">="
138
113
  - !ruby/object:Gem::Version
139
- hash: 3
140
- segments:
141
- - 0
142
114
  version: "0"
143
115
  required_rubygems_version: !ruby/object:Gem::Requirement
144
116
  none: false
145
117
  requirements:
146
118
  - - ">="
147
119
  - !ruby/object:Gem::Version
148
- hash: 3
149
- segments:
150
- - 0
151
120
  version: "0"
152
121
  requirements: []
153
122
 
154
123
  rubyforge_project:
155
- rubygems_version: 1.6.2
124
+ rubygems_version: 1.8.17
156
125
  signing_key:
157
126
  specification_version: 3
158
127
  summary: A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases