mimimi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+ gem "rails", "~> 2.3.5"
3
+ group :development do
4
+ gem "rspec", "~> 2.3.0"
5
+ gem "bundler", "~> 1.0.0"
6
+ gem "jeweler", "~> 1.6.4"
7
+ gem "rcov", ">= 0"
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (2.3.14)
5
+ actionpack (= 2.3.14)
6
+ actionpack (2.3.14)
7
+ activesupport (= 2.3.14)
8
+ rack (~> 1.1.0)
9
+ activerecord (2.3.14)
10
+ activesupport (= 2.3.14)
11
+ activeresource (2.3.14)
12
+ activesupport (= 2.3.14)
13
+ activesupport (2.3.14)
14
+ diff-lcs (1.1.2)
15
+ git (1.2.5)
16
+ jeweler (1.6.4)
17
+ bundler (~> 1.0)
18
+ git (>= 1.2.5)
19
+ rake
20
+ rack (1.1.2)
21
+ rails (2.3.14)
22
+ actionmailer (= 2.3.14)
23
+ actionpack (= 2.3.14)
24
+ activerecord (= 2.3.14)
25
+ activeresource (= 2.3.14)
26
+ activesupport (= 2.3.14)
27
+ rake (>= 0.8.3)
28
+ rake (0.9.2)
29
+ rcov (0.9.10)
30
+ rspec (2.3.0)
31
+ rspec-core (~> 2.3.0)
32
+ rspec-expectations (~> 2.3.0)
33
+ rspec-mocks (~> 2.3.0)
34
+ rspec-core (2.3.1)
35
+ rspec-expectations (2.3.0)
36
+ diff-lcs (~> 1.1.2)
37
+ rspec-mocks (2.3.0)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ bundler (~> 1.0.0)
44
+ jeweler (~> 1.6.4)
45
+ rails (~> 2.3.5)
46
+ rcov
47
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 4pcbr
2
+
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:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
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.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = mimimi
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to mimimi
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * 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
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 4pcbr. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = "mimimi"
17
+ gem.homepage = "http://github.com/4pcbr/mimimi"
18
+ gem.license = "MIT"
19
+ gem.summary = %Q{config yaml files → openstruct}
20
+ gem.description = %Q{Creates a singletone openstruct item from all your config yaml files }
21
+ gem.email = "i4pcbr@gmail.com"
22
+ gem.authors = ["4pcbr"]
23
+ end
24
+ Jeweler::RubygemsDotOrgTasks.new
25
+
26
+ require 'rspec/core'
27
+ require 'rspec/core/rake_task'
28
+ RSpec::Core::RakeTask.new(:spec) do |spec|
29
+ spec.pattern = FileList['spec/**/*_spec.rb']
30
+ end
31
+
32
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
33
+ spec.pattern = 'spec/**/*_spec.rb'
34
+ spec.rcov = true
35
+ end
36
+
37
+ task :default => :spec
38
+
39
+ require 'rake/rdoctask'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "mimimi #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/config/test.yml ADDED
@@ -0,0 +1,8 @@
1
+ test:
2
+ some_array:
3
+ - elem1
4
+ - elem2
5
+ - elem3
6
+ some_hash:
7
+ key1: [ subkey1, subkey2, subkey3, subkey4 ]
8
+ key2: just a string
data/lib/mimimi.rb ADDED
@@ -0,0 +1,39 @@
1
+ require 'ostruct'
2
+ require 'yaml'
3
+ require 'erb'
4
+
5
+ module Mimimi
6
+
7
+ extend self
8
+
9
+
10
+ def self.[]=(k, v)
11
+ self.send(:attr_accessor, k) if !self.respond_to?(k)
12
+ self.send("#{k}=", v)
13
+ end
14
+
15
+
16
+ def env
17
+ Rails.env
18
+ end
19
+
20
+
21
+ def root
22
+ Rails.root.to_s
23
+ end
24
+
25
+
26
+ def self.yap!(path = nil)
27
+ path ||= root
28
+ Dir[path + '/config/**/*.yml'].each do |f|
29
+ res = YAML::load(ERB.new(IO.read(f)).result)
30
+ cfg = res[env.to_s] if res != false
31
+ next if cfg.nil?
32
+ self[File.basename(f, '.yml')] = OpenStruct.new(cfg)
33
+ end
34
+ end
35
+
36
+
37
+ def self.method_missing(m, *args) nil ; end
38
+
39
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
+
5
+ describe "Mimimi" do
6
+ context "missing method" do
7
+ it "should return nil value" do
8
+ Mimimi.some_unknown_method.should be_nil
9
+ end
10
+ end
11
+
12
+
13
+ context "yap!" do
14
+ it "empty before yap! call" do
15
+ Mimimi.test.should be_nil
16
+ end
17
+
18
+ it "returns test structure" do
19
+ Mimimi.yap!
20
+ Mimimi.test.should_not be_nil
21
+ t = Mimimi.test
22
+ t.some_array.is_a?(Array).should be_true
23
+ t.some_array.length.should eq 3
24
+ t.some_hash.is_a?(Hash).should be_true
25
+ t.some_hash["key1"].is_a?(Array).should be_true
26
+ t.some_hash["key1"].length.should eq 4
27
+ t.some_hash["key2"].is_a?(String).should be_true
28
+ t.some_hash["key2"].should eq "just a string"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'mimimi'
5
+
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+
11
+
12
+ RSpec.configure do |config|
13
+
14
+ end
15
+
16
+
17
+ module Mimimi
18
+ module Rails
19
+ extend self
20
+
21
+ def self.env
22
+ :test
23
+ end
24
+
25
+ def self.root
26
+ File.expand_path(File.join(File.dirname(__FILE__), ".."))
27
+ end
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mimimi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - 4pcbr
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-26 00:00:00.000000000 +04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: &70165683682340 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 2.3.5
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70165683682340
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &70165683681840 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *70165683681840
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ requirement: &70165683681360 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.0.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70165683681360
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ requirement: &70165683680860 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 1.6.4
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *70165683680860
59
+ - !ruby/object:Gem::Dependency
60
+ name: rcov
61
+ requirement: &70165683680380 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *70165683680380
70
+ description: ! 'Creates a singletone openstruct item from all your config yaml files '
71
+ email: i4pcbr@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - LICENSE.txt
76
+ - README.rdoc
77
+ files:
78
+ - .document
79
+ - .rspec
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.rdoc
84
+ - Rakefile
85
+ - VERSION
86
+ - config/test.yml
87
+ - lib/mimimi.rb
88
+ - spec/mimimi_spec.rb
89
+ - spec/spec_helper.rb
90
+ has_rdoc: true
91
+ homepage: http://github.com/4pcbr/mimimi
92
+ licenses:
93
+ - MIT
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ segments:
105
+ - 0
106
+ hash: 4522870966541986669
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 1.6.2
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: config yaml files → openstruct
119
+ test_files: []