sanultari-config 0.1.0.RC1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,12 +6,13 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "ZenTest", "~> 4.8.1"
9
+ gem "ZenTest", "~> 4.8.1"
10
10
  gem "autotest-growl", "~> 0.2.16"
11
- gem "rspec", "~> 2.11"
12
- gem "yard", "~> 0.7"
13
- gem "rdoc", "~> 3.12"
14
- gem "bundler", "~> 1.1"
15
- gem "jeweler", "~> 1.8.3"
16
- gem "rcov", ">= 0", :platform => [:ruby_18, :mingw_18]
11
+ gem "rspec", "~> 2.11"
12
+ gem "yard", "~> 0.7"
13
+ gem "redcarpet", "~> 2.1"
14
+ gem "rdoc", "~> 3.12"
15
+ gem "bundler", "~> 1.1"
16
+ gem "jeweler", "~> 1.8.3"
17
+ gem "rcov", ">= 0", :platform => [:ruby_18, :mingw_18]
17
18
  end
data/Gemfile.lock CHANGED
@@ -15,6 +15,7 @@ GEM
15
15
  rcov (1.0.0)
16
16
  rdoc (3.12)
17
17
  json (~> 1.4)
18
+ redcarpet (2.1.1)
18
19
  rspec (2.11.0)
19
20
  rspec-core (~> 2.11.0)
20
21
  rspec-expectations (~> 2.11.0)
@@ -36,5 +37,6 @@ DEPENDENCIES
36
37
  jeweler (~> 1.8.3)
37
38
  rcov
38
39
  rdoc (~> 3.12)
40
+ redcarpet (~> 2.1)
39
41
  rspec (~> 2.11)
40
42
  yard (~> 0.7)
