pyramid_scheme 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
@@ -29,7 +29,11 @@ module PyramidScheme
29
29
  config_hash = YAML::load(File.open(path))
30
30
  set do |config|
31
31
  config_hash.each do |key, value|
32
- config.send("#{key}=", value)
32
+ if key =~ /class$/
33
+ config.send("#{key}=", recursive_const_get(value))
34
+ else
35
+ config.send("#{key}=", value)
36
+ end
33
37
  end
34
38
  end
35
39
  end
@@ -45,5 +49,15 @@ module PyramidScheme
45
49
  def [](key)
46
50
  configatron.pyramid_scheme.to_hash[key]
47
51
  end
52
+
53
+ def self.recursive_const_get(klass_str, mod_base = Kernel)
54
+ first_namespace = klass_str[/^\w*\:\:/]
55
+ if first_namespace.nil?
56
+ mod_base.const_get(klass_str)
57
+ else
58
+ recursive_const_get(klass_str.gsub(first_namespace, ""),
59
+ mod_base.const_get(first_namespace[0..-3]))
60
+ end
61
+ end
48
62
  end
49
63
  end
@@ -1 +1,34 @@
1
- load(File.join(File.dirname(__FILE__), 'tasks/rake_tasks.rake'))
1
+ module PyramidScheme
2
+ # PyramidScheme::Tasks.new('path/to/configuration/yml')
3
+ class Tasks < ::Rake::TaskLib
4
+ attr_reader :yml_path
5
+
6
+ def initialize(yml_path = nil)
7
+ unless yml_path.nil?
8
+ @yml_path = yml_path
9
+ configure_with_yml
10
+ end
11
+ define
12
+ end
13
+
14
+ protected
15
+ def configure_with_yml
16
+ PyramidScheme.configure_with_yml(@yml_path)
17
+ end
18
+
19
+ def define
20
+ namespace :pyramid_scheme do
21
+ desc "retrieve new sphinx indexes as the client"
22
+ task :retrieve do
23
+ PyramidScheme::IndexClient.new.retrieve_index
24
+ end
25
+
26
+ desc "create new sphinx indexes as the server"
27
+ task :index do
28
+ PyramidScheme::IndexServer.new.index
29
+ end
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -2,5 +2,6 @@ access_key: access_key
2
2
  secret_access_key: secret_access_key
3
3
  bucket: some_bucket
4
4
  prefix: some_prefix
5
+ index_provider_class: PyramidScheme::IndexProvider::S3
5
6
  server_source_path: "/some/server/source"
6
7
  client_destination_path: "/some/client/destination"
@@ -4,6 +4,8 @@ describe PyramidScheme::Configuration do
4
4
  describe "from yml" do
5
5
  before(:each) do
6
6
  FakeFS.deactivate!
7
+ PyramidScheme.configure_with_yml(
8
+ File.join(File.dirname(__FILE__), '../configuration.example.yml'))
7
9
  end
8
10
 
9
11
  after(:each) do
@@ -11,9 +13,11 @@ describe PyramidScheme::Configuration do
11
13
  end
12
14
 
13
15
  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
16
  PyramidScheme.configuration[:secret_access_key].should_not be_nil
17
17
  end
18
+
19
+ it 'should cast a string to a class if suffix of the configuraiton is class' do
20
+ PyramidScheme.configuration[:index_provider_class].should eql(PyramidScheme::IndexProvider::S3)
21
+ end
18
22
  end
19
23
  end
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,7 @@ require 'fakefs/spec_helpers'
13
13
  Spec::Runner.configure do |config|
14
14
  config.before(:each) do
15
15
  PyramidScheme.configure do |config|
16
+ config.index_provider_class = PyramidScheme::IndexProvider::FileSystem
16
17
  config.client_source_path = '/some/default/source'
17
18
  config.client_destination_path = '/some/default/destination'
18
19
  config.server_source_path = '/some/server/source'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 7
9
- version: 0.2.7
8
+ - 8
9
+ version: 0.2.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dan Pickett
@@ -142,7 +142,6 @@ files:
142
142
  - lib/pyramid_scheme/lock/s3.rb
143
143
  - lib/pyramid_scheme/required_configuration_not_found.rb
144
144
  - lib/pyramid_scheme/tasks.rb
145
- - lib/pyramid_scheme/tasks/rake_tasks.rake
146
145
  - lib/pyramid_scheme/thinking_sphinx_indexer.rb
147
146
  - lib/pyramid_scheme/ultrasphinx_indexer.rb
148
147
  - spec/configuration.example.yml
@@ -1,11 +0,0 @@
1
- namespace :pyramid_scheme do
2
- desc "retrieve new sphinx indexes as the client"
3
- task :retrieve => :environment do
4
- PyramidScheme::IndexClient.new.retrieve_index
5
- end
6
-
7
- desc "create new sphinx indexes as the server"
8
- task :index => :environment do
9
- PyramidScheme::IndexServer.new.index
10
- end
11
- end