utility_drawer 0.1.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.
data/README ADDED
@@ -0,0 +1 @@
1
+ This is a gem that defines extensions to classes and modules
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'yaml'
4
+
5
+
6
+ class ClientBase
7
+ include HTTParty
8
+ include Voomify::Config
9
+ has_site_config "services.yml"
10
+
11
+ private
12
+ def self.hashes2struct(object, name="Root")
13
+ return case object
14
+ when Hash
15
+ object = object.clone
16
+ object.each do |key, value|
17
+ object[key] = self.hashes2struct(value, key.capitalize)
18
+ end
19
+ object.to_struct(name)
20
+ when Array
21
+ object = object.clone
22
+ object.map! { |i| self.hashes2struct(i) }
23
+ else
24
+ object
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,5 @@
1
+ class Hash
2
+ def to_struct(struct_name)
3
+ Struct.new(struct_name,*keys).new(*values)
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ require 'stringio'
2
+
3
+ module Kernel
4
+
5
+ def capture_stdout
6
+ out = StringIO.new
7
+ $stdout = out
8
+ yield
9
+ return out
10
+ ensure
11
+ $stdout = STDOUT
12
+ end
13
+
14
+ end
@@ -0,0 +1,27 @@
1
+ module Voomify
2
+ module Config
3
+ module ClassMethods
4
+ def has_site_config(config_name)
5
+ class_eval <<-STUFF
6
+ @site_config = nil
7
+
8
+ def self.site_config
9
+ load_site_config unless @site_config
10
+ @site_config
11
+ end
12
+
13
+ def self.load_site_config
14
+ raw_config = File.read("#{RAILS_ROOT}/config/#{config_name}")
15
+ erb_config = ERB.new(raw_config).result
16
+ @site_config = YAML.load(erb_config)[RAILS_ENV]
17
+ end
18
+ STUFF
19
+ end
20
+ end
21
+
22
+ def self.included(base)
23
+ base.extend ClassMethods
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,2 @@
1
+ require 'extensions/kernel'
2
+ require 'extensions/hash'
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: utility_drawer
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Russell Edens
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-26 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: This gem contains a bunch of useful utilities.
23
+ email: russell@voomify.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README
30
+ files:
31
+ - lib/base/httparty.rb
32
+ - lib/extensions/hash.rb
33
+ - lib/extensions/kernel.rb
34
+ - lib/voomify/config.rb
35
+ - lib/voomify_extensions.rb
36
+ - README
37
+ has_rdoc: true
38
+ homepage: http://www.github.com/voomify/utility_drawer
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --charset=UTF-8
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.7
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Voomify useful classes that most of our projects use
71
+ test_files: []
72
+