rails_tiny_ds 0.0.2
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/LICENSE +20 -0
- data/README.rdoc +32 -0
- data/Rakefile +31 -0
- data/generators/rspec_td_model/td_dm_model_generator.rb +23 -0
- data/generators/rspec_td_model/templates/model_spec.rb +9 -0
- data/generators/td_model/td_model_generator.rb +24 -0
- data/generators/td_model/templates/model.rb +20 -0
- data/generators/td_model/templates/unit_test.rb +8 -0
- data/lib/rails_tiny_ds.rb +10 -0
- metadata +86 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 John Woodell, woodie@netpress.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= Rails TinyDS Plugin
|
2
|
+
|
3
|
+
This is an integration plugin for TinyDS that provides certain
|
4
|
+
ActiveRecord method calls for Rails 2.3.5 generated scaffold.
|
5
|
+
|
6
|
+
== Work with AR Scaffold
|
7
|
+
|
8
|
+
Add the following to your Gemfile
|
9
|
+
|
10
|
+
gem 'rails_tiny_ds'
|
11
|
+
|
12
|
+
Add the following to the initializer in config/environment.rb
|
13
|
+
|
14
|
+
require 'tiny_ds'
|
15
|
+
require 'rails_tiny_ds'
|
16
|
+
|
17
|
+
== Generate TinyDS Models
|
18
|
+
|
19
|
+
Install as an MRI gem to use these rake tasks:
|
20
|
+
|
21
|
+
script/generate td_model
|
22
|
+
script/generate rspec_td_model
|
23
|
+
|
24
|
+
Example:
|
25
|
+
|
26
|
+
./script/generate td_model article title:string summary:text -f
|
27
|
+
./script/generate td_model author name:string age:integer -—skip-timestamps
|
28
|
+
|
29
|
+
These are based on generators in rails_datamapper gem
|
30
|
+
|
31
|
+
--
|
32
|
+
Author: John Woodell, woodie@netpress.com
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require File.dirname(__FILE__) + '/../../lib/tiny_ds/version'
|
4
|
+
|
5
|
+
RAILS_VERSION = "2.3.5"
|
6
|
+
|
7
|
+
spec = Gem::Specification.new do |s|
|
8
|
+
s.name = "rails_tiny_ds"
|
9
|
+
s.version = TinyDS::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.has_rdoc = false
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
|
13
|
+
s.description = "A Rails integration plugin for TinyDS"
|
14
|
+
s.summary = "This is an integration plugin for TinyDS, that provides " +
|
15
|
+
"ActiveRecord method calls for Rails #{RAILS_VERSION} generated scaffold"
|
16
|
+
s.authors = ["John Woodell", "Takeru Sasaki"]
|
17
|
+
s.email = ["woodie@netpress.com", "sasaki.takeru@gmail.com"]
|
18
|
+
s.homepage = "http://github.com/woodie/tiny_ds/" +
|
19
|
+
"tree/master/adapters/rails_tiny_ds"
|
20
|
+
s.require_path = 'lib'
|
21
|
+
s.files = %w(LICENSE README.rdoc Rakefile) +
|
22
|
+
Dir.glob("generators/**/*") + Dir.glob("lib/**/*")
|
23
|
+
s.add_dependency 'tiny_ds', "#{TinyDS::VERSION}"
|
24
|
+
s.add_dependency 'rails', "#{RAILS_VERSION}"
|
25
|
+
end
|
26
|
+
|
27
|
+
task :default => :gem
|
28
|
+
|
29
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
30
|
+
pkg.gem_spec = spec
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails_generator/generators/components/model/model_generator'
|
2
|
+
require 'active_record'
|
3
|
+
|
4
|
+
class RspecTdModelGenerator < ModelGenerator
|
5
|
+
|
6
|
+
def manifest
|
7
|
+
record do |m|
|
8
|
+
|
9
|
+
# Check for class naming collisions.
|
10
|
+
m.class_collisions class_path, class_name
|
11
|
+
|
12
|
+
# Model, spec, and fixture directories.
|
13
|
+
m.directory File.join('app/models', class_path)
|
14
|
+
m.directory File.join('spec/models', class_path)
|
15
|
+
|
16
|
+
# Model class, spec and fixtures.
|
17
|
+
m.template 'td_model:model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
18
|
+
m.template 'model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb")
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), <%= ([ "'..'" ] * class_nesting_depth).join(', ') %>, '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe <%= class_name %> do
|
4
|
+
before(:each) do
|
5
|
+
@<%= file_name %> = <%= class_name %>.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should be awesome'
|
9
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails_generator/generators/components/model/model_generator'
|
2
|
+
require 'active_record'
|
3
|
+
require 'tiny_ds/base'
|
4
|
+
|
5
|
+
class TdModelGenerator < ModelGenerator
|
6
|
+
|
7
|
+
def manifest
|
8
|
+
record do |m|
|
9
|
+
|
10
|
+
# Check for class naming collisions.
|
11
|
+
m.class_collisions class_path, class_name, "#{class_name}Test"
|
12
|
+
|
13
|
+
# Model, test, and fixture directories.
|
14
|
+
m.directory File.join('app/models', class_path)
|
15
|
+
m.directory File.join('test/unit', class_path)
|
16
|
+
|
17
|
+
# Model class, unit test, and fixtures.
|
18
|
+
m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
19
|
+
m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% min = max = 10
|
2
|
+
Array(attributes).each do |attribute|
|
3
|
+
if TinyDS::Base::RESERVED_PROPERTY_NAME.include? attribute.name.to_sym
|
4
|
+
raise "reserved property name '#{attribute.name}'"
|
5
|
+
elsif !TinyDS::Base::VALID_PROPERTY_TYPE.include? attribute.type
|
6
|
+
raise "unknown property type '#{attribute.type}'"
|
7
|
+
end
|
8
|
+
max = attribute.name.size if attribute.name.size > max -%>
|
9
|
+
<% end -%>
|
10
|
+
class <%= class_name %> < TinyDS::Base
|
11
|
+
<% Array(attributes).each do |attribute|
|
12
|
+
pad = max - attribute.name.size
|
13
|
+
%> property :<%= attribute.name
|
14
|
+
%>, <%= " " * pad %><%= ":#{attribute.type}" %>
|
15
|
+
<% end -%>
|
16
|
+
<% unless options[:skip_timestamps] -%>
|
17
|
+
property :created_at, <%= " " * (max - min) %>:time
|
18
|
+
property :updated_at, <%= " " * (max - min) %>:time
|
19
|
+
<% end -%>
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module TinyDS
|
2
|
+
class Base
|
3
|
+
# convert calls from Rails generated scaffold
|
4
|
+
def self.all; self.query.all; end
|
5
|
+
def self.find(id); self.get_by_id(id); end
|
6
|
+
def to_param; id.to_s; end
|
7
|
+
def update_attributes(values); self.attributes = values; save; end
|
8
|
+
def errors; []; end # TODO: add basic validations
|
9
|
+
end
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_tiny_ds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Woodell
|
8
|
+
- Takeru Sasaki
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-01-05 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: tiny_ds
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - "="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.2
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rails
|
28
|
+
type: :runtime
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.3.5
|
35
|
+
version:
|
36
|
+
description: A Rails integration plugin for TinyDS
|
37
|
+
email:
|
38
|
+
- woodie@netpress.com
|
39
|
+
- sasaki.takeru@gmail.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files:
|
45
|
+
- README.rdoc
|
46
|
+
- LICENSE
|
47
|
+
files:
|
48
|
+
- LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- generators/rspec_td_model/td_dm_model_generator.rb
|
52
|
+
- generators/rspec_td_model/templates/model_spec.rb
|
53
|
+
- generators/td_model/td_model_generator.rb
|
54
|
+
- generators/td_model/templates/model.rb
|
55
|
+
- generators/td_model/templates/unit_test.rb
|
56
|
+
- lib/rails_tiny_ds.rb
|
57
|
+
has_rdoc: true
|
58
|
+
homepage: http://github.com/woodie/tiny_ds/tree/master/adapters/rails_tiny_ds
|
59
|
+
licenses: []
|
60
|
+
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.5
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: This is an integration plugin for TinyDS, that provides ActiveRecord method calls for Rails 2.3.5 generated scaffold
|
85
|
+
test_files: []
|
86
|
+
|