Krakken 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.
- checksums.yaml +15 -0
- data/lib/krakken.rb +38 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmJkZDljZDNkM2E5MmUxNTUxNTY3MGIzOWI5ZTRhMWM4NDVmNDYxYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YjQxNWZhNmEyODFlNzE2ZWRkZjI1NGQ5ZDM0NGM0OGM3MTZlMGJlYw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MzZkYzM3ZDExN2NhOGFmOTIyZDM3YjQxMTgyOTE1NTE2OGJjNzg1ZmYxMTAx
|
10
|
+
M2EzZDA2MjAzMzk3MjRkY2NjYWQ1OGZmMDMyOGM4ZmZiMmEwYzQyN2Y5YzUx
|
11
|
+
OTJjNTQwYjdkMjlmYzJiZjQwYjFhY2E2ODljZTM5MmJmYWYyYWY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDRhOGUwOTMwOTZlZTM2NzJmZDRlODZhYmQ1YWFhYmVkYjQyM2UwYzMyZWMy
|
14
|
+
ZWM5ZWJjMjMxYzY1NDE3ODU2ZjZlMWU2Mjc2ODZlZmJjYzk2ZmQ5ODJjZDNl
|
15
|
+
MjcyNDIzZjQ2ZTQwNTYwMThjMzg3ZTNkNTVjYWUzNmZjNThkZTQ=
|
data/lib/krakken.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Krakken
|
2
|
+
|
3
|
+
# The method used to parse the config files
|
4
|
+
def parse(config="settings.conf")
|
5
|
+
|
6
|
+
values = []
|
7
|
+
|
8
|
+
# Create a new File handler object
|
9
|
+
File.open(config, 'r') do |configfile|
|
10
|
+
# Keep parsing long as there is another unparsed line in the file
|
11
|
+
while (nextline = configfile.gets)
|
12
|
+
# Check to see if we are parsing a comment
|
13
|
+
if nextline[0] != "#"
|
14
|
+
# Remove the whitespace
|
15
|
+
nextline = nextline.gsub(/\s+/, '')
|
16
|
+
# Split the key from the value
|
17
|
+
# And add each to an array
|
18
|
+
splitvalues = nextline.split("=")
|
19
|
+
splitvalues.each {|object| values << object}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
# Return the parsed values as a hash
|
24
|
+
return Hash[*values.flatten]
|
25
|
+
end
|
26
|
+
|
27
|
+
# The method used to save the config file
|
28
|
+
def write(settings, output="settings.conf")
|
29
|
+
|
30
|
+
# Create the config file as a string to be written to disk
|
31
|
+
config = settings.map{|k,v| "#{k} = #{v}\n"}.join('')
|
32
|
+
|
33
|
+
# And save
|
34
|
+
File.open(output, 'w') {|f| f.write(config)}
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Krakken
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sam Sheffres
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Krakken is able to parse files into a hash, and write a hash to a file.
|
14
|
+
It supports comments started with '#' when parsing, and outputs in the format of
|
15
|
+
'[key]=[value]'
|
16
|
+
email: samsheff@icloud.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/krakken.rb
|
22
|
+
homepage: https://github.com/samsheff/krakken
|
23
|
+
licenses: []
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.0.3
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Config file parser and generator
|
46
|
+
test_files: []
|
47
|
+
has_rdoc:
|