yml_object 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ba0a6d8447f1a10a062f57853bae360aa8030ee9
4
+ data.tar.gz: 9e5e1b12b2886190d949c927bb57c35c1eb6bb9b
5
+ SHA512:
6
+ metadata.gz: 9336c3b6bcdf4af31894f1b0e73e75d444cac302240320ae4fa03fc1abd1c8d24ea920d36caa4e9ad7f3bf97f99e4af68985c4a3617d52ae75c1a5e1536a0d5c
7
+ data.tar.gz: 5336097f2d710df20fc083c00392f6f48ea7db30147fd2047a0f6e1eeca43ce99d64c12a14c56074293af2ea5250a8c1cd9aa0e15dd8dc884398f52d2979aff5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ *.bundle
13
+ *.so
14
+ *.o
15
+ *.a
16
+ mkmf.log
17
+ rdoc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yml_object.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jason Heylon
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # YmlObject
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'yml_object'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install yml_object
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/yml_object/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,3 @@
1
+ module YmlObject
2
+ VERSION = "0.0.1"
3
+ end
data/lib/yml_object.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "yml_object/version"
2
+ require 'yaml'
3
+
4
+ module YmlObject
5
+ def self.say_hi
6
+ 'Hi'
7
+ end
8
+ def self.load(file_path)
9
+ YmlObject::Object.new(YAML.load_file(file_path))
10
+ end
11
+
12
+ class Object
13
+ def initialize(yml_hash)
14
+ @my_object = yml_hash
15
+ end
16
+
17
+ def method_missing(method_name, *args, &block)
18
+ if @my_object.include?(method_name.to_s)
19
+ value = @my_object[method_name.to_s]
20
+ if value.class == Hash
21
+ value = YmlObject::Object.new value
22
+ end
23
+ return value
24
+ end
25
+ super(method_name, *args, &block)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'yml_object'
5
+
6
+ RSpec.configure do |config|
7
+
8
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe "YmlObject" do
4
+ it 'should get correct value of first level' do
5
+ y = YmlObject.load("#{File.dirname(__FILE__)}/yml_sample.yml")
6
+ expect(y.test).to eq('test')
7
+ end
8
+ it 'should get correct value of second level' do
9
+ y = YmlObject.load("#{File.dirname(__FILE__)}/yml_sample.yml")
10
+ expect(y.user.age).to eq(18)
11
+ end
12
+ it 'should get correct value of deeper level' do
13
+ y = YmlObject.load("#{File.dirname(__FILE__)}/yml_sample.yml")
14
+ expect("#{y.user.name.first_name} #{y.user.name.last_name}").to eq("Jason Heylon")
15
+ end
16
+
17
+ end
@@ -0,0 +1,6 @@
1
+ test: "test"
2
+ user:
3
+ age: 18
4
+ name:
5
+ first_name: "Jason"
6
+ last_name: "Heylon"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yml_object/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yml_object"
8
+ spec.version = YmlObject::VERSION
9
+ spec.authors = ["Jason Heylon"]
10
+ spec.email = ["jasonheylon@gmail.com"]
11
+ spec.summary = %q{Load YML file to a object}
12
+ spec.description = %q{Load YML file to a object}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rspec', '~> 3.2.0'
24
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yml_object
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jason Heylon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.0
55
+ description: Load YML file to a object
56
+ email:
57
+ - jasonheylon@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/yml_object.rb
69
+ - lib/yml_object/version.rb
70
+ - spec/spec_helper.rb
71
+ - spec/yml_object_spec.rb
72
+ - spec/yml_sample.yml
73
+ - yml_object.gemspec
74
+ homepage: ''
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.5
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Load YML file to a object
98
+ test_files:
99
+ - spec/spec_helper.rb
100
+ - spec/yml_object_spec.rb
101
+ - spec/yml_sample.yml