props 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +10 -11
- data/README.md +24 -52
- data/Rakefile +5 -1
- data/lib/props.rb +4 -11
- data/lib/props/version.rb +2 -3
- data/test/test_version.rb +14 -0
- metadata +22 -11
- data/.gemtest +0 -0
- data/lib/props/ini.rb +0 -84
- data/test/test_ini.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b88d1e58bc4160d79848f192186a8cc375d4a82d
|
4
|
+
data.tar.gz: 9edc188d3a49723dd51167359a772a8e66768531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fa51b77c8226beab7f8ca48577f16eb8fdd4a3de1d2a956999471051a26c679eee5a1a387513e6d5f123ac47300368529b64c3dfab4ae25310ad60886d52053
|
7
|
+
data.tar.gz: 8843e8df31d1cd0ec492804a0d4572883cd2f6f9d85f95d99056dbf774ab4588e028b1ca03532ab8a2e35ea46e97fcc3e02d256c5cbe68c835df1385aebe5a80
|
data/Manifest.txt
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
HISTORY.md
|
2
|
-
Manifest.txt
|
3
|
-
README.md
|
4
|
-
Rakefile
|
5
|
-
lib/props.rb
|
6
|
-
lib/props/env.rb
|
7
|
-
lib/props/
|
8
|
-
lib/props/
|
9
|
-
|
10
|
-
test/
|
11
|
-
test/test_ini.rb
|
1
|
+
HISTORY.md
|
2
|
+
Manifest.txt
|
3
|
+
README.md
|
4
|
+
Rakefile
|
5
|
+
lib/props.rb
|
6
|
+
lib/props/env.rb
|
7
|
+
lib/props/props.rb
|
8
|
+
lib/props/version.rb
|
9
|
+
test/helper.rb
|
10
|
+
test/test_version.rb
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
Example:
|
14
14
|
|
15
|
-
|
15
|
+
``` ruby
|
16
16
|
class Config
|
17
17
|
|
18
18
|
DEFAULTS = { 'libs' => [ 'kramdown' ],
|
@@ -44,9 +44,9 @@ class Config
|
|
44
44
|
puts "Loading settings from '#{props_home_file}'..."
|
45
45
|
@props = @props_home = Props.load_file( props_home_file, @props )
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# check for user settings (markdown.yml) in working folder
|
49
|
-
|
49
|
+
|
50
50
|
props_work_file = File.join( '.', 'markdown.yml' )
|
51
51
|
if File.exists?( props_work_file )
|
52
52
|
puts "Loading settings from '#{props_work_file}'..."
|
@@ -59,23 +59,23 @@ class Config
|
|
59
59
|
end
|
60
60
|
|
61
61
|
...
|
62
|
-
|
62
|
+
|
63
63
|
end # class Config
|
64
|
-
|
64
|
+
```
|
65
65
|
|
66
66
|
|
67
67
|
### Environment
|
68
68
|
|
69
69
|
Example:
|
70
70
|
|
71
|
-
|
72
|
-
|
71
|
+
``` ruby
|
72
|
+
puts Env.home
|
73
73
|
# => '/home/gerald'
|
74
|
-
|
74
|
+
```
|
75
75
|
|
76
76
|
Backstage the `Env.home` code looks something like:
|
77
77
|
|
78
|
-
|
78
|
+
``` ruby
|
79
79
|
path = if( ENV['HOME'] || ENV['USERPROFILE'] )
|
80
80
|
ENV['HOME'] || ENV['USERPROFILE']
|
81
81
|
elsif( ENV['HOMEDRIVE'] && ENV['HOMEPATH'] )
|
@@ -91,42 +91,20 @@ path = if( ENV['HOME'] || ENV['USERPROFILE'] )
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
94
|
+
```
|
95
95
|
|
96
96
|
|
97
97
|
`Env.path` returns `ENV[ 'PATH' ]` - splits all path entries
|
98
98
|
w/ file separator (e.g. `;` or `:`) and returns string array
|
99
99
|
|
100
|
-
|
101
|
-
|
100
|
+
``` ruby
|
101
|
+
puts Env.path
|
102
102
|
# => ['/usr/local/sbin',
|
103
|
-
'/usr/local/bin',
|
104
|
-
'/usr/sbin',
|
105
|
-
...
|
106
|
-
]
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
### INI
|
111
|
-
|
112
|
-
Example:
|
113
|
-
|
114
|
-
~~~
|
115
|
-
config_path = './ruby.ini'
|
116
|
-
~~~
|
117
|
-
|
118
|
-
Opt 1) `INI.load` - load from string. Example:
|
119
|
-
|
120
|
-
~~~
|
121
|
-
text = File.read( config_path )
|
122
|
-
config = INI.load( text )
|
123
|
-
~~~
|
124
|
-
|
125
|
-
Opt 2) `INI.load_file` - load from file (shortcut). Example:
|
126
|
-
|
127
|
-
~~~
|
128
|
-
config = INI.load_file( config_path )
|
129
|
-
~~~
|
103
|
+
# '/usr/local/bin',
|
104
|
+
# '/usr/sbin',
|
105
|
+
# ...
|
106
|
+
# ]
|
107
|
+
```
|
130
108
|
|
131
109
|
|
132
110
|
|
@@ -144,7 +122,7 @@ The [`slideshow`](http://slideshow-s9.github.io) gem (also known as Slide Show (
|
|
144
122
|
that lets you create slide shows
|
145
123
|
and author slides in plain text using a wiki-style markup language that's easy-to-write and easy-to-read.
|
146
124
|
|
147
|
-
The [`pluto`](http://feedreader.github.io) gem
|
125
|
+
The [`pluto`](http://feedreader.github.io) gem
|
148
126
|
that lets you auto-build web pages from web feeds.
|
149
127
|
|
150
128
|
The [`markdown`](https://github.com/rubylibs/markdown) gem that lets you use your markdown library
|
@@ -152,20 +130,14 @@ of choice.
|
|
152
130
|
|
153
131
|
|
154
132
|
|
155
|
-
##
|
156
|
-
|
157
|
-
### Config / Settings
|
158
|
-
|
159
|
-
* [`configtoolkit`](http://configtoolkit.rubyforge.org) gem
|
160
|
-
|
161
|
-
### Environment / Env
|
133
|
+
## License
|
162
134
|
|
163
|
-
|
135
|
+
![](https://publicdomainworks.github.io/buttons/zero88x31.png)
|
164
136
|
|
165
|
-
|
137
|
+
The `props` scripts are dedicated to the public domain.
|
138
|
+
Use it as you please with no restrictions whatsoever.
|
166
139
|
|
167
140
|
|
168
|
-
##
|
141
|
+
## Questions? Comments?
|
169
142
|
|
170
|
-
|
171
|
-
Use it as you please with no restrictions whatsoever.
|
143
|
+
Post them to the [wwwmake forum](http://groups.google.com/group/wwwmake). Thanks!
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ Hoe.spec 'props' do
|
|
11
11
|
self.urls = ['https://github.com/rubylibs/props']
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
|
-
self.email = '
|
14
|
+
self.email = 'wwwmake@googlegroups.com'
|
15
15
|
|
16
16
|
# switch extension to .markdown for gihub formatting
|
17
17
|
self.readme_file = 'README.md'
|
@@ -19,6 +19,10 @@ Hoe.spec 'props' do
|
|
19
19
|
|
20
20
|
self.licenses = ['Public Domain']
|
21
21
|
|
22
|
+
self.extra_deps = [
|
23
|
+
['iniparser', '>=0.1.0'],
|
24
|
+
]
|
25
|
+
|
22
26
|
self.spec_extras = {
|
23
27
|
required_ruby_version: '>= 1.9.2'
|
24
28
|
}
|
data/lib/props.rb
CHANGED
@@ -8,11 +8,14 @@ require 'fileutils'
|
|
8
8
|
require 'erb'
|
9
9
|
|
10
10
|
|
11
|
+
# 3rd party
|
12
|
+
require 'iniparser' # (auto-)include INI.load for now (was part of props - now its own gem)
|
13
|
+
|
14
|
+
|
11
15
|
# our own code
|
12
16
|
|
13
17
|
require 'props/version' # version always goes first
|
14
18
|
require 'props/env'
|
15
|
-
require 'props/ini'
|
16
19
|
require 'props/props'
|
17
20
|
|
18
21
|
|
@@ -23,16 +26,6 @@ Env = ConfUtils::Env
|
|
23
26
|
Props = ConfUtils::Props
|
24
27
|
|
25
28
|
|
26
|
-
module INI
|
27
|
-
|
28
|
-
# returns a nested hash
|
29
|
-
# (compatible structure - works like YAML.load_file)
|
30
|
-
|
31
|
-
def self.load_file( path ) ConfUtils::IniFile.load_file( path ); end
|
32
|
-
def self.load( text ) ConfUtils::IniFile.load( text ); end
|
33
|
-
|
34
|
-
end # module INI
|
35
|
-
|
36
29
|
|
37
30
|
|
38
31
|
puts ConfUtils.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG) # say hello
|
data/lib/props/version.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
module ConfUtils
|
4
4
|
|
5
5
|
MAJOR = 1 ## todo: namespace inside version or something - why? why not??
|
6
|
-
MINOR =
|
7
|
-
PATCH =
|
6
|
+
MINOR = 2
|
7
|
+
PATCH = 0
|
8
8
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
9
9
|
|
10
10
|
def self.version
|
@@ -21,4 +21,3 @@ module ConfUtils
|
|
21
21
|
end
|
22
22
|
|
23
23
|
end # module ConfUtils
|
24
|
-
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: props
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: iniparser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rdoc
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -30,17 +44,17 @@ dependencies:
|
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
47
|
+
version: '3.15'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
54
|
+
version: '3.15'
|
41
55
|
description: props - Manage Settings Hierachies (Commandline, User, Home, Defaults,
|
42
56
|
etc.)
|
43
|
-
email:
|
57
|
+
email: wwwmake@googlegroups.com
|
44
58
|
executables: []
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files:
|
@@ -48,18 +62,16 @@ extra_rdoc_files:
|
|
48
62
|
- Manifest.txt
|
49
63
|
- README.md
|
50
64
|
files:
|
51
|
-
- ".gemtest"
|
52
65
|
- HISTORY.md
|
53
66
|
- Manifest.txt
|
54
67
|
- README.md
|
55
68
|
- Rakefile
|
56
69
|
- lib/props.rb
|
57
70
|
- lib/props/env.rb
|
58
|
-
- lib/props/ini.rb
|
59
71
|
- lib/props/props.rb
|
60
72
|
- lib/props/version.rb
|
61
73
|
- test/helper.rb
|
62
|
-
- test/
|
74
|
+
- test/test_version.rb
|
63
75
|
homepage: https://github.com/rubylibs/props
|
64
76
|
licenses:
|
65
77
|
- Public Domain
|
@@ -82,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
94
|
version: '0'
|
83
95
|
requirements: []
|
84
96
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.6.7
|
86
98
|
signing_key:
|
87
99
|
specification_version: 4
|
88
100
|
summary: props - Manage Settings Hierachies (Commandline, User, Home, Defaults, etc.)
|
89
|
-
test_files:
|
90
|
-
- test/test_ini.rb
|
101
|
+
test_files: []
|
data/.gemtest
DELETED
File without changes
|
data/lib/props/ini.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
|
2
|
-
module ConfUtils
|
3
|
-
|
4
|
-
|
5
|
-
class IniFile
|
6
|
-
|
7
|
-
# returns a nested hash
|
8
|
-
# (compatible structure - works like YAML.load_file)
|
9
|
-
|
10
|
-
def self.load_file( path )
|
11
|
-
text = File.open( path, 'r:bom|utf-8' ).read
|
12
|
-
self.load( text )
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.load( text )
|
16
|
-
IniFile.new( text ).parse
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def initialize( text )
|
21
|
-
@text = text
|
22
|
-
end
|
23
|
-
|
24
|
-
def parse
|
25
|
-
hash = top_hash = Hash.new
|
26
|
-
|
27
|
-
text = @text
|
28
|
-
text = text.gsub( "\t", ' ' ) # replace all tabs w/ spaces
|
29
|
-
|
30
|
-
text.each_line do |line|
|
31
|
-
|
32
|
-
### skip comments
|
33
|
-
# e.g. # this is a comment line
|
34
|
-
# or ; this too
|
35
|
-
# or -- haskell style
|
36
|
-
# or % text style
|
37
|
-
|
38
|
-
if line =~ /^\s*#/ || line =~ /^\s*;/ || line =~ /^\s*--/ || line =~ /^\s*%/
|
39
|
-
## logger.debug 'skipping comment line'
|
40
|
-
next
|
41
|
-
end
|
42
|
-
|
43
|
-
### skip blank lines
|
44
|
-
if line =~ /^\s*$/
|
45
|
-
## logger.debug 'skipping blank line'
|
46
|
-
next
|
47
|
-
end
|
48
|
-
|
49
|
-
# pass 1) remove possible trailing eol comment
|
50
|
-
## e.g -> New York # Sample EOL Comment Here (with or without commas,,,,)
|
51
|
-
## becomes -> New York
|
52
|
-
|
53
|
-
line = line.sub( /\s+#.*$/, '' )
|
54
|
-
|
55
|
-
# pass 2) remove leading and trailing whitespace
|
56
|
-
|
57
|
-
line = line.strip
|
58
|
-
|
59
|
-
## check for new section e.g. [planet012-xxx_bc]
|
60
|
-
|
61
|
-
### todo: allow _ or - in strict section key? why? why not??
|
62
|
-
### allow _ or - in value key? why why not??
|
63
|
-
if line =~ /^\s*\[\s*([a-z0-9_\-]+)\s*\]\s*$/ # strict section
|
64
|
-
key = $1.to_s.dup
|
65
|
-
hash = top_hash[ key ] = Hash.new
|
66
|
-
elsif line =~ /^\s*\[\s*([^ \]]+)\s*\]\s*$/ # liberal section; allow everything in key
|
67
|
-
key = $1.to_s.dup
|
68
|
-
hash = top_hash[ key ] = Hash.new
|
69
|
-
elsif line =~ /^\s*([a-z0-9_\-]+)\s*[:=](.*)$/
|
70
|
-
key = $1.to_s.dup
|
71
|
-
value = $2.to_s.strip.dup # check if it can be nil? if yes use blank string e.g. ''
|
72
|
-
### todo: strip quotes from value??? why? why not?
|
73
|
-
hash[ key ] = value
|
74
|
-
else
|
75
|
-
puts "*** warn: skipping unknown line type in ini >#{line}<"
|
76
|
-
end
|
77
|
-
end # each lines
|
78
|
-
|
79
|
-
top_hash
|
80
|
-
end
|
81
|
-
|
82
|
-
end # class IniReader
|
83
|
-
|
84
|
-
end # module ConfUtils
|
data/test/test_ini.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
|
5
|
-
class TestIni < MiniTest::Test
|
6
|
-
|
7
|
-
def test_load
|
8
|
-
|
9
|
-
text = <<EOS
|
10
|
-
# comment
|
11
|
-
; another comment
|
12
|
-
|
13
|
-
key1 = hello
|
14
|
-
key2 : hi!
|
15
|
-
|
16
|
-
[section1]
|
17
|
-
key3 = salut # end of line comment here
|
18
|
-
|
19
|
-
[section2]
|
20
|
-
key4: hola
|
21
|
-
blank =
|
22
|
-
blank2:
|
23
|
-
|
24
|
-
[ http://example.com ]
|
25
|
-
title = A rose is a rose is a rose, eh?
|
26
|
-
title2: A rose is a rose is a rose, eh? # comment here
|
27
|
-
; another one here
|
28
|
-
title3 = A rose is a rose is a rose, eh?
|
29
|
-
EOS
|
30
|
-
|
31
|
-
hash = INI.load( text )
|
32
|
-
pp hash
|
33
|
-
|
34
|
-
assert_equal 'hello', hash['key1']
|
35
|
-
assert_equal 'hi!', hash['key2']
|
36
|
-
assert_equal 'salut', hash['section1']['key3']
|
37
|
-
assert_equal 'hola', hash['section2']['key4']
|
38
|
-
assert_equal '', hash['section2']['blank']
|
39
|
-
assert_equal '', hash['section2']['blank2']
|
40
|
-
assert_equal 'A rose is a rose is a rose, eh?', hash['http://example.com']['title']
|
41
|
-
assert_equal 'A rose is a rose is a rose, eh?', hash['http://example.com']['title2']
|
42
|
-
assert_equal 'A rose is a rose is a rose, eh?', hash['http://example.com']['title3']
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|