pyramid_scheme 0.2.5 → 0.2.7
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/.gitignore +3 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/pyramid_scheme.rb +4 -0
- data/lib/pyramid_scheme/configuration.rb +9 -0
- data/lib/pyramid_scheme/index_provider/base.rb +1 -1
- data/spec/configuration.example.yml +6 -0
- data/spec/integrations/s3_spec.rb +38 -14
- data/spec/pyramid_scheme/configuration_spec.rb +19 -0
- metadata +9 -6
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ begin
|
|
13
13
|
gem.authors = ["Dan Pickett"]
|
14
14
|
gem.add_dependency "rake", ">= 0.8.7"
|
15
15
|
gem.add_dependency "configatron"
|
16
|
-
gem.add_dependency "aws-s3", ">= 0.
|
16
|
+
gem.add_dependency "aws-s3", ">= 0.6.2"
|
17
17
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
18
18
|
gem.add_development_dependency "yard", ">= 0"
|
19
19
|
gem.add_development_dependency "mocha", "0.9.8"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/lib/pyramid_scheme.rb
CHANGED
@@ -25,6 +25,15 @@ module PyramidScheme
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def self.set_from_yml(path)
|
29
|
+
config_hash = YAML::load(File.open(path))
|
30
|
+
set do |config|
|
31
|
+
config_hash.each do |key, value|
|
32
|
+
config.send("#{key}=", value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
28
37
|
def self.defaults
|
29
38
|
{
|
30
39
|
:lock_file_name => 'pyramid_scheme_index_in_progress.txt',
|
@@ -46,7 +46,7 @@ module PyramidScheme
|
|
46
46
|
protected
|
47
47
|
def ensure_required_options_are_present
|
48
48
|
self.class.required_options.each do |opt|
|
49
|
-
if @configuration[opt].nil?
|
49
|
+
if @configuration[opt].nil? || @configuration[opt] == ''
|
50
50
|
raise PyramidScheme::RequiredConfigurationNotFound,
|
51
51
|
"the #{opt} setting was not found"
|
52
52
|
end
|
@@ -20,11 +20,16 @@ describe "S3 index provider" do
|
|
20
20
|
|
21
21
|
describe "populating index files" do
|
22
22
|
before(:each) do
|
23
|
+
FakeFS.deactivate!
|
24
|
+
clear_source
|
25
|
+
end
|
23
26
|
|
27
|
+
after(:each) do
|
28
|
+
FakeFS.activate!
|
24
29
|
end
|
30
|
+
|
25
31
|
it 'should copy all the relevant index files to s3 on processing' do
|
26
32
|
FileUtils.mkdir_p(PyramidScheme.configuration[:server_source_path])
|
27
|
-
FileUtils.mkdir_p(PyramidScheme.configuration[:server_destination_path])
|
28
33
|
@filenames = [
|
29
34
|
'.spi',
|
30
35
|
'.spd',
|
@@ -36,7 +41,9 @@ describe "S3 index provider" do
|
|
36
41
|
].collect{|s| "some_index#{s}" }
|
37
42
|
|
38
43
|
@filenames.each do |f|
|
39
|
-
|
44
|
+
File.open(File.join(PyramidScheme.configuration[:server_source_path], f), 'w') do |file|
|
45
|
+
file << 'contents'
|
46
|
+
end
|
40
47
|
File.exists?(File.join(PyramidScheme.configuration[:server_source_path], f)).should be_true
|
41
48
|
end
|
42
49
|
|
@@ -50,6 +57,15 @@ describe "S3 index provider" do
|
|
50
57
|
end
|
51
58
|
|
52
59
|
describe "providing index files" do
|
60
|
+
before(:each) do
|
61
|
+
FakeFS.deactivate!
|
62
|
+
clear_destination
|
63
|
+
end
|
64
|
+
|
65
|
+
after(:each) do
|
66
|
+
FakeFS.activate!
|
67
|
+
end
|
68
|
+
|
53
69
|
it 'should download all the relevant index files to s3 on providing' do
|
54
70
|
FileUtils.mkdir_p(PyramidScheme.configuration[:client_destination_path])
|
55
71
|
@provider.retrieve_index
|
@@ -63,28 +79,36 @@ describe "S3 index provider" do
|
|
63
79
|
'.spp',
|
64
80
|
'.spk'
|
65
81
|
].collect{|s| "some_index#{s}" }.each do |f|
|
66
|
-
File.
|
67
|
-
f.gsub(/\./, '.new.'))
|
82
|
+
filename = File.join(PyramidScheme.configuration[:client_destination_path],
|
83
|
+
f.gsub(/\./, '.new.'))
|
84
|
+
File.exists?(filename).should be_true
|
85
|
+
File.size(filename).should > 0
|
68
86
|
end
|
69
87
|
|
70
88
|
end
|
71
89
|
end
|
72
90
|
|
91
|
+
def clear_destination
|
92
|
+
clear_directory(PyramidScheme.configuration[:client_destination_path])
|
93
|
+
end
|
94
|
+
|
95
|
+
def clear_source
|
96
|
+
clear_directory(PyramidScheme.configuration[:server_source_path])
|
97
|
+
end
|
98
|
+
|
99
|
+
def clear_directory(path)
|
100
|
+
FileUtils.rm_f("#{path}/*")
|
101
|
+
end
|
102
|
+
|
73
103
|
def load_configuration_from_yaml
|
74
104
|
FakeFS.deactivate!
|
75
|
-
yml_config = YAML.load_file(File.join(File.dirname(__FILE__), 's3.yml'))
|
76
|
-
|
77
105
|
PyramidScheme.configure do |config|
|
78
106
|
config.index_provider_class = PyramidScheme::IndexProvider::S3
|
79
|
-
config.
|
80
|
-
config.
|
81
|
-
|
82
|
-
config.prefix = yml_config["prefix"]
|
83
|
-
config.server_source_path = "/some/server/source"
|
84
|
-
config.client_destination_path = "/some/client/destination"
|
85
|
-
end
|
107
|
+
config.client_destination_path = File.join(File.dirname(__FILE__), 'destination')
|
108
|
+
config.server_source_path = File.join(File.dirname(__FILE__), 'source')
|
109
|
+
end
|
86
110
|
|
111
|
+
PyramidScheme.configure_with_yml(File.join(File.dirname(__FILE__), 's3.yml'))
|
87
112
|
FakeFS.activate!
|
88
|
-
|
89
113
|
end
|
90
114
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PyramidScheme::Configuration do
|
4
|
+
describe "from yml" do
|
5
|
+
before(:each) do
|
6
|
+
FakeFS.deactivate!
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
FakeFS.activate!
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have a method that allows configuration from a yml file' do
|
14
|
+
PyramidScheme.configure_with_yml(
|
15
|
+
File.join(File.dirname(__FILE__), '../configuration.example.yml'))
|
16
|
+
PyramidScheme.configuration[:secret_access_key].should_not be_nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 7
|
9
|
+
version: 0.2.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Dan Pickett
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-23 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -52,9 +52,9 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
segments:
|
54
54
|
- 0
|
55
|
-
-
|
56
|
-
-
|
57
|
-
version: 0.
|
55
|
+
- 6
|
56
|
+
- 2
|
57
|
+
version: 0.6.2
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id003
|
60
60
|
- !ruby/object:Gem::Dependency
|
@@ -145,9 +145,11 @@ files:
|
|
145
145
|
- lib/pyramid_scheme/tasks/rake_tasks.rake
|
146
146
|
- lib/pyramid_scheme/thinking_sphinx_indexer.rb
|
147
147
|
- lib/pyramid_scheme/ultrasphinx_indexer.rb
|
148
|
+
- spec/configuration.example.yml
|
148
149
|
- spec/integrations/s3.example.yml
|
149
150
|
- spec/integrations/s3_spec.rb
|
150
151
|
- spec/pyramid_scheme.rb
|
152
|
+
- spec/pyramid_scheme/configuration_spec.rb
|
151
153
|
- spec/pyramid_scheme/index_client_spec.rb
|
152
154
|
- spec/pyramid_scheme/index_provider/file_system_spec.rb
|
153
155
|
- spec/pyramid_scheme/index_provider_configuration_spec.rb
|
@@ -189,6 +191,7 @@ specification_version: 3
|
|
189
191
|
summary: Sphinx index propagation
|
190
192
|
test_files:
|
191
193
|
- spec/integrations/s3_spec.rb
|
194
|
+
- spec/pyramid_scheme/configuration_spec.rb
|
192
195
|
- spec/pyramid_scheme/index_client_spec.rb
|
193
196
|
- spec/pyramid_scheme/index_provider/file_system_spec.rb
|
194
197
|
- spec/pyramid_scheme/index_provider_configuration_spec.rb
|