compath 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.compath.yml +6 -5
- data/.github/.gitkeep +0 -0
- data/README.md +1 -1
- data/lib/compath.rb +1 -0
- data/lib/compath/cli.rb +2 -1
- data/lib/compath/version.rb +1 -1
- data/lib/compath/yaml_formatter.rb +44 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2547bb4109ddc4b27334c1d7dddf4b9e2485ec8c
|
4
|
+
data.tar.gz: 00a4c8b479e7600f543d1b5009eb0ff789e9b3bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00204f9c2e9fb60983573d2e44ae5e9e1a5a687a6d00cd999c833a93b5dc1131154cd1270b90fd5878c4e7ad6806f2ae2f0842001b93bca182a27e9d4ce501e6
|
7
|
+
data.tar.gz: 988799224d0eaad2080e5abed8b7d3281c7a1cc665dae1f357b98fd58e6e0357f598a01b312d3e36e340d960540adb85895da8c47d899e4f67f6ef22369bb6b3
|
data/.compath.yml
CHANGED
data/.github/.gitkeep
ADDED
File without changes
|
data/README.md
CHANGED
data/lib/compath.rb
CHANGED
data/lib/compath/cli.rb
CHANGED
data/lib/compath/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Compath
|
2
|
+
class YamlFormatter
|
3
|
+
attr_accessor :yaml
|
4
|
+
|
5
|
+
def initialize(yaml)
|
6
|
+
@yaml = yaml
|
7
|
+
end
|
8
|
+
|
9
|
+
def format
|
10
|
+
formatters.each do |formatter|
|
11
|
+
self.yaml = formatter.call(yaml)
|
12
|
+
end
|
13
|
+
yaml
|
14
|
+
end
|
15
|
+
|
16
|
+
def formatters
|
17
|
+
@formatters ||= [
|
18
|
+
remove_trailing_space_formatter,
|
19
|
+
remove_quotes_from_keys_formatter,
|
20
|
+
]
|
21
|
+
end
|
22
|
+
|
23
|
+
def remove_trailing_space_formatter
|
24
|
+
lambda do |yaml|
|
25
|
+
yaml.lines.map(&:rstrip).map {|x| "#{x}\n" }.join
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
QUOTED_KEY_REGEXP = /^"(?<key>[^"]+)":(?<value>.*)/
|
30
|
+
def remove_quotes_from_keys_formatter
|
31
|
+
lambda do |yaml|
|
32
|
+
lines = yaml.lines.map do |line|
|
33
|
+
if m = QUOTED_KEY_REGEXP.match(line)
|
34
|
+
"#{m[:key]}: #{m[:value]}"
|
35
|
+
else
|
36
|
+
line.chomp
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
lines.map {|x| "#{x}\n" }.join
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- meganemura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- ".compath.yml"
|
78
|
+
- ".github/.gitkeep"
|
78
79
|
- ".gitignore"
|
79
80
|
- ".rspec"
|
80
81
|
- ".travis.yml"
|
@@ -94,6 +95,7 @@ files:
|
|
94
95
|
- lib/compath/guide_book.rb
|
95
96
|
- lib/compath/path_sorter.rb
|
96
97
|
- lib/compath/version.rb
|
98
|
+
- lib/compath/yaml_formatter.rb
|
97
99
|
homepage: https://github.com/meganemura/compath
|
98
100
|
licenses:
|
99
101
|
- MIT
|