machinist_activeresource 0.0.1
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/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/lib/machinist_activeresource.rb +74 -0
- data/machinist_activeresource.gemspec +58 -0
- data/spec/machinist_activeresource_spec.rb +49 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- metadata +110 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Mathieu Fosse
|
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,17 @@
|
|
1
|
+
= machinist_activeresource
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Mathieu Fosse. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "machinist_activeresource"
|
8
|
+
gem.summary = %Q{ActiveResource Adapter for Machinist}
|
9
|
+
gem.description = %Q{ActiveResource Adapter for Machinist}
|
10
|
+
gem.email = "mathieu.fosse@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/yeastymobs/machinist_activeresource"
|
12
|
+
gem.authors = ["Mathieu Fosse"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
gem.add_dependency "machinist", ">= 1.0.6"
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "machinist_activeresource #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'machinist'
|
2
|
+
require 'machinist/blueprints'
|
3
|
+
require 'active_resource'
|
4
|
+
|
5
|
+
module Machinist
|
6
|
+
|
7
|
+
class ActiveResourceAdapter
|
8
|
+
|
9
|
+
def self.has_association?(object, attribute)
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
#def self.class_for_association(object, attribute)
|
14
|
+
#association = object.class.reflect_on_association(attribute)
|
15
|
+
#association && association.klass
|
16
|
+
#end
|
17
|
+
|
18
|
+
# This method takes care of converting any associated objects,
|
19
|
+
# in the hash returned by Lathe#assigned_attributes, into their
|
20
|
+
# object ids.
|
21
|
+
#
|
22
|
+
# For example, let's say we have blueprints like this:
|
23
|
+
#
|
24
|
+
# Post.blueprint { }
|
25
|
+
# Comment.blueprint { post }
|
26
|
+
#
|
27
|
+
# Lathe#assigned_attributes will return { :post => ... }, but
|
28
|
+
# we want to pass { :post_id => 1 } to a controller.
|
29
|
+
#
|
30
|
+
# This method takes care of cleaning this up.
|
31
|
+
def self.assigned_attributes_without_associations(lathe)
|
32
|
+
attributes = {}
|
33
|
+
lathe.assigned_attributes.each_pair do |attribute, value|
|
34
|
+
attributes[attribute] = value
|
35
|
+
end
|
36
|
+
attributes
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
module ActiveResourceExtensions
|
42
|
+
def self.included(base)
|
43
|
+
base.extend(ClassMethods)
|
44
|
+
end
|
45
|
+
|
46
|
+
module ClassMethods
|
47
|
+
def make(*args, &block)
|
48
|
+
lathe = Lathe.run(Machinist::ActiveResourceAdapter, self.new, *args)
|
49
|
+
# What is Nerfed ?
|
50
|
+
#unless Machinist.nerfed?
|
51
|
+
#lathe.object.save!
|
52
|
+
#lathe.object.reload
|
53
|
+
#end
|
54
|
+
lathe.object(&block)
|
55
|
+
end
|
56
|
+
|
57
|
+
def make_unsaved(*args)
|
58
|
+
object = Machinist.with_save_nerfed { make(*args) }
|
59
|
+
yield object if block_given?
|
60
|
+
object
|
61
|
+
end
|
62
|
+
|
63
|
+
def plan(*args)
|
64
|
+
lathe = Lathe.run(Machinist::ActiveResourceAdapter, self.new, *args)
|
65
|
+
Machinist::ActiveResourceAdapter.assigned_attributes_without_associations(lathe)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class ActiveResource::Base
|
72
|
+
include Machinist::Blueprints
|
73
|
+
include Machinist::ActiveResourceExtensions
|
74
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{machinist_activeresource}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Mathieu Fosse"]
|
12
|
+
s.date = %q{2010-10-05}
|
13
|
+
s.description = %q{ActiveResource Adapter for Machinist}
|
14
|
+
s.email = %q{mathieu.fosse@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/machinist_activeresource.rb",
|
27
|
+
"machinist_activeresource.gemspec",
|
28
|
+
"spec/machinist_activeresource_spec.rb",
|
29
|
+
"spec/spec.opts",
|
30
|
+
"spec/spec_helper.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/yeastymobs/machinist_activeresource}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.3.7}
|
36
|
+
s.summary = %q{ActiveResource Adapter for Machinist}
|
37
|
+
s.test_files = [
|
38
|
+
"spec/machinist_activeresource_spec.rb",
|
39
|
+
"spec/spec_helper.rb"
|
40
|
+
]
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
48
|
+
s.add_runtime_dependency(%q<machinist>, [">= 1.0.6"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
51
|
+
s.add_dependency(%q<machinist>, [">= 1.0.6"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
55
|
+
s.add_dependency(%q<machinist>, [">= 1.0.6"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
class Application < ActiveResource::Base
|
4
|
+
self.site = 'http://test.local'
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
describe "ActiveResource adapter" do
|
9
|
+
before(:each) do
|
10
|
+
Application.clear_blueprints!
|
11
|
+
Application.blueprint do
|
12
|
+
name "My Application"
|
13
|
+
email "my@email.com"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#make' do
|
18
|
+
context 'When use default values' do
|
19
|
+
subject { Application.make }
|
20
|
+
|
21
|
+
its(:name) { should == "My Application" }
|
22
|
+
its(:email) { should == "my@email.com" }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'When change one value' do
|
26
|
+
subject { Application.make(:name => "Another Application") }
|
27
|
+
|
28
|
+
its(:name) { should == "Another Application" }
|
29
|
+
its(:email) { should == "my@email.com" }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
describe '#plan' do
|
35
|
+
context 'When use default values' do
|
36
|
+
subject { Application.plan }
|
37
|
+
|
38
|
+
it { subject[:name].should == "My Application"}
|
39
|
+
it { subject[:email].should == "my@email.com"}
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'When change one value' do
|
43
|
+
subject { Application.plan(:email => "other@email.com") }
|
44
|
+
|
45
|
+
it { subject[:name].should == "My Application"}
|
46
|
+
it { subject[:email].should == "other@email.com"}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'active_resource'
|
4
|
+
require 'machinist_activeresource'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
|
8
|
+
Spec::Runner.configure do |config|
|
9
|
+
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: machinist_activeresource
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Mathieu Fosse
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-05 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: machinist
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 27
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 0
|
49
|
+
- 6
|
50
|
+
version: 1.0.6
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description: ActiveResource Adapter for Machinist
|
54
|
+
email: mathieu.fosse@gmail.com
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files:
|
60
|
+
- LICENSE
|
61
|
+
- README.rdoc
|
62
|
+
files:
|
63
|
+
- .document
|
64
|
+
- .gitignore
|
65
|
+
- LICENSE
|
66
|
+
- README.rdoc
|
67
|
+
- Rakefile
|
68
|
+
- VERSION
|
69
|
+
- lib/machinist_activeresource.rb
|
70
|
+
- machinist_activeresource.gemspec
|
71
|
+
- spec/machinist_activeresource_spec.rb
|
72
|
+
- spec/spec.opts
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
has_rdoc: true
|
75
|
+
homepage: http://github.com/yeastymobs/machinist_activeresource
|
76
|
+
licenses: []
|
77
|
+
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options:
|
80
|
+
- --charset=UTF-8
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
requirements: []
|
102
|
+
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 1.3.7
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: ActiveResource Adapter for Machinist
|
108
|
+
test_files:
|
109
|
+
- spec/machinist_activeresource_spec.rb
|
110
|
+
- spec/spec_helper.rb
|