odm 0.1.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/LICENSE +8 -0
- data/README.md +64 -0
- data/Rakefile +1 -0
- data/VERSION +1 -0
- data/examples/test.rb +30 -0
- data/lib/odm/ext.rb +26 -0
- data/lib/odm.rb +1 -0
- data/odm.gemspec +21 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1777cc023b2925b282b8258d8bd775fe22346d81
|
4
|
+
data.tar.gz: 48fafb1d2ca288764ac7795c755ece47a773644d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b1e72fdca127c2ea42adb825653137c8555366411b98d25dedfc33e63e60e58f029e5cc079ac3f27f71c23a24a29993192e8cbd038480ac1305f792924ee74dc
|
7
|
+
data.tar.gz: bea277b9776ca5ed4e9f6455f84a8887654706dd5dad624ded59aed33c60f870b6f7eb36b9abe88e191180ceddb355c0af376ccb1c249e90300d7151e07ed1f7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Copyright (c) 2014 Adam Luzsi
|
2
|
+
|
3
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
4
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
5
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
6
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
7
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
8
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
ARGV
|
2
|
+
========
|
3
|
+
|
4
|
+
Extension for ARGV obj.
|
5
|
+
With this extension module, you can parse in an easy way the script input tags
|
6
|
+
|
7
|
+
### example
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
|
11
|
+
require 'argv'
|
12
|
+
|
13
|
+
#$ ruby sample/test.rb --test test this ok
|
14
|
+
|
15
|
+
puts ARGV.to_hash
|
16
|
+
# {"--test"=>"test"}
|
17
|
+
|
18
|
+
puts ARGV.to_hash( multi_value: true )
|
19
|
+
# {"--test"=>["test", "this", "ok"]}
|
20
|
+
|
21
|
+
puts ARGV.to_hash( sym_key: true )
|
22
|
+
# {:test=>"test"}
|
23
|
+
|
24
|
+
puts ARGV.to_hash( s: true, m: true )
|
25
|
+
# {:test=>["test", "this", "ok"]}
|
26
|
+
|
27
|
+
puts ARGV.values.inspect
|
28
|
+
# ["test", "this", "ok"]
|
29
|
+
|
30
|
+
puts ARGV.keys.inspect
|
31
|
+
# ["--test"]
|
32
|
+
|
33
|
+
puts ARGV.flag_syms.inspect
|
34
|
+
# [:test, :test, :this, :ok]
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
#### For Modules
|
39
|
+
|
40
|
+
if you write module and you want to have some custom tags and help msg for that,
|
41
|
+
use the following example
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
|
45
|
+
require 'argv'
|
46
|
+
|
47
|
+
ARGVEXT.add_help_msg "This will show you the help msg (this)",:helper,:help,:h
|
48
|
+
|
49
|
+
#
|
50
|
+
# ARGVEXT.help_msg or show_help will read on your values and will produce the following with this example
|
51
|
+
#
|
52
|
+
# This will show you the help msg (this)
|
53
|
+
# --helper
|
54
|
+
# --help
|
55
|
+
# -h
|
56
|
+
|
57
|
+
# this will run on the terminal and break Process,
|
58
|
+
# if the user give one of the helper tags as argv
|
59
|
+
|
60
|
+
```
|
61
|
+
|
62
|
+
### Test
|
63
|
+
|
64
|
+
* you can find a test file in the sample named as "test"
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join"bundler","gem_tasks"
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0.alpha
|
data/examples/test.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "odm"
|
2
|
+
|
3
|
+
#$ ruby sample/test.rb --test test this ok
|
4
|
+
|
5
|
+
# new help
|
6
|
+
ARGV.add_help "heeeelp meeeeee~~~",:no
|
7
|
+
|
8
|
+
ARGV.show_help
|
9
|
+
|
10
|
+
puts "","original ARGV:",ARGV.inspect,""
|
11
|
+
|
12
|
+
puts "hash from argv:",ARGV.to_hash,""
|
13
|
+
# {"--test"=>"test"}
|
14
|
+
|
15
|
+
puts "multi valued hash:",ARGV.to_hash( multi_value: true ),""
|
16
|
+
# {"--test"=>["test", "this", "ok"]}
|
17
|
+
|
18
|
+
puts "sym keyed hash:",ARGV.to_hash( sym_key: true ),""
|
19
|
+
# {:test=>"test"}
|
20
|
+
|
21
|
+
puts "sym keyed multi valued hash:",ARGV.to_hash( s: true, m: true ),""
|
22
|
+
# {:test=>["test", "this", "ok"]}
|
23
|
+
|
24
|
+
puts "argv values without the tags:",ARGV.values.inspect,""
|
25
|
+
# ["test", "this", "ok"]
|
26
|
+
|
27
|
+
puts "argv tags, \"keys\":",ARGV.keys.inspect,""
|
28
|
+
# ["--test"]
|
29
|
+
|
30
|
+
puts "symbolized flags:",ARGV.sym_flags.inspect,""
|
data/lib/odm/ext.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module ODM
|
2
|
+
|
3
|
+
module EXT
|
4
|
+
|
5
|
+
def odm_convert obj
|
6
|
+
raise unless self.class == Class
|
7
|
+
|
8
|
+
case true
|
9
|
+
|
10
|
+
when self <= ::Hash
|
11
|
+
|
12
|
+
when self <= ::Array
|
13
|
+
|
14
|
+
when self <= ::Array
|
15
|
+
|
16
|
+
when self <= ::Array
|
17
|
+
when self <= ::Array
|
18
|
+
when self <= ::Array
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/odm.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'odm/ext'
|
data/odm.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
|
5
|
+
spec.name = "odm"
|
6
|
+
spec.version = File.open(File.join(File.dirname(__FILE__),"VERSION")).read.split("\n")[0].chomp.gsub(' ','')
|
7
|
+
spec.authors = ["Adam Luzsi"]
|
8
|
+
spec.email = ["adamluzsi@gmail.com"]
|
9
|
+
spec.description = %q{ Simple Object Data Mapper. Pars Array of Hash into random Class of classes to make it more object oriented }
|
10
|
+
spec.summary = %q{ Simple Object Data Mapper }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_development_dependency "bundler"
|
18
|
+
spec.add_development_dependency "rake"
|
19
|
+
spec.add_dependency "mpatch", ">= 2.12.1"
|
20
|
+
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: odm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Luzsi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-09 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: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mpatch
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.12.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.12.1
|
55
|
+
description: " Simple Object Data Mapper. Pars Array of Hash into random Class of
|
56
|
+
classes to make it more object oriented "
|
57
|
+
email:
|
58
|
+
- adamluzsi@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- VERSION
|
69
|
+
- examples/test.rb
|
70
|
+
- lib/odm.rb
|
71
|
+
- lib/odm/ext.rb
|
72
|
+
- odm.gemspec
|
73
|
+
homepage:
|
74
|
+
licenses: []
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.3.1
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Simple Object Data Mapper
|
96
|
+
test_files: []
|