basic_model 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ .rvmrc
3
+ pkg
4
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ gemfile:
5
+ - gemfiles/Gemfile.activemodel-3.0.x
6
+ - gemfiles/Gemfile.activemodel-3.1.x
7
+
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ task :default => :test
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.test_files = FileList['test/*_test.rb']
7
+ end
8
+
9
+ require 'bundler'
10
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'basic_model/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'basic_model'
7
+ s.version = BasicModel::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Pete Browne']
10
+ s.email = ['me@petebrowne.com']
11
+ s.homepage = 'http://github.com/petebrowne/basic_model'
12
+ s.summary = 'BasicModel is a tiny Module that complies with the ActiveModel API'
13
+ s.description = 'BasicModel is intended to be used in a tableless model in Rails >= 3.0. It complies with the ActiveModel API and includes valdiations, so it can be used in form helpers without a problem.'
14
+
15
+ s.rubyforge_project = 'basic_model'
16
+
17
+ s.add_dependency 'activemodel', '~> 3.0'
18
+ s.add_dependency 'activesupport', '~> 3.0'
19
+ s.add_development_dependency 'rake'
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = %w(lib)
25
+ end
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem 'basic_model', :path => File.expand_path('../..', __FILE__)
4
+
5
+ gem 'activemodel', '~> 3.0.0'
6
+ gem 'activesupport', '~> 3.0.0'
7
+
8
+ gem 'rake', :group => :development
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem 'basic_model', :path => File.expand_path('../..', __FILE__)
4
+
5
+ gem 'activemodel', '~> 3.1.0'
6
+ gem 'activesupport', '~> 3.1.0'
7
+
8
+ gem 'rake', :group => :development
@@ -0,0 +1,3 @@
1
+ module BasicModel
2
+ VERSION = "0.3.2"
3
+ end
data/lib/basic_model.rb CHANGED
@@ -1,9 +1,8 @@
1
+ require "basic_model/version"
1
2
  require "active_model"
2
3
  require "active_support/concern"
3
4
 
4
5
  module BasicModel
5
- VERSION = "0.3.1"
6
-
7
6
  extend ActiveSupport::Concern
8
7
  include ActiveModel::Conversion
9
8
  include ActiveModel::Validations
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ Bundler.require
4
+ require 'test/unit'
5
+
6
+ class Post
7
+ include BasicModel
8
+ attr_accessor :title, :body
9
+
10
+ private
11
+
12
+ def not_allowed=(value)
13
+ raise 'Not Allowed!'
14
+ end
15
+ end
16
+
17
+ class Comment
18
+ include BasicModel
19
+ include ActiveModel::MassAssignmentSecurity
20
+ attr_accessor :name, :comment, :spam
21
+
22
+ attr_accessible :name, :comment
23
+ end
24
+
25
+ class BasicModelTest < ActiveSupport::TestCase
26
+ include ActiveModel::Lint::Tests
27
+
28
+ def setup
29
+ @model = Post.new
30
+ end
31
+
32
+ def test_initialize_with_attributes
33
+ @model = Post.new(:title => 'Title', :body => 'Body')
34
+ assert_equal 'Title', @model.title
35
+ assert_equal 'Body', @model.body
36
+ end
37
+
38
+ def test_do_not_call_private_methods
39
+ assert_nothing_raised do
40
+ Post.new(:not_allowed => 'Oops')
41
+ end
42
+ end
43
+
44
+ def test_mass_security_assignment
45
+ @model = Comment.new(:name => 'Bob', :comment => 'Great post!', :spam => false)
46
+ assert_nil @model.spam
47
+ end
48
+
49
+ def test_initialize_with_yield
50
+ @model = Post.new do |post|
51
+ post.title = 'Title'
52
+ end
53
+ assert_equal 'Title', @model.title
54
+ end
55
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basic_model
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pete Browne
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-30 00:00:00 Z
18
+ date: 2011-09-06 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel
@@ -71,9 +71,18 @@ extensions: []
71
71
  extra_rdoc_files: []
72
72
 
73
73
  files:
74
- - lib/basic_model.rb
74
+ - .gitignore
75
+ - .travis.yml
76
+ - Gemfile
75
77
  - LICENSE
76
78
  - README.md
79
+ - Rakefile
80
+ - basic_model.gemspec
81
+ - gemfiles/Gemfile.activemodel-3.0.x
82
+ - gemfiles/Gemfile.activemodel-3.1.x
83
+ - lib/basic_model.rb
84
+ - lib/basic_model/version.rb
85
+ - test/basic_model_test.rb
77
86
  homepage: http://github.com/petebrowne/basic_model
78
87
  licenses: []
79
88
 
@@ -107,5 +116,5 @@ rubygems_version: 1.8.5
107
116
  signing_key:
108
117
  specification_version: 3
109
118
  summary: BasicModel is a tiny Module that complies with the ActiveModel API
110
- test_files: []
111
-
119
+ test_files:
120
+ - test/basic_model_test.rb