nsync 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/nsync/config.rb +1 -1
- data/lib/nsync/consumer.rb +3 -3
- data/lib/nsync/core_extensions.rb +29 -0
- data/lib/nsync/producer.rb +2 -2
- data/lib/nsync.rb +4 -5
- data/nsync.gemspec +5 -8
- data/test/helper.rb +1 -1
- metadata +37 -28
data/Rakefile
CHANGED
@@ -5,6 +5,7 @@ gem "schleyfox-grit", ">= 2.3.0.1"
|
|
5
5
|
require 'grit'
|
6
6
|
|
7
7
|
require 'jeweler'
|
8
|
+
$:.unshift(".")
|
8
9
|
require 'jeweler_monkey_patch'
|
9
10
|
|
10
11
|
|
@@ -19,7 +20,6 @@ Jeweler::Tasks.new do |gem|
|
|
19
20
|
gem.authors = ["Ben Hughes"]
|
20
21
|
|
21
22
|
gem.add_dependency "json"
|
22
|
-
gem.add_dependency "activesupport", "~> 2.3.5"
|
23
23
|
gem.add_dependency "schleyfox-grit", ">= 2.3.0.1"
|
24
24
|
gem.add_dependency "schleyfox-lockfile", ">= 1.0.0"
|
25
25
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/nsync/config.rb
CHANGED
@@ -59,7 +59,7 @@ module Nsync
|
|
59
59
|
def consumer_classes_for(producer_class)
|
60
60
|
Array(@class_mappings[producer_class]).map do |klass|
|
61
61
|
begin
|
62
|
-
|
62
|
+
CoreExtensions.constantize(klass)
|
63
63
|
rescue NameError => e
|
64
64
|
log.error(e.inspect)
|
65
65
|
log.warn("[NSYNC] Could not find class '#{klass}'; skipping")
|
data/lib/nsync/consumer.rb
CHANGED
@@ -114,7 +114,7 @@ module Nsync
|
|
114
114
|
if config.ordering
|
115
115
|
config.ordering.each do |klass|
|
116
116
|
klass = begin
|
117
|
-
|
117
|
+
CoreExtensions.constantize(klass)
|
118
118
|
rescue NameError => e
|
119
119
|
config.log.warn("[NSYNC] Could not find class '#{klass}' from ordering; skipping")
|
120
120
|
false
|
@@ -249,7 +249,7 @@ module Nsync
|
|
249
249
|
|
250
250
|
config.lock do
|
251
251
|
git = Grit::Git.new(config.repo_path)
|
252
|
-
git.clone
|
252
|
+
git.run('', 'clone', '', {:bare => true}, [config.repo_url, config.repo_path])
|
253
253
|
self.repo = Grit::Repo.new(config.repo_path)
|
254
254
|
config.version_manager.version = first_commit
|
255
255
|
return self.repo
|
@@ -336,7 +336,7 @@ module Nsync
|
|
336
336
|
end
|
337
337
|
|
338
338
|
def consumer_classes_and_id_from_path(path)
|
339
|
-
producer_class_name = File.dirname(path)
|
339
|
+
producer_class_name = CoreExtensions.camelize(File.dirname(path))
|
340
340
|
id = File.basename(path, ".json")
|
341
341
|
[config.consumer_classes_for(producer_class_name), id]
|
342
342
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# The parts of ActiveSupport that we need, all shamelessly stolen
|
2
|
+
module Nsync
|
3
|
+
module CoreExtensions
|
4
|
+
# Upper case camelize
|
5
|
+
def self.camelize(string)
|
6
|
+
string.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.constantize(string)
|
10
|
+
names = string.split('::')
|
11
|
+
names.shift if names.size == 0 || names.first.size == 0
|
12
|
+
|
13
|
+
constant = Object
|
14
|
+
#Ruby 1.9 awesomeness
|
15
|
+
if Module.method(:const_get).arity == 1
|
16
|
+
names.each do |name|
|
17
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
names.each do |name|
|
21
|
+
constant = constant.const_get(name, false) || constant.const_missing(name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
constant
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
data/lib/nsync/producer.rb
CHANGED
@@ -128,13 +128,13 @@ module Nsync
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def consumer_classes_and_id_from_path(path)
|
131
|
-
producer_class_name = File.dirname(path)
|
131
|
+
producer_class_name = CoreExtensions.camelize(File.dirname(path))
|
132
132
|
id = File.basename(path, ".json")
|
133
133
|
classes = config.consumer_classes_for(producer_class_name)
|
134
134
|
|
135
135
|
# refinement to allow the producer to consume itself
|
136
136
|
if classes.empty?
|
137
|
-
classes = [
|
137
|
+
classes = [CoreExtensions.constantize(producer_class_name)].compact
|
138
138
|
end
|
139
139
|
[classes, id]
|
140
140
|
end
|
data/lib/nsync.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
-
# just for now
|
5
|
-
gem 'activesupport', "~> 2.3.5"
|
6
|
-
require 'active_support'
|
7
|
-
|
8
4
|
gem "schleyfox-grit", ">= 2.3.0.1"
|
9
5
|
require 'grit'
|
10
6
|
|
7
|
+
require 'nsync/core_extensions'
|
8
|
+
|
11
9
|
#up the timeout, as these repos can get quite large
|
12
10
|
Grit::Git.git_timeout = 60 # 1 minute should do
|
13
|
-
|
11
|
+
# 100 megabytes
|
12
|
+
Grit::Git.git_max_size = 100*1024*1024 # tweak this up for very large changesets
|
14
13
|
|
15
14
|
gem "schleyfox-lockfile", ">= 1.0.0"
|
16
15
|
require 'lockfile'
|
data/nsync.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{nsync}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Hughes"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-06-13}
|
13
13
|
s.description = %q{Nsync is designed to allow you to have a separate data
|
14
14
|
processing app with its own data processing optimized database and a consumer
|
15
15
|
app with its own database, while keeping the data as in sync as you want it.}
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/nsync/class_methods.rb",
|
32
32
|
"lib/nsync/config.rb",
|
33
33
|
"lib/nsync/consumer.rb",
|
34
|
+
"lib/nsync/core_extensions.rb",
|
34
35
|
"lib/nsync/git_version_manager.rb",
|
35
36
|
"lib/nsync/producer.rb",
|
36
37
|
"lib/nsync/producer/methods.rb",
|
@@ -38,7 +39,7 @@ Gem::Specification.new do |s|
|
|
38
39
|
]
|
39
40
|
s.homepage = %q{http://github.com/schleyfox/nsync}
|
40
41
|
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = %q{1.
|
42
|
+
s.rubygems_version = %q{1.4.0}
|
42
43
|
s.summary = %q{Keep your data processors and apps in sync}
|
43
44
|
s.test_files = [
|
44
45
|
"test/active_record_test.rb",
|
@@ -51,19 +52,16 @@ Gem::Specification.new do |s|
|
|
51
52
|
]
|
52
53
|
|
53
54
|
if s.respond_to? :specification_version then
|
54
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
55
|
s.specification_version = 3
|
56
56
|
|
57
|
-
if Gem::Version.new(Gem::
|
57
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
58
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
59
|
-
s.add_runtime_dependency(%q<activesupport>, ["~> 2.3.5"])
|
60
59
|
s.add_runtime_dependency(%q<schleyfox-grit>, [">= 2.3.0.1"])
|
61
60
|
s.add_runtime_dependency(%q<schleyfox-lockfile>, [">= 1.0.0"])
|
62
61
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
63
62
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
64
63
|
else
|
65
64
|
s.add_dependency(%q<json>, [">= 0"])
|
66
|
-
s.add_dependency(%q<activesupport>, ["~> 2.3.5"])
|
67
65
|
s.add_dependency(%q<schleyfox-grit>, [">= 2.3.0.1"])
|
68
66
|
s.add_dependency(%q<schleyfox-lockfile>, [">= 1.0.0"])
|
69
67
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
@@ -71,7 +69,6 @@ Gem::Specification.new do |s|
|
|
71
69
|
end
|
72
70
|
else
|
73
71
|
s.add_dependency(%q<json>, [">= 0"])
|
74
|
-
s.add_dependency(%q<activesupport>, ["~> 2.3.5"])
|
75
72
|
s.add_dependency(%q<schleyfox-grit>, [">= 2.3.0.1"])
|
76
73
|
s.add_dependency(%q<schleyfox-lockfile>, [">= 1.0.0"])
|
77
74
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Ben Hughes
|
@@ -14,42 +15,32 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-06-13 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: json
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
30
33
|
type: :runtime
|
31
34
|
version_requirements: *id001
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: activesupport
|
34
|
-
prerelease: false
|
35
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ~>
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
segments:
|
40
|
-
- 2
|
41
|
-
- 3
|
42
|
-
- 5
|
43
|
-
version: 2.3.5
|
44
|
-
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
35
|
- !ruby/object:Gem::Dependency
|
47
36
|
name: schleyfox-grit
|
48
37
|
prerelease: false
|
49
|
-
requirement: &
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
50
40
|
requirements:
|
51
41
|
- - ">="
|
52
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 117
|
53
44
|
segments:
|
54
45
|
- 2
|
55
46
|
- 3
|
@@ -57,45 +48,51 @@ dependencies:
|
|
57
48
|
- 1
|
58
49
|
version: 2.3.0.1
|
59
50
|
type: :runtime
|
60
|
-
version_requirements: *
|
51
|
+
version_requirements: *id002
|
61
52
|
- !ruby/object:Gem::Dependency
|
62
53
|
name: schleyfox-lockfile
|
63
54
|
prerelease: false
|
64
|
-
requirement: &
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
65
57
|
requirements:
|
66
58
|
- - ">="
|
67
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 23
|
68
61
|
segments:
|
69
62
|
- 1
|
70
63
|
- 0
|
71
64
|
- 0
|
72
65
|
version: 1.0.0
|
73
66
|
type: :runtime
|
74
|
-
version_requirements: *
|
67
|
+
version_requirements: *id003
|
75
68
|
- !ruby/object:Gem::Dependency
|
76
69
|
name: shoulda
|
77
70
|
prerelease: false
|
78
|
-
requirement: &
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
79
73
|
requirements:
|
80
74
|
- - ">="
|
81
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
82
77
|
segments:
|
83
78
|
- 0
|
84
79
|
version: "0"
|
85
80
|
type: :development
|
86
|
-
version_requirements: *
|
81
|
+
version_requirements: *id004
|
87
82
|
- !ruby/object:Gem::Dependency
|
88
83
|
name: mocha
|
89
84
|
prerelease: false
|
90
|
-
requirement: &
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
91
87
|
requirements:
|
92
88
|
- - ">="
|
93
89
|
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
94
91
|
segments:
|
95
92
|
- 0
|
96
93
|
version: "0"
|
97
94
|
type: :development
|
98
|
-
version_requirements: *
|
95
|
+
version_requirements: *id005
|
99
96
|
description: |-
|
100
97
|
Nsync is designed to allow you to have a separate data
|
101
98
|
processing app with its own data processing optimized database and a consumer
|
@@ -121,10 +118,18 @@ files:
|
|
121
118
|
- lib/nsync/class_methods.rb
|
122
119
|
- lib/nsync/config.rb
|
123
120
|
- lib/nsync/consumer.rb
|
121
|
+
- lib/nsync/core_extensions.rb
|
124
122
|
- lib/nsync/git_version_manager.rb
|
125
123
|
- lib/nsync/producer.rb
|
126
124
|
- lib/nsync/producer/methods.rb
|
127
125
|
- nsync.gemspec
|
126
|
+
- test/active_record_test.rb
|
127
|
+
- test/classes.rb
|
128
|
+
- test/helper.rb
|
129
|
+
- test/nsync_config_test.rb
|
130
|
+
- test/nsync_consumer_test.rb
|
131
|
+
- test/nsync_producer_test.rb
|
132
|
+
- test/repo.rb
|
128
133
|
has_rdoc: true
|
129
134
|
homepage: http://github.com/schleyfox/nsync
|
130
135
|
licenses: []
|
@@ -135,23 +140,27 @@ rdoc_options: []
|
|
135
140
|
require_paths:
|
136
141
|
- lib
|
137
142
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
138
144
|
requirements:
|
139
145
|
- - ">="
|
140
146
|
- !ruby/object:Gem::Version
|
147
|
+
hash: 3
|
141
148
|
segments:
|
142
149
|
- 0
|
143
150
|
version: "0"
|
144
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
145
153
|
requirements:
|
146
154
|
- - ">="
|
147
155
|
- !ruby/object:Gem::Version
|
156
|
+
hash: 3
|
148
157
|
segments:
|
149
158
|
- 0
|
150
159
|
version: "0"
|
151
160
|
requirements: []
|
152
161
|
|
153
162
|
rubyforge_project:
|
154
|
-
rubygems_version: 1.
|
163
|
+
rubygems_version: 1.4.0
|
155
164
|
signing_key:
|
156
165
|
specification_version: 3
|
157
166
|
summary: Keep your data processors and apps in sync
|