localconfig 0.3.1 → 0.3.2
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 +4 -4
- data/README.md +2 -2
- data/lib/localconfig/config.rb +19 -7
- data/lib/localconfig/version.rb +2 -2
- data/spec/localconfig/config_spec.rb +16 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fd04212aecdab757b1aa37c66c20ec31fe57a6c
|
4
|
+
data.tar.gz: 3e59657314b77fbff2777edf7569ffb6119f9c50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85e43f62c8d096c22234ee1935d36e744ee5ed7ff7a48bb45244aff0c220a798cfe661aabdf2e9f45aa27c427ba9de24eee9976fc00b3de2610352c07cc0ba74
|
7
|
+
data.tar.gz: f8438f461329489edfd3aefe46ee27820b280a0a4bbf32eb94f0a8dbe9655caddc60e2d7544bbaab7d84711cf1537276b544c87645f134357b7427ba7f564023
|
data/README.md
CHANGED
data/lib/localconfig/config.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# File : localconfig/config.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date : 2014-10-
|
5
|
+
# Date : 2014-10-30
|
6
6
|
#
|
7
7
|
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
8
|
# Licence : LGPLv3+
|
@@ -24,8 +24,7 @@ module LocalConfig
|
|
24
24
|
# configuration
|
25
25
|
class Config # {{{1
|
26
26
|
|
27
|
-
|
28
|
-
class RunError < StandardError; end
|
27
|
+
class Error < StandardError; end
|
29
28
|
|
30
29
|
# dir
|
31
30
|
attr_accessor :dir
|
@@ -148,22 +147,30 @@ module LocalConfig
|
|
148
147
|
#
|
149
148
|
# <!-- }}}2 -->
|
150
149
|
def git_repo(path, url, opts = {}) # {{{2
|
150
|
+
%w{ branch rev tag }.count { |x| opts.has_key? x.to_sym } <= 1 \
|
151
|
+
or raise ArgumentError,
|
152
|
+
"You can't use more than one of :rev, :tag, :branch"
|
151
153
|
q = opts.fetch(:quiet, true) ? %w{ --quiet } : []
|
154
|
+
s = opts.fetch(:quiet, true) ?
|
155
|
+
-> *a { _sys *a } :
|
156
|
+
-> *a { puts "$ #{a*' '}"; _sys *a }
|
152
157
|
b = opts[:branch]; b = "origin/#{b}" if b && !b['/']
|
153
158
|
rev = opts[:rev] || opts[:tag]
|
154
159
|
ref = rev || b || 'origin/master'
|
155
160
|
dest = path path
|
156
161
|
if File.exist? dest
|
157
162
|
Dir.chdir(dest) do
|
158
|
-
|
163
|
+
_git_dir_check
|
164
|
+
s[*(%w{ git fetch --force --tags } + q)] \
|
159
165
|
unless rev && %x[ git rev-parse HEAD ] ==
|
160
166
|
%x[ git rev-parse --revs-only #{rev}^0 -- ]
|
161
167
|
end
|
162
168
|
else
|
163
|
-
|
169
|
+
s[*(%w{ git clone } + q + [url, dest])]
|
164
170
|
end
|
165
171
|
Dir.chdir(dest) do
|
166
|
-
|
172
|
+
_git_dir_check
|
173
|
+
s[*(%w{ git reset --hard } + q + [ref] + %w{ -- })]
|
167
174
|
end
|
168
175
|
end # }}}2
|
169
176
|
|
@@ -198,10 +205,15 @@ module LocalConfig
|
|
198
205
|
nil
|
199
206
|
end # }}}2
|
200
207
|
|
208
|
+
# check for .git/
|
209
|
+
def _git_dir_check
|
210
|
+
File.exist? '.git/' or raise Error, 'not a git dir'
|
211
|
+
end
|
212
|
+
|
201
213
|
# run!
|
202
214
|
def _sys(cmd, *args)
|
203
215
|
system([cmd, cmd], *args) or \
|
204
|
-
raise
|
216
|
+
raise Error, "failed to run command #{[cmd]+args} (#$?)"
|
205
217
|
end
|
206
218
|
|
207
219
|
end # }}}1
|
data/lib/localconfig/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# File : localconfig/config_spec.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date : 2014-10-
|
5
|
+
# Date : 2014-10-30
|
6
6
|
#
|
7
7
|
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
8
|
# Licence : LGPLv3+
|
@@ -60,9 +60,9 @@ describe lcc do
|
|
60
60
|
end # }}}1
|
61
61
|
|
62
62
|
context 'glob' do # {{{1
|
63
|
-
it '* -> init.rb pg.json
|
63
|
+
it '* -> bar foo init.rb pg.json' do
|
64
64
|
expect(test1.glob('*').sort).to eq \
|
65
|
-
%w{ init.rb pg.json
|
65
|
+
%w{ bar foo init.rb pg.json }
|
66
66
|
end
|
67
67
|
it '*.json -> pg.json' do
|
68
68
|
expect(test1.glob('*.json').sort).to eq %w{ pg.json }
|
@@ -87,12 +87,22 @@ describe lcc do
|
|
87
87
|
end # }}}1
|
88
88
|
|
89
89
|
context 'load_yaml' do # {{{1
|
90
|
-
it 'loads x.yaml' do
|
91
|
-
x = test1.dup; x.load_yaml 'x.yaml'
|
92
|
-
expect(x.x.to_hash).to eq({ 'foo' => 99, 'bar' => 'hi!' })
|
90
|
+
it 'loads foo/x.yaml' do
|
91
|
+
x = test1.dup; x.load_yaml 'foo/x.yaml'
|
92
|
+
expect(x[:foo].x.to_hash).to eq({ 'foo' => 99, 'bar' => 'hi!' })
|
93
93
|
end
|
94
94
|
end # }}}1
|
95
95
|
|
96
|
+
context 'load_dir' do # {{{1
|
97
|
+
it 'loads bar/y.yml' do
|
98
|
+
x = test1.dup; x.load_dir 'bar'
|
99
|
+
expect(x.bar.y.to_hash).to \
|
100
|
+
eq({ 'spam' => true, 'eggs' => false })
|
101
|
+
end
|
102
|
+
end # }}}1
|
103
|
+
|
104
|
+
# TODO: git_repo
|
105
|
+
|
96
106
|
end
|
97
107
|
|
98
108
|
# vim: set tw=70 sw=2 sts=2 et fdm=marker :
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localconfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix C. Stegerman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|