scales-core 0.0.1.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/bin/scale +14 -0
- data/bin/scalify +6 -0
- data/lib/.DS_Store +0 -0
- data/lib/scales-core.rb +13 -0
- data/lib/scales-core/.DS_Store +0 -0
- data/lib/scales-core/base.rb +31 -0
- data/lib/scales-core/boot/autoload.rb +19 -0
- data/lib/scales-core/boot/initializers/em.rb +3 -0
- data/lib/scales-core/boot/initializers/goliath.rb +2 -0
- data/lib/scales-core/boot/initializers/json.rb +1 -0
- data/lib/scales-core/boot/initializers/redis.rb +1 -0
- data/lib/scales-core/boot/initializers/securerandom.rb +1 -0
- data/lib/scales-core/boot/initializers/thor.rb +1 -0
- data/lib/scales-core/config.rb +46 -0
- data/lib/scales-core/helper.rb +6 -0
- data/lib/scales-core/helper/content_types.rb +29 -0
- data/lib/scales-core/helper/partial_resolver.rb +36 -0
- data/lib/scales-core/pub_sub.rb +6 -0
- data/lib/scales-core/pub_sub/async.rb +19 -0
- data/lib/scales-core/pub_sub/sync.rb +17 -0
- data/lib/scales-core/queue.rb +8 -0
- data/lib/scales-core/queue/async.rb +18 -0
- data/lib/scales-core/queue/sync.rb +18 -0
- data/lib/scales-core/scalify.rb +17 -0
- data/lib/scales-core/scalify/templates/cache.yml +20 -0
- data/lib/scales-core/scalify/templates/scaleup.rb +6 -0
- data/lib/scales-core/storage.rb +17 -0
- data/lib/scales-core/storage/async.rb +89 -0
- data/lib/scales-core/storage/sync.rb +93 -0
- data/lib/scales-core/version.rb +5 -0
- data/scales-core.gemspec +29 -0
- data/spec/.DS_Store +0 -0
- data/spec/base_spec.rb +19 -0
- data/spec/config_spec.rb +43 -0
- data/spec/gem_spec.rb +7 -0
- data/spec/helper.rb +57 -0
- data/spec/partial_resolver_spec.rb +45 -0
- data/spec/pub_sub_spec.rb +51 -0
- data/spec/queue_spec.rb +37 -0
- data/spec/scalify_spec.rb +13 -0
- data/spec/storage_spec.rb +147 -0
- metadata +213 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scales::PubSub::Async do
|
4
|
+
|
5
|
+
it "should publish a few responses" do
|
6
|
+
async do
|
7
|
+
Scales::PubSub::Async.publish "channel1", "response 1"
|
8
|
+
Scales::PubSub::Async.publish "channel2", "response 2"
|
9
|
+
Scales::PubSub::Async.publish "channel3", "response 3"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should subscribe to a few channels" do
|
14
|
+
async do
|
15
|
+
Scales::PubSub::Async.subscribe("channel1").should == "response 1"
|
16
|
+
Scales::PubSub::Async.subscribe("channel2").should == "response 2"
|
17
|
+
Scales::PubSub::Async.subscribe("channel3").should == "response 3"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe Scales::PubSub::Sync do
|
24
|
+
|
25
|
+
it "should publish a few responses" do
|
26
|
+
Scales::PubSub::Sync.publish "channel1", "response 1"
|
27
|
+
Scales::PubSub::Sync.publish "channel2", "response 2"
|
28
|
+
Scales::PubSub::Sync.publish "channel3", "response 3"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should subscribe to a few channels" do
|
32
|
+
Scales::PubSub::Sync.subscribe("channel1").should == "response 1"
|
33
|
+
Scales::PubSub::Sync.subscribe("channel2").should == "response 2"
|
34
|
+
Scales::PubSub::Sync.subscribe("channel3").should == "response 3"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe Scales::PubSub do
|
40
|
+
|
41
|
+
it "subscribes async and pushes sync" do
|
42
|
+
Thread.new do
|
43
|
+
sleep 2
|
44
|
+
Scales::PubSub::Sync.publish "channel1", "response 1"
|
45
|
+
end
|
46
|
+
async do
|
47
|
+
Scales::PubSub::Async.subscribe("channel1").should == "response 1"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/spec/queue_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scales::Queue::Sync do
|
4
|
+
|
5
|
+
it "should place a few jobs" do
|
6
|
+
Scales::Queue::Sync.add "job 1"
|
7
|
+
Scales::Queue::Sync.add "job 2"
|
8
|
+
Scales::Queue::Sync.add "job 3"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should take them out blocking" do
|
12
|
+
Scales::Queue::Sync.pop.should == "job 1"
|
13
|
+
Scales::Queue::Sync.pop.should == "job 2"
|
14
|
+
Scales::Queue::Sync.pop.should == "job 3"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe Scales::Queue::Async do
|
20
|
+
|
21
|
+
it "should place a few jobs" do
|
22
|
+
async do
|
23
|
+
Scales::Queue::Async.add "job 1"
|
24
|
+
Scales::Queue::Async.add "job 2"
|
25
|
+
Scales::Queue::Async.add "job 3"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should take them out blocking" do
|
30
|
+
async do
|
31
|
+
Scales::Queue::Async.pop.should == "job 1"
|
32
|
+
Scales::Queue::Async.pop.should == "job 2"
|
33
|
+
Scales::Queue::Async.pop.should == "job 3"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scales::Scalify do
|
4
|
+
|
5
|
+
it "creates scaleup and cache.yml file" do
|
6
|
+
in_temp_folder do
|
7
|
+
described_class.start
|
8
|
+
File.exists?("config/scaleup.rb").should be_true
|
9
|
+
File.exists?("config/cache.yml").should be_true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scales::Storage::Sync do
|
4
|
+
|
5
|
+
it "should set and get a key" do
|
6
|
+
Scales::Storage::Sync.set_content "test_key", "a test value"
|
7
|
+
Scales::Storage::Sync.get_content("test_key").should == "a test value"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should set and get and delete a resource" do
|
11
|
+
Scales::Storage::Sync.set_content "test_key", "a test value"
|
12
|
+
Scales::Storage::Sync.get_content("test_key").should == "a test value"
|
13
|
+
Scales::Storage::Sync.del_content "test_key"
|
14
|
+
Scales::Storage::Sync.get_content("test_key").should be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set and get and delete a partial" do
|
18
|
+
Scales::Storage::Sync.set_content "test_key", "a test value"
|
19
|
+
Scales::Storage::Sync.get_content("test_key").should == "a test value"
|
20
|
+
Scales::Storage::Sync.del_content "test_key"
|
21
|
+
Scales::Storage::Sync.get_content("test_key").should be_nil
|
22
|
+
end
|
23
|
+
|
24
|
+
context "partials" do
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
Scales.config.partials = true
|
28
|
+
Scales::Storage::Sync.flushall!
|
29
|
+
end
|
30
|
+
|
31
|
+
it "resolves partials" do
|
32
|
+
|
33
|
+
@html = <<-HTML
|
34
|
+
<html>
|
35
|
+
<body>
|
36
|
+
<div id="header">Scales.partial "_header"</div>
|
37
|
+
<div id="page">
|
38
|
+
<h1>Hello World</h1>
|
39
|
+
</div>
|
40
|
+
</body>
|
41
|
+
</html>
|
42
|
+
HTML
|
43
|
+
|
44
|
+
@header = <<-HTML
|
45
|
+
<ul>
|
46
|
+
<li>Home</li>
|
47
|
+
<li>Tracks</li>
|
48
|
+
Scales.partial "_sub_header"
|
49
|
+
</ul>
|
50
|
+
HTML
|
51
|
+
|
52
|
+
@sub_header = <<-HTML
|
53
|
+
<ul>
|
54
|
+
<li>Sub 1</li>
|
55
|
+
<li>Sub 2</li>
|
56
|
+
</ul>
|
57
|
+
HTML
|
58
|
+
|
59
|
+
Scales::Storage::Sync.set_content "/tracks", @html
|
60
|
+
Scales::Storage::Sync.set_content "_header", @header
|
61
|
+
Scales::Storage::Sync.set_content "_sub_header", @sub_header
|
62
|
+
|
63
|
+
squeeze(Scales::Storage::Sync.get_content("/tracks", true)).should == squeeze(@html.gsub('Scales.partial "_header"', @header).gsub('Scales.partial "_sub_header"', @sub_header))
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
describe Scales::Storage::Async do
|
71
|
+
|
72
|
+
it "should set and get a key" do
|
73
|
+
async do
|
74
|
+
Scales::Storage::Async.set("test_key", "a test value") do
|
75
|
+
Scales::Storage::Async.get("test_key") do |value|
|
76
|
+
value.should == "a test value"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should set and get a resource" do
|
83
|
+
async do
|
84
|
+
Scales::Storage::Async.set_content "test_key", "a test value"
|
85
|
+
Scales::Storage::Async.get_content("test_key").should == "a test value"
|
86
|
+
Scales::Storage::Async.del_content "test_key"
|
87
|
+
Scales::Storage::Async.get_content("test_key").should be_nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should set and get a partial" do
|
92
|
+
async do
|
93
|
+
Scales::Storage::Async.set_content "test_key", "a test value"
|
94
|
+
Scales::Storage::Async.get_content("test_key").should == "a test value"
|
95
|
+
Scales::Storage::Async.del_content "test_key"
|
96
|
+
Scales::Storage::Async.get_content("test_key").should be_nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "partials" do
|
101
|
+
|
102
|
+
before(:each) do
|
103
|
+
Scales.config.partials = true
|
104
|
+
Scales::Storage::Sync.flushall!
|
105
|
+
end
|
106
|
+
|
107
|
+
it "resolves partials" do
|
108
|
+
|
109
|
+
@html = <<-HTML
|
110
|
+
<html>
|
111
|
+
<body>
|
112
|
+
<div id="header">Scales.partial "_header"</div>
|
113
|
+
<div id="page">
|
114
|
+
<h1>Hello World</h1>
|
115
|
+
</div>
|
116
|
+
</body>
|
117
|
+
</html>
|
118
|
+
HTML
|
119
|
+
|
120
|
+
@header = <<-HTML
|
121
|
+
<ul>
|
122
|
+
<li>Home</li>
|
123
|
+
<li>Tracks</li>
|
124
|
+
Scales.partial "_sub_header"
|
125
|
+
</ul>
|
126
|
+
HTML
|
127
|
+
|
128
|
+
@sub_header = <<-HTML
|
129
|
+
<ul>
|
130
|
+
<li>Sub 1</li>
|
131
|
+
<li>Sub 2</li>
|
132
|
+
</ul>
|
133
|
+
HTML
|
134
|
+
|
135
|
+
async do
|
136
|
+
Scales::Storage::Async.set_content "/tracks", @html
|
137
|
+
Scales::Storage::Async.set_content "_header", @header
|
138
|
+
Scales::Storage::Async.set_content "_sub_header", @sub_header
|
139
|
+
|
140
|
+
squeeze(Scales::Storage::Async.get_content("/tracks", true)).should == squeeze(@html.gsub('Scales.partial "_header"', @header).gsub('Scales.partial "_sub_header"', @sub_header))
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
metadata
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scales-core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.beta.1
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thomas Fankhauser
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70359165803380 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.2.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70359165803380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70359165802460 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.11'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70359165802460
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: redis
|
38
|
+
requirement: &70359165823400 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.0.1
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70359165823400
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: eventmachine
|
49
|
+
requirement: &70359165822700 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0.beta.4
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70359165822700
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: em-http-request
|
60
|
+
requirement: &70359165821400 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.0.2
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70359165821400
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: em-synchrony
|
71
|
+
requirement: &70359165818720 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.0.2
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70359165818720
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: em-hiredis
|
82
|
+
requirement: &70359165818180 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.1.1
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70359165818180
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: json
|
93
|
+
requirement: &70359165817720 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.7.4
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70359165817720
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: colorize
|
104
|
+
requirement: &70359165816720 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.5.8
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70359165816720
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: thor
|
115
|
+
requirement: &70359165835040 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.15.4
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *70359165835040
|
124
|
+
description: Super Scale Caching Framework - Core
|
125
|
+
email:
|
126
|
+
- tommylefunk@googlemail.com
|
127
|
+
executables:
|
128
|
+
- scale
|
129
|
+
- scalify
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- Gemfile
|
135
|
+
- LICENSE
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- bin/scale
|
139
|
+
- bin/scalify
|
140
|
+
- lib/.DS_Store
|
141
|
+
- lib/scales-core.rb
|
142
|
+
- lib/scales-core/.DS_Store
|
143
|
+
- lib/scales-core/base.rb
|
144
|
+
- lib/scales-core/boot/autoload.rb
|
145
|
+
- lib/scales-core/boot/initializers/em.rb
|
146
|
+
- lib/scales-core/boot/initializers/goliath.rb
|
147
|
+
- lib/scales-core/boot/initializers/json.rb
|
148
|
+
- lib/scales-core/boot/initializers/redis.rb
|
149
|
+
- lib/scales-core/boot/initializers/securerandom.rb
|
150
|
+
- lib/scales-core/boot/initializers/thor.rb
|
151
|
+
- lib/scales-core/config.rb
|
152
|
+
- lib/scales-core/helper.rb
|
153
|
+
- lib/scales-core/helper/content_types.rb
|
154
|
+
- lib/scales-core/helper/partial_resolver.rb
|
155
|
+
- lib/scales-core/pub_sub.rb
|
156
|
+
- lib/scales-core/pub_sub/async.rb
|
157
|
+
- lib/scales-core/pub_sub/sync.rb
|
158
|
+
- lib/scales-core/queue.rb
|
159
|
+
- lib/scales-core/queue/async.rb
|
160
|
+
- lib/scales-core/queue/sync.rb
|
161
|
+
- lib/scales-core/scalify.rb
|
162
|
+
- lib/scales-core/scalify/templates/cache.yml
|
163
|
+
- lib/scales-core/scalify/templates/scaleup.rb
|
164
|
+
- lib/scales-core/storage.rb
|
165
|
+
- lib/scales-core/storage/async.rb
|
166
|
+
- lib/scales-core/storage/sync.rb
|
167
|
+
- lib/scales-core/version.rb
|
168
|
+
- scales-core.gemspec
|
169
|
+
- spec/.DS_Store
|
170
|
+
- spec/base_spec.rb
|
171
|
+
- spec/config_spec.rb
|
172
|
+
- spec/gem_spec.rb
|
173
|
+
- spec/helper.rb
|
174
|
+
- spec/partial_resolver_spec.rb
|
175
|
+
- spec/pub_sub_spec.rb
|
176
|
+
- spec/queue_spec.rb
|
177
|
+
- spec/scalify_spec.rb
|
178
|
+
- spec/storage_spec.rb
|
179
|
+
homepage: http://itscales.org
|
180
|
+
licenses: []
|
181
|
+
post_install_message:
|
182
|
+
rdoc_options: []
|
183
|
+
require_paths:
|
184
|
+
- lib
|
185
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
187
|
+
requirements:
|
188
|
+
- - ! '>='
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
none: false
|
193
|
+
requirements:
|
194
|
+
- - ! '>'
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 1.3.1
|
197
|
+
requirements: []
|
198
|
+
rubyforge_project:
|
199
|
+
rubygems_version: 1.8.11
|
200
|
+
signing_key:
|
201
|
+
specification_version: 3
|
202
|
+
summary: Provides core functionalities like storage, queues, pubsub and configurations.
|
203
|
+
test_files:
|
204
|
+
- spec/.DS_Store
|
205
|
+
- spec/base_spec.rb
|
206
|
+
- spec/config_spec.rb
|
207
|
+
- spec/gem_spec.rb
|
208
|
+
- spec/helper.rb
|
209
|
+
- spec/partial_resolver_spec.rb
|
210
|
+
- spec/pub_sub_spec.rb
|
211
|
+
- spec/queue_spec.rb
|
212
|
+
- spec/scalify_spec.rb
|
213
|
+
- spec/storage_spec.rb
|