gitconfigio 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.
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +34 -0
- data/Rakefile +7 -0
- data/gitconfigio.gemspec +24 -0
- data/lib/gitconfigio/version.rb +3 -0
- data/lib/gitconfigio.rb +51 -0
- data/spec/gitconfigio_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +107 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Gitconfigio
|
2
|
+
|
3
|
+
gitconfig Input/Output
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'gitconfigio'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install gitconfigio
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/gitconfigio/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
|
32
|
+
|
33
|
+
## LICENCE
|
34
|
+
GNU GPLv3
|
data/Rakefile
ADDED
data/gitconfigio.gemspec
ADDED
@@ -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 'gitconfigio/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gitconfigio"
|
8
|
+
spec.version = Gitconfigio::VERSION
|
9
|
+
spec.authors = ["mocchi"]
|
10
|
+
spec.email = ["boom.boom.planet@gmail.com"]
|
11
|
+
spec.summary = %q{gitconfig Input/Output}
|
12
|
+
spec.description = %q{gitconfig Input/Output}
|
13
|
+
spec.homepage = "https://github.com/mocchit/gitconfigio"
|
14
|
+
spec.license = "GPLv3"
|
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"
|
24
|
+
end
|
data/lib/gitconfigio.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative "gitconfigio/version"
|
2
|
+
|
3
|
+
module GitConfigIO
|
4
|
+
|
5
|
+
def self.parse_value(source)
|
6
|
+
key,value = source.split('=')
|
7
|
+
return key.gsub(/\s/,''),value.sub(/^\s/,'') if key && value
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parse_node(line_source)
|
11
|
+
config = {}
|
12
|
+
head = nil
|
13
|
+
line_source.each do |l|
|
14
|
+
if /^\[(.+)\]$/ === l
|
15
|
+
head = {}
|
16
|
+
config[l.match(/^\[(.+)\]$/)[1]] = head
|
17
|
+
elsif /^#/ === l
|
18
|
+
next
|
19
|
+
elsif !!head
|
20
|
+
key,value = parse_value(l)
|
21
|
+
head[key] = value if key
|
22
|
+
end
|
23
|
+
end
|
24
|
+
config
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.parse(source)
|
28
|
+
ls = source.split("\n")
|
29
|
+
config = parse_node(ls)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.load(path)
|
33
|
+
parse(File.read(File.expand_path(path)))
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.generate(hash)
|
37
|
+
str = ''
|
38
|
+
hash.keys.each do |key|
|
39
|
+
str << "[#{key}]\n"
|
40
|
+
hash[key].each do |k,v|
|
41
|
+
str << "\t#{k} = #{v}\n"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
str
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.dump(path,source = '')
|
48
|
+
source = generate(source) if source.class == Hash
|
49
|
+
File.write(File.expand_path(path),source)
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitconfigio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- mocchi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.7'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.7'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '10.0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '10.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: gitconfig Input/Output
|
63
|
+
email:
|
64
|
+
- boom.boom.planet@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .rspec
|
71
|
+
- .travis.yml
|
72
|
+
- Gemfile
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- gitconfigio.gemspec
|
76
|
+
- lib/gitconfigio.rb
|
77
|
+
- lib/gitconfigio/version.rb
|
78
|
+
- spec/gitconfigio_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
homepage: https://github.com/mocchit/gitconfigio
|
81
|
+
licenses:
|
82
|
+
- GPLv3
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.8.23
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: gitconfig Input/Output
|
105
|
+
test_files:
|
106
|
+
- spec/gitconfigio_spec.rb
|
107
|
+
- spec/spec_helper.rb
|