data/LICENSE.txt CHANGED
@@ -1,20 +1,26 @@
1
- Copyright (c) 2012 Jeong, Jiung
1
+ Copyright (c) 2012, Team SanUltari
2
+ All rights reserved.
2
3
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
10
6
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
13
12
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ The views and conclusions contained in the software and documentation are those
25
+ of the authors and should not be interpreted as representing official policies,
26
+ either expressed or implied, of the FreeBSD Project.
data/README.md CHANGED
@@ -1,9 +1,20 @@
1
- = sanconfig
1
+ # SanUltari Configuration
2
+ [![Gemnasium](https://gemnasium.com/sanultari/config.png)](https://gemnasium.com/sanultari/config)
2
3
 
3
- Description goes here.
4
+ 오브젝트를 이용하여 계층형 설정 정보를 관리하기 위한 라이브러리.
4
5
 
5
- == Contributing to sanconfig
6
-
6
+ ## 사용방식
7
+ ```ruby
8
+ require 'sanultari-config'
9
+ config = SanUltari::Config.new
10
+ config.init!
11
+ config.develop.db.type = 'mysql'
12
+ config.develop.db.host = 'localhost'
13
+ config.develop.db.port = ...
14
+ config.production.db.type = 'postgresql'
15
+ config.production.db.host = 'localhost'
16
+ ```
17
+ ## Contributing to sanultari-config
7
18
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
19
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
20
  * Fork the project.
@@ -12,8 +23,5 @@ Description goes here.
12
23
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
24
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
25
 
15
- == Copyright
16
-
17
- Copyright (c) 2012 Jeong, Jiung. See LICENSE.txt for
18
- further details.
19
-
26
+ ## Copyright
27
+ Copyright (c) 2012 Team SanUltari. See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
17
  gem.name = "sanultari-config"
18
18
  gem.homepage = "https://github.com/sanultari/config"
19
- gem.license = "AFL"
19
+ gem.license = "FreeBSD"
20
20
  gem.summary = %Q{Simple configuration}
21
21
  gem.description = %Q{This library provides simple configuration management with object's attributes. sanconfig support yaml as datastore.}
22
22
  gem.email = "ethernuiel@sanultari.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0.RC1
1
+ 0.1.0
@@ -1,6 +1,15 @@
1
+ # coding: utf-8
1
2
  module SanUltari
2
3
  class Config
4
+ # SanUltari::Config의 설정값들을 실제로 저장하기 위한 객체
5
+ # method 기반으로 동작하므로, method 이름을 격리하기 위하여 상속받은 동적 타입을 생성하여 사용한다.
6
+ #
7
+ # @author Jeong, Jiung
8
+ # @see SanUltari::Config
3
9
  class Store
10
+ # 기본 인덱서
11
+ #
12
+ # @param [String] name 실제로 저장된 값에 접근하기 위한 접근자
4
13
  def [] name
5
14
  @values ||= {}
6
15
 
@@ -8,17 +17,23 @@ module SanUltari
8
17
  @values[name]
9
18
  end
10
19
 
20
+ # 기본 인덱서 세터
21
+ #
22
+ # @param [String] name 값을 저장할 이름. 메서드 이름으로 변경된다.
23
+ # @param [Object] value 저장될 값. 현재 테스트된 타입은 Primary types과 List, Hash에 한한다.
11
24
  def []= name, value
12
25
  @values ||= {}
13
26
 
14
27
  @values[name] = value
15
28
  end
16
29
 
30
+ # 현재 저장되어 있는 설정의 Key값 컬렉션을 반환한다.
17
31
  def keys
18
32
  return [] if @values == nil
19
33
  @values.keys
20
34
  end
21
35
 
36
+ # 설정값에 대해서 Getter와 Setter를 동적으로 생성하기 위한 Handler.
22
37
  def method_missing(method_name, *args, &block)
23
38
  name = method_name.to_s
24
39
  name.chomp!('=')
@@ -1,10 +1,16 @@
1
+ # coding: utf-8
1
2
  require 'sanultari/config/store'
2
3
  require 'yaml'
3
4
 
5
+ # @author Jeong, Jiung
4
6
  module SanUltari
7
+ # @author Jeong, Jiung
5
8
  class Config
6
9
  attr_accessor :name, :path
7
10
 
11
+ # 생성자
12
+ #
13
+ # @param [String] name 설정 Key의 이름. 넘기지 않으면 nil이 설정된다.
8
14
  def initialize name = nil
9
15
  @name = name || nil
10
16
  @path = File.expand_path '.'
@@ -12,6 +18,9 @@ module SanUltari
12
18
  @store = @store_class.new
13
19
  end
14
20
 
21
+ # Config 객체 초기화
22
+ #
23
+ # @param [String] path 읽어 들일 설정 파일의 위치. 넘기지 않으면 아무것도 설정하지 않는다.
15
24
  def init! path = nil
16
25
  return nil if path == nil
17
26
  if @name == nil
@@ -22,6 +31,12 @@ module SanUltari
22
31
  from_hash(config_hash)
23
32
  end
24
33
 
34
+ # Config 객체를 지정된 위치에 YAML 포맷으로 덤프한다.
35
+ #
36
+ # @param [String] path 기록할 파일의 위치. 넘기지 않을 경우 기본값이 셋팅된다. {#init!}을 통해 파일을 읽은 경우에는 읽었던 파일의 위치. 그렇지 않으면 현재 디렉토리내의 config.yml을 대상으로 한다. {#path=}가 설정된 경우에는 {#path}하위에 config.yml을 만든다.
37
+ # @see SanUltari::Config#init!
38
+ # @see SanUltari::Config#path=
39
+ # @see SanUltari::Config#path
25
40
  def save path = nil
26
41
  @name = 'config' if @name == nil
27
42
  path = make_path if path == nil
@@ -31,6 +46,10 @@ module SanUltari
31
46
  end
32
47
  end
33
48
 
49
+ # Config 객체를 {Hash Ruby Hash}로부터 생성한다.
50
+ #
51
+ # @param [Hash] hash {SanUltari::Config}로 변환할 Hash객체
52
+ # @see Hash
34
53
  def from_hash hash
35
54
  raise Exception.new unless hash.instance_of?(Hash)
36
55
 
@@ -45,6 +64,10 @@ module SanUltari
45
64
  end
46
65
  end
47
66
 
67
+ # 현재 Config 객체를 {Hash Ruby Hash}로 변환한다.
68
+ #
69
+ # @return [SanUltari::Config] {SanUltari::Config}객체가 변환된 Hash객체
70
+ # @see Hash
48
71
  def to_hash
49
72
  hash = {}
50
73
  @store.keys.each do |key|
@@ -55,6 +78,9 @@ module SanUltari
55
78
  hash
56
79
  end
57
80
 
81
+ # 현재 패스로부터 적절한 YAML 파일 경로를 만들어낸다.
82
+ #
83
+ # @param [String] path YAML 파일의 위치. 지정되지 않으면, {#name}, {#path}로부터 기본 패스를 만들어낸다.
58
84
  def make_path path = nil
59
85
  return File.expand_path "#{@name}.yml", @path if path == nil
60
86
  if path.start_with?('/', '\\')
@@ -64,6 +90,7 @@ module SanUltari
64
90
  end
65
91
  end
66
92
 
93
+ # 존재하지 않는 메소드 처리를 위한 핸들러
67
94
  def method_missing(method_name, *args, &block)
68
95
  @store.send method_name, *args, &block
69
96
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanultari-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.RC1
5
- prerelease: 6
4
+ version: 0.1.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeong, Jiung
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-19 00:00:00.000000000 Z
12
+ date: 2012-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ZenTest
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0.7'
78
+ - !ruby/object:Gem::Dependency
79
+ name: redcarpet
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '2.1'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.1'
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: rdoc
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -167,7 +183,7 @@ files:
167
183
  - spec/spec_helper.rb
168
184
  homepage: https://github.com/sanultari/config
169
185
  licenses:
170
- - AFL
186
+ - FreeBSD
171
187
  post_install_message:
172
188
  rdoc_options: []
173
189
  require_paths:
@@ -180,13 +196,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
196
  version: '0'
181
197
  segments:
182
198
  - 0
183
- hash: 805368188006248101
199
+ hash: -539915354181194909
184
200
  required_rubygems_version: !ruby/object:Gem::Requirement
185
201
  none: false
186
202
  requirements:
187
- - - ! '>'
203
+ - - ! '>='
188
204
  - !ruby/object:Gem::Version
189
- version: 1.3.1
205
+ version: '0'
190
206
  requirements: []
191
207
  rubyforge_project:
192
208
  rubygems_version: 1.8.24