synced 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7216624feb81567456dd5c0d2468da9d36232efe
4
+ data.tar.gz: b2ac5bb712039e8ddedb5713960a5a68785545a4
5
+ SHA512:
6
+ metadata.gz: bec0c589e63b7ff64d901a3d3e9172a032c7b1ba8bd9466122011d0dc9d127510294daa0d8597a95fbe60214c99c8feef96cfe9d598b63beb511cf7a6884832b
7
+ data.tar.gz: 955521df6291cc240e6ddd38e6643a0ebf79685fadd4a6285d585bdcee1b2445080635200e585b9cfd6daed47b2a295950a75120e53e2a0e116c8ae9a26573c5
@@ -0,0 +1,20 @@
1
+ Copyright 2014 BookingSync
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.
@@ -0,0 +1,50 @@
1
+ # Synced
2
+
3
+ Synced is a Rails Engine that helps you keep local models synchronized with their BookingSync representation.
4
+
5
+ Note: This synchronization is in one way only, from BookingSync to your application. If you want to do a 2 way synchronization, you will need to implement it yourself using [BookingSync-API](https://github.com/BookingSync/bookingsync-api)
6
+
7
+ ## Requirements
8
+
9
+ This engine requires BookingSync API `>= 0.0.17`, Rails `>= 4.0.0` and Ruby `>= 2.0.0`.
10
+
11
+ ## Documentation
12
+
13
+ [API documentation is available at rdoc.info](http://rdoc.info/github/BookingSync/synced/master/frames).
14
+
15
+ ## Installation
16
+
17
+ Synced works with BookingSync API 0.0.17 onwards, Rails 4.0 onwards and Ruby 2.0 onwards. To get started, add it to your Gemfile with:
18
+
19
+ ```ruby
20
+ gem 'synced'
21
+ ```
22
+
23
+ Then run the installer to copy the migrations,
24
+
25
+ ```console
26
+ rake synced:install:migrations
27
+ ```
28
+
29
+ Then, generate a migration to add Synced fields for the model you want to synchronize:
30
+
31
+ Example:
32
+ ```console
33
+ rails g migration AddSyncedFieldsToRentals synced_id:integer:index synced_data:text \
34
+ synced_updated_at:datetime
35
+ ```
36
+
37
+ and migrate:
38
+
39
+ ```console
40
+ rake db:migrate
41
+ ```
42
+
43
+ And include `Synced::HasSyncedData` in the model you want to keep in sync:
44
+
45
+ Example:
46
+ ```ruby
47
+ class Rental < ActiveRecord::Base
48
+ include Synced::HasSyncedData
49
+ end
50
+ ```
@@ -0,0 +1,31 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+ require 'thor'
9
+
10
+ RDoc::Task.new(:rdoc) do |rdoc|
11
+ rdoc.rdoc_dir = 'rdoc'
12
+ rdoc.title = 'Synced'
13
+ rdoc.options << '--line-numbers'
14
+ rdoc.rdoc_files.include('README.md')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
17
+
18
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
19
+ load 'rails/tasks/engine.rake'
20
+
21
+
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
25
+ require 'rspec/core'
26
+ require 'rspec/core/rake_task'
27
+
28
+ desc "Run all specs in spec directory (excluding plugin specs)"
29
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
30
+
31
+ task default: :spec
@@ -0,0 +1,4 @@
1
+ module Synced
2
+ class Synchronization < ActiveRecord::Base
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,10 @@
1
+ class CreateSyncedSynchronizations < ActiveRecord::Migration
2
+ def change
3
+ create_table :synced_synchronizations do |t|
4
+ t.string :model
5
+ t.datetime :synchronized_at
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ require "synced/engine"
2
+
3
+ module Synced
4
+ end
@@ -0,0 +1,13 @@
1
+ module Synced
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Synced
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ end
8
+
9
+ config.to_prepare do
10
+ require "synced/engine/lib/has_synced_data"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,37 @@
1
+ require 'hashie'
2
+
3
+ module Synced
4
+ # Provide a serialized `bs_data` attribute for models. This is a friendlier
5
+ # alternative to `serialize` with respect to dirty attributes.
6
+ module HasSyncedData
7
+ class SyncedData < Hashie::Mash; end
8
+
9
+ # Serialize and set remote data from `object`.
10
+ def synced_data=(object)
11
+ write_attribute :synced_data, dump(object)
12
+ ensure
13
+ @synced_data = nil
14
+ end
15
+
16
+ # Return remote data as a cached instance.
17
+ def synced_data
18
+ @synced_data ||= SyncedData.new loaded_synced_data
19
+ end
20
+
21
+ private
22
+
23
+ def loaded_synced_data
24
+ load read_attribute(:synced_data)
25
+ rescue
26
+ {}
27
+ end
28
+
29
+ def dump(object)
30
+ JSON.dump object
31
+ end
32
+
33
+ def load(source)
34
+ JSON.load source
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module Synced
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: synced
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sebastien Grosjean
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bookingsync-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.17
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.17
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Keep your BookingSync Application synced with BookingSync.
98
+ email:
99
+ - dev@bookingsync.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - MIT-LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - app/models/synced/synchronization.rb
108
+ - config/routes.rb
109
+ - db/migrate/20140621143737_create_synced_synchronizations.rb
110
+ - lib/synced.rb
111
+ - lib/synced/engine.rb
112
+ - lib/synced/engine/lib/has_synced_data.rb
113
+ - lib/synced/version.rb
114
+ homepage: https://github.com/BookingSync/synced
115
+ licenses:
116
+ - MIT
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.2.2
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Keep your BookingSync Application synced with BookingSync.
138
+ test_files: []