yml_reader 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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format Fuubar
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3-p0@data_magic --create
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'fuubar'
5
+ gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
6
+ gem 'growl'
7
+ gem 'guard-rspec'
8
+
9
+ # Specify your gem's dependencies in yml_reader.gemspec
10
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :cli => '--color --format Fuubar' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/yml_reader/#{m[1]}_spec.rb" }
7
+ watch(%r{^(.+)\.rb$}) { |m| "spec/yml_reader/#{m[1]}_spec.rb" }
8
+ watch('spec/spec_helper.rb') { "spec" }
9
+ end
10
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jeffrey S. Morgan
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,53 @@
1
+ # YmlReader
2
+
3
+ Simple (very simple) gem to set a directory and load yaml files. This gem is a result of finding duplication between my data_magic and fig_newton gems. Here's an example of how it is used in the fig_newton gem:
4
+
5
+ First of all you need to extend the `YmlReader` gem if you intend to use it in another Module:
6
+
7
+ ````ruby
8
+ class FigNewton
9
+ extend YmlReader
10
+ ````
11
+
12
+ By extending the `YmlReader` module you now have three new methods and two instance variables. Here are the three methods:
13
+
14
+ ````ruby
15
+ yml_directory=
16
+ yml_directory
17
+ load
18
+ ````
19
+
20
+ and the instance variables:
21
+
22
+ ````ruby
23
+ @yml_directory
24
+ @yml
25
+ ````
26
+
27
+ The `@yml` instance variable will contain the contents of the yml file after a call to load.
28
+
29
+ ## Installation
30
+
31
+ Add this line to your application's Gemfile:
32
+
33
+ gem 'yml_reader'
34
+
35
+ And then execute:
36
+
37
+ $ bundle
38
+
39
+ Or install it yourself as:
40
+
41
+ $ gem install yml_reader
42
+
43
+ ## Usage
44
+
45
+ TODO: Write usage instructions here
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.ruby_opts = "-I lib:spec"
8
+ spec.pattern = 'spec/**/*_spec.rb'
9
+ end
10
+ task :spec
11
+
12
+ task :default => :spec
data/lib/yml_reader.rb ADDED
@@ -0,0 +1,29 @@
1
+ require "yml_reader/version"
2
+
3
+ module YmlReader
4
+
5
+ #
6
+ # Set the directory to use when reading yml files
7
+ #
8
+ def yml_directory=(directory)
9
+ @yml_directory = directory
10
+ end
11
+
12
+ #
13
+ # Returns the directory to be used when reading yml files
14
+ #
15
+ def yml_directory
16
+ return @yml_directory if @yml_directory
17
+ return default_directory if self.respond_to? :default_directory
18
+ nil
19
+ end
20
+
21
+ #
22
+ # Loads the requested file. It will look for the file in the
23
+ # directory specified by a call to the yml_directory= method.
24
+ #
25
+ def load(filename)
26
+ @yml = YAML.load_file "#{@yml_directory}/#{filename}"
27
+ end
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ module YmlReader
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+
5
+ if ENV['coverage']
6
+ raise "simplecov only works on Ruby 1.9" unless RUBY_VERSION =~ /^1\.9/
7
+
8
+ require 'simplecov'
9
+ SimpleCov.start { add_filter "spec/" }
10
+ end
11
+
12
+ require 'rspec'
13
+ require 'yml_reader'
14
+
15
+
16
+
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ module MyModule
4
+ extend YmlReader
5
+
6
+ def self.default_directory
7
+ 'default_directory'
8
+ end
9
+ end
10
+
11
+ describe YmlReader do
12
+ context "when configuring the yml directory" do
13
+ before(:each) do
14
+ MyModule.yml_directory = nil
15
+ end
16
+
17
+ it "should store a yml directory" do
18
+ MyModule.yml_directory = 'some_directory'
19
+ MyModule.yml_directory.should == 'some_directory'
20
+ end
21
+
22
+ it "should default to a directory specified by the containing class" do
23
+ MyModule.yml_directory.should == 'default_directory'
24
+ end
25
+ end
26
+
27
+ context "when reading yml files" do
28
+ it "should read files from the yml_directory" do
29
+ MyModule.yml_directory = 'conf'
30
+ YAML.should_receive(:load_file).with('conf/test').and_return({})
31
+ MyModule.load('test')
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/yml_reader/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jeffrey S. Morgan"]
6
+ gem.email = ["jeff.morgan@leandog.com"]
7
+ gem.description = %q{Sets a directory and reads yml files}
8
+ gem.summary = %q{Sets a directory and reads yml files}
9
+ gem.homepage = "http://github.com/cheezy/yml_reader"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "yml_reader"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = YmlReader::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yml_reader
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeffrey S. Morgan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-03 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Sets a directory and reads yml files
15
+ email:
16
+ - jeff.morgan@leandog.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - .rspec
23
+ - .rvmrc
24
+ - Gemfile
25
+ - Guardfile
26
+ - LICENSE
27
+ - README.md
28
+ - Rakefile
29
+ - lib/yml_reader.rb
30
+ - lib/yml_reader/version.rb
31
+ - spec/spec_helper.rb
32
+ - spec/yml_reader/yml_reader_spec.rb
33
+ - yml_reader.gemspec
34
+ homepage: http://github.com/cheezy/yml_reader
35
+ licenses: []
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 1.8.10
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Sets a directory and reads yml files
58
+ test_files:
59
+ - spec/spec_helper.rb
60
+ - spec/yml_reader/yml_reader_spec.rb