prop2redis 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), 'lib', 'prop2redis', 'version')
2
+ require 'rspec/core/rake_task'
1
3
  require "bundler/gem_tasks"
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ task :default => :spec
data/bin/prop2redis CHANGED
@@ -1,3 +1,3 @@
1
- require File.join(File.dirname(__FILE__), '..', 'lib', 'prop2redis', 'prop2redis')
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'prop2redis')
2
2
 
3
- Prop2Redis::RedisLoader.main
3
+ Prop2redis::RedisLoader.main
@@ -3,7 +3,7 @@ require 'uri'
3
3
  require 'cgi'
4
4
  require 'redis'
5
5
 
6
- module Prop2Redis
6
+ module Prop2redis
7
7
  class RedisLoader
8
8
  # http://www.dzone.com/snippets/load-properties-properties
9
9
  def self.load_properties(properties_filename)
@@ -53,10 +53,15 @@ module Prop2Redis
53
53
  redis = Redis.new(:host=>host, :port=>port, :db=>db)
54
54
  redis.multi do
55
55
  hash.each do |key, value|
56
- redis.hset namespace, key, value
56
+ redis.hset namespace, to_env_format(key), value
57
57
  end
58
58
  end
59
59
  end
60
+
61
+ # Convert to ENV format. ie, "my.property" --> "MY_PROPERTY"
62
+ def to_env_format(key)
63
+ key.upcase.gsub(/[\.|\-]/, "_")
64
+ end
60
65
  end
61
66
  end
62
67
 
@@ -1,3 +1,3 @@
1
1
  module Prop2redis
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/prop2redis.gemspec CHANGED
@@ -18,4 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency('redis')
21
+ gem.add_dependency('prop2env')
22
+ gem.add_development_dependency('rspec')
21
23
  end
@@ -0,0 +1,8 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'prop2redis')
2
+
3
+ describe Prop2redis::RedisLoader do
4
+ it "Converts properties to env variable format" do
5
+ loader = Prop2redis::RedisLoader.new
6
+ loader.to_env_format('this.is-my-key').should == 'THIS_IS_MY_KEY'
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prop2redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-31 00:00:00.000000000 Z
12
+ date: 2012-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
@@ -27,6 +27,38 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: prop2env
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
30
62
  description: Converts .properties files into redenv
31
63
  email:
32
64
  - mshea@rypple.com
@@ -41,9 +73,10 @@ files:
41
73
  - README.md
42
74
  - Rakefile
43
75
  - bin/prop2redis
44
- - lib/prop2redis/prop2redis.rb
76
+ - lib/prop2redis.rb
45
77
  - lib/prop2redis/version.rb
46
78
  - prop2redis.gemspec
79
+ - spec/prop2redis_spec.rb
47
80
  homepage: https://github.com/sheax0r/prop2redis
48
81
  licenses: []
49
82
  post_install_message:
@@ -68,4 +101,5 @@ rubygems_version: 1.8.24
68
101
  signing_key:
69
102
  specification_version: 3
70
103
  summary: Converts .properties files into redenv
71
- test_files: []
104
+ test_files:
105
+ - spec/prop2redis_spec.rb