untied-consumer-sync-activerecord 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +23 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/lib/untied-consumer-sync-activerecord.rb +3 -0
- data/lib/untied-consumer-sync-activerecord/active_record.rb +24 -0
- data/lib/untied-consumer-sync-activerecord/backend/active_record.rb +26 -0
- data/lib/untied-consumer-sync-activerecord/version.rb +9 -0
- data/spec/active_record_spec.rb +7 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/model_data.yml +8 -0
- data/spec/support/setup_ar_and_schema.rb +29 -0
- data/untied-consumer-sync-activerecord.gemspec +32 -0
- metadata +168 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2013 Redu Educational Technologies
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Untied::Consumer::Sync::ActiveRecord
|
2
|
+
|
3
|
+
A ActiveRecord backend for [Untied::Consumer::Sync](https://github.com/redu/untied-consumer-sync).
|
4
|
+
|
5
|
+
**Build status**
|
6
|
+
|
7
|
+
[![Build Status](https://travis-ci.org/redu/untied-consumer-sync.png)](https://travis-ci.org/redu/untied-consumer-sync-activerecord)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'untied-consumer-sync-activerecord'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install untied-consumer-sync-activerecord
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
30
|
+
|
31
|
+
|
32
|
+
<img src="https://github.com/downloads/redu/redupy/redutech-marca.png" alt="Redu Educational Technologies" width="300">
|
33
|
+
|
34
|
+
This project is maintained and funded by [Redu Educational Techologies](http://tech.redu.com.br).
|
35
|
+
|
36
|
+
# Copyright
|
37
|
+
|
38
|
+
Copyright (c) 2013 Redu Educational Technologies
|
39
|
+
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
41
|
+
|
42
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
43
|
+
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
45
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Untied
|
2
|
+
module Consumer
|
3
|
+
module Sync
|
4
|
+
module Backend
|
5
|
+
module ActiveRecord
|
6
|
+
class ModelHelper
|
7
|
+
include Sync::Backend::Base
|
8
|
+
|
9
|
+
# Public: Procura o modelo pelo id.
|
10
|
+
#
|
11
|
+
# id - Inteiro que indentifica o objeto de acordo a configuração.
|
12
|
+
#
|
13
|
+
# Retorna o caso o modelo seja encontrado ou nil caso o modelo não exista
|
14
|
+
# no banco.
|
15
|
+
def find(id)
|
16
|
+
# Unscoped para encontrar zombies
|
17
|
+
@model.unscoped.send("find_by_#{@model_data['mappings']['id']}", id)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "untied-consumer-sync"
|
2
|
+
|
3
|
+
module Untied
|
4
|
+
module Consumer
|
5
|
+
module Sync
|
6
|
+
module Backend
|
7
|
+
module ActiveRecord
|
8
|
+
class ModelHelper
|
9
|
+
include Sync::Backend::Base
|
10
|
+
|
11
|
+
# Public: Procura o modelo pelo id.
|
12
|
+
#
|
13
|
+
# id - Inteiro que indentifica o objeto de acordo a configuração.
|
14
|
+
#
|
15
|
+
# Retorna o caso o modelo seja encontrado ou nil caso o modelo não exista
|
16
|
+
# no banco.
|
17
|
+
def find(id)
|
18
|
+
# Unscoped para encontrar zombies
|
19
|
+
@model.unscoped.send("find_by_#{@model_data['mappings']['id']}", id)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
require 'untied-consumer-sync-activerecord'
|
9
|
+
require 'support/setup_ar_and_schema'
|
10
|
+
require 'untied-consumer-sync/backend/backend_shared_example'
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
Untied::Consumer::Sync.configure do |c|
|
14
|
+
c.model_data = "spec/support/model_data.yml"
|
15
|
+
c.service_name = "my_service"
|
16
|
+
end
|
17
|
+
|
18
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
19
|
+
config.run_all_when_everything_filtered = true
|
20
|
+
config.filter_run :focus
|
21
|
+
|
22
|
+
# Run specs in random order to surface order dependencies. If you find an
|
23
|
+
# order dependency and want to debug it, you can fix the order by providing
|
24
|
+
# the seed, which is printed after each run.
|
25
|
+
# --seed 1234
|
26
|
+
config.order = 'random'
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'active_record'
|
3
|
+
require 'untied-consumer-sync'
|
4
|
+
|
5
|
+
module SetupActiveRecord
|
6
|
+
# Connection
|
7
|
+
ar_config = { :test => { :adapter => 'sqlite3', :database => ":memory:" } }
|
8
|
+
ActiveRecord::Base.configurations = ar_config
|
9
|
+
ActiveRecord::Base.
|
10
|
+
establish_connection(ActiveRecord::Base.configurations[:test])
|
11
|
+
|
12
|
+
# Schema
|
13
|
+
ActiveRecord::Schema.define do
|
14
|
+
create_table :users, :force => true do |t|
|
15
|
+
t.string :my_id
|
16
|
+
t.string :login
|
17
|
+
t.string :name
|
18
|
+
t.boolean :zombie, :default => true
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Models
|
24
|
+
class ::User < ActiveRecord::Base
|
25
|
+
include Untied::Consumer::Sync::Zombificator::ActsAsZombie
|
26
|
+
|
27
|
+
validates_presence_of :login
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'untied-consumer-sync-activerecord/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "untied-consumer-sync-activerecord"
|
8
|
+
gem.version = Untied::Consumer::Sync::Activerecord::VERSION
|
9
|
+
gem.authors = ["Juliana Lucena"]
|
10
|
+
gem.email = ["julianalucenaa@gmail.com"]
|
11
|
+
gem.description = %q{A ActiveRecord backend for Untied Consumer Sync.}
|
12
|
+
gem.summary = %q{A ActiveRecord backend for Untied::Consumer::Sync.}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(spec)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rake'
|
21
|
+
gem.add_development_dependency 'rspec'
|
22
|
+
gem.add_development_dependency 'sqlite3'
|
23
|
+
|
24
|
+
gem.add_runtime_dependency 'untied-consumer-sync', '~> 0.0'
|
25
|
+
gem.add_runtime_dependency 'activerecord', '~> 3.2'
|
26
|
+
|
27
|
+
if RUBY_VERSION < "1.9"
|
28
|
+
gem.add_development_dependency "ruby-debug"
|
29
|
+
else
|
30
|
+
gem.add_development_dependency "debugger"
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: untied-consumer-sync-activerecord
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Juliana Lucena
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-01-04 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rspec
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: sqlite3
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: untied-consumer-sync
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 11
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
- 0
|
74
|
+
version: "0.0"
|
75
|
+
type: :runtime
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: activerecord
|
79
|
+
prerelease: false
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 3
|
88
|
+
- 2
|
89
|
+
version: "3.2"
|
90
|
+
type: :runtime
|
91
|
+
version_requirements: *id005
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: ruby-debug
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
type: :development
|
105
|
+
version_requirements: *id006
|
106
|
+
description: A ActiveRecord backend for Untied Consumer Sync.
|
107
|
+
email:
|
108
|
+
- julianalucenaa@gmail.com
|
109
|
+
executables: []
|
110
|
+
|
111
|
+
extensions: []
|
112
|
+
|
113
|
+
extra_rdoc_files: []
|
114
|
+
|
115
|
+
files:
|
116
|
+
- .gitignore
|
117
|
+
- .travis.yml
|
118
|
+
- Gemfile
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.md
|
121
|
+
- Rakefile
|
122
|
+
- lib/untied-consumer-sync-activerecord.rb
|
123
|
+
- lib/untied-consumer-sync-activerecord/active_record.rb
|
124
|
+
- lib/untied-consumer-sync-activerecord/backend/active_record.rb
|
125
|
+
- lib/untied-consumer-sync-activerecord/version.rb
|
126
|
+
- spec/active_record_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/support/model_data.yml
|
129
|
+
- spec/support/setup_ar_and_schema.rb
|
130
|
+
- untied-consumer-sync-activerecord.gemspec
|
131
|
+
homepage: ""
|
132
|
+
licenses: []
|
133
|
+
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
requirements: []
|
158
|
+
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.8.24
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: A ActiveRecord backend for Untied::Consumer::Sync.
|
164
|
+
test_files:
|
165
|
+
- spec/active_record_spec.rb
|
166
|
+
- spec/spec_helper.rb
|
167
|
+
- spec/support/model_data.yml
|
168
|
+
- spec/support/setup_ar_and_schema.rb
|