myna 0.0.0
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.
- checksums.yaml +7 -0
- data/lib/myna.rb +39 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d740333b1f649fd18b16c53de18835a0e2f01e83
|
4
|
+
data.tar.gz: feee6383e96598499bd36d9814f75302e90c7fb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cedcb24982c5944931c34844e05325abb5b6410742cc9198a8bba6f05bd365d72af61ec6c06b33fb59b8e873adfc1d30715d96d8f2c90155e59a4ed508cffdf7
|
7
|
+
data.tar.gz: 530896651ac48c2278a7b620f60ffa2f693e1a973244e69e462c70c71c082774ae8bd7d7c76691e58f5d3f76c3c419b7310570f40ade48784cd4e55f99ea18d2
|
data/lib/myna.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# the main myna driver
|
2
|
+
require 'yaml'
|
3
|
+
class Myna
|
4
|
+
# load custom config file to ruby.
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
# >> yaml = Myha.open_yaml(yaml_file_path)
|
8
|
+
# => Config file
|
9
|
+
# >> yaml.value
|
10
|
+
# => Hash
|
11
|
+
# >> yaml.get(:a,:b)
|
12
|
+
# => yaml.value['a']['b']
|
13
|
+
attr_accessor :value
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.open_yaml(path)
|
19
|
+
# open yaml file and return a new MyHa instance of this file
|
20
|
+
self.new.instance_eval do
|
21
|
+
@value=YAML.load_file(path)
|
22
|
+
return self
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def get(*args)
|
27
|
+
# get value from @value, here can use nested, for example:
|
28
|
+
# >> .get(:top_level, :second_level)
|
29
|
+
# same way with the following:
|
30
|
+
# >> value = @value['top_level', :second_level]
|
31
|
+
# in yaml file, structure will be like this:
|
32
|
+
## :top_level
|
33
|
+
## :second_level: 'my_config'
|
34
|
+
value=@value
|
35
|
+
args.each{|arg| value=value[arg.to_s]}
|
36
|
+
value
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: myna
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- gxlonline
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: load config custom file to ruby
|
14
|
+
email: gxlonline@163.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/myna.rb
|
20
|
+
homepage: http://rubygems.org/gems/myna
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: config gem
|
44
|
+
test_files: []
|