ohm-arfreaks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.markdown +44 -0
- data/Rakefile +51 -0
- data/lib/ohm-arfreaks.rb +34 -0
- metadata +59 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 maiha@wota.jp
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Ohm ARFreaks
|
2
|
+
============
|
3
|
+
|
4
|
+
Ohm::Model extensions for AR freaks
|
5
|
+
|
6
|
+
|
7
|
+
Install
|
8
|
+
-------
|
9
|
+
|
10
|
+
$ sudo gem install ohm-arfreaks
|
11
|
+
|
12
|
+
|
13
|
+
Models
|
14
|
+
------
|
15
|
+
|
16
|
+
AR freaks will be puzzled that Ohm::Model lacks well known methods like first, count, etc.
|
17
|
+
This library provides some of them to Ohm::Model.
|
18
|
+
|
19
|
+
### Example
|
20
|
+
|
21
|
+
require 'ohm-arfreaks'
|
22
|
+
|
23
|
+
class Page < Ohm::Model
|
24
|
+
attribute :url
|
25
|
+
end
|
26
|
+
|
27
|
+
Page.first
|
28
|
+
# => #<Page:1 url="http://...">
|
29
|
+
|
30
|
+
Page.create!(:url=>...)
|
31
|
+
|
32
|
+
Page.new.save!
|
33
|
+
|
34
|
+
|
35
|
+
Homepage
|
36
|
+
--------
|
37
|
+
|
38
|
+
http://github.com/maiha/ohm-arfreaks
|
39
|
+
|
40
|
+
|
41
|
+
Author
|
42
|
+
------
|
43
|
+
|
44
|
+
maiha@wota.jp
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
GEM_NAME = "ohm-arfreaks"
|
5
|
+
AUTHOR = "maiha"
|
6
|
+
EMAIL = "maiha@wota.jp"
|
7
|
+
HOMEPAGE = "http://github.com/maiha/ohm-arfreaks"
|
8
|
+
SUMMARY = "Ohm::Model extensions for AR freaks"
|
9
|
+
GEM_VERSION = "0.0.1"
|
10
|
+
|
11
|
+
spec = Gem::Specification.new do |s|
|
12
|
+
s.rubyforge_project = 'asakusarb'
|
13
|
+
s.executables = []
|
14
|
+
s.name = GEM_NAME
|
15
|
+
s.version = GEM_VERSION
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.extra_rdoc_files = ["README.markdown", "LICENSE"]
|
19
|
+
s.summary = SUMMARY
|
20
|
+
s.description = s.summary
|
21
|
+
s.author = AUTHOR
|
22
|
+
s.email = EMAIL
|
23
|
+
s.homepage = HOMEPAGE
|
24
|
+
s.require_path = 'lib'
|
25
|
+
s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("{lib,spec,app,public,stubs}/**/*")
|
26
|
+
end
|
27
|
+
|
28
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
29
|
+
pkg.gem_spec = spec
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Install the gem"
|
33
|
+
task :install do
|
34
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Uninstall the gem"
|
38
|
+
task :uninstall do
|
39
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Create a gemspec file"
|
43
|
+
task :gemspec do
|
44
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
45
|
+
file.puts spec.to_ruby
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
require 'spec/rake/spectask'
|
50
|
+
desc 'Default: run spec examples'
|
51
|
+
task :default => 'spec'
|
data/lib/ohm-arfreaks.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Ohm
|
2
|
+
class Model
|
3
|
+
######################################################################
|
4
|
+
### Validations
|
5
|
+
|
6
|
+
RecordNotSaved = Class.new(RuntimeError)
|
7
|
+
|
8
|
+
def self.create!(attributes)
|
9
|
+
object = new(attributes)
|
10
|
+
object.save!
|
11
|
+
object
|
12
|
+
end
|
13
|
+
|
14
|
+
def save!
|
15
|
+
save || raise(RecordNotSaved)
|
16
|
+
end
|
17
|
+
|
18
|
+
######################################################################
|
19
|
+
### Accessor methods
|
20
|
+
|
21
|
+
def self.first(*args)
|
22
|
+
(args.empty? ? all : find(*args)).first
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.last(*args)
|
26
|
+
(args.empty? ? all : find(*args)).last
|
27
|
+
end
|
28
|
+
|
29
|
+
# TODO: should use native 'count' method for performance reason
|
30
|
+
def self.count(*args)
|
31
|
+
(args.empty? ? all : find(*args)).size
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ohm-arfreaks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- maiha
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-05 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Ohm::Model extensions for AR freaks
|
17
|
+
email: maiha@wota.jp
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.markdown
|
24
|
+
- LICENSE
|
25
|
+
files:
|
26
|
+
- LICENSE
|
27
|
+
- README.markdown
|
28
|
+
- Rakefile
|
29
|
+
- lib/ohm-arfreaks.rb
|
30
|
+
has_rdoc: true
|
31
|
+
homepage: http://github.com/maiha/ohm-arfreaks
|
32
|
+
licenses: []
|
33
|
+
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
rubyforge_project: asakusarb
|
54
|
+
rubygems_version: 1.3.5
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Ohm::Model extensions for AR freaks
|
58
|
+
test_files: []
|
59
|
+
|