vstheme2scss 0.0.8 → 0.0.10
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/bin/vstheme2scss +3 -57
- data/lib/vstheme2scss/converter.rb +64 -0
- metadata +2 -2
- data/lib/converter.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 299b51c5fe5a2e379743026bda1898baad2cc992cc99387f274b6a67b1edee7b
|
4
|
+
data.tar.gz: 2dbbcd63a003b90ed228b1c5e8021a092d56724b5d882db11c7d06646978091a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 448520529d5abaacddd27acdbdb55ec1ae610e92d595362764d536e2f7a56ba8d617054f93ac138eff4e5cc35dbc7d24f273f99f36430b088414f405e20c7b43
|
7
|
+
data.tar.gz: 53af42690bd7b1a3c4bbfa84fe0cf272d6ea64a2c5cddfe32506a0e69b4bf09347baec8167bb4bf26ee08b582e0bddefdc6aa18cbf53c84c946ff0a82fd656d1
|
data/bin/vstheme2scss
CHANGED
@@ -1,33 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require "json"
|
3
|
-
require "pathname"
|
4
2
|
require "optparse"
|
5
3
|
require "ostruct"
|
6
|
-
|
7
|
-
|
8
|
-
tokens.select{ |token|
|
9
|
-
token.key?("name")
|
10
|
-
}.uniq{ |token|
|
11
|
-
token["name"]
|
12
|
-
}.select{ |token|
|
13
|
-
not token["name"].include? "[" and not token["name"].include? "]" and not token["name"].include? "/"
|
14
|
-
}.select{ |token|
|
15
|
-
token["settings"].key?("foreground")
|
16
|
-
}.map{ |token|
|
17
|
-
"\t\t#{token["name"].downcase.gsub(/ /, "-")}-color: #{token["settings"]["foreground"]},"
|
18
|
-
}.join("\n")
|
19
|
-
end
|
20
|
-
|
21
|
-
def build_scss_theme(theme)
|
22
|
-
colors = theme["colors"]
|
23
|
-
tokens = theme["tokenColors"]
|
24
|
-
[
|
25
|
-
"\t#{theme["name"].downcase.gsub(/ /, "-")}: (",
|
26
|
-
"\t\tbackground-color: #{colors["editor.background"]},",
|
27
|
-
"\t\tforeground-color: #{colors["editor.foreground"]},",
|
28
|
-
"#{build_tokens_scss(tokens)}",
|
29
|
-
].join("\n") + "\n\t),"
|
30
|
-
end
|
4
|
+
require "vstheme2scss/converter"
|
5
|
+
include Converter
|
31
6
|
|
32
7
|
options = OpenStruct.new
|
33
8
|
OptionParser.new do |parser|
|
@@ -36,33 +11,4 @@ OptionParser.new do |parser|
|
|
36
11
|
parser.on("-o", "--out-file=OUTFILE", "Output destionation file"){ |o| options[:out_file] = o }
|
37
12
|
end.parse!
|
38
13
|
|
39
|
-
|
40
|
-
puts "Error: Missing output file"
|
41
|
-
exit
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
out_path = Pathname.new(options[:out_file]);
|
46
|
-
json_res = ARGV.map{ |theme_file|
|
47
|
-
theme_path = Pathname.new(theme_file)
|
48
|
-
if not theme_path.directory?
|
49
|
-
theme = JSON.parse(theme_path.read)
|
50
|
-
scss_stub = build_scss_theme(theme)
|
51
|
-
else
|
52
|
-
puts "Error: #{theme_path.dirname}#{theme_path.basename} was not a file."
|
53
|
-
end
|
54
|
-
theme_path.directory? ? nil : JSON.parse(theme_path.read)
|
55
|
-
}.select{ |theme| theme != nil }
|
56
|
-
|
57
|
-
out_res = json_res.map{ |theme| build_scss_theme(theme) }.join("\n")
|
58
|
-
out_path.write("$themes: (\n#{out_res}\n);\n")
|
59
|
-
|
60
|
-
if options[:json_list]
|
61
|
-
json_out_path = Pathname.new(options[:json_list])
|
62
|
-
if json_out_path.directory?
|
63
|
-
puts "Error #{json_out_path.dirname}#{json_out_path.basename} is not a file"
|
64
|
-
else
|
65
|
-
names = json_res.map{ |theme| "#{theme["name"].downcase.gsub(/ /, "-")}" }
|
66
|
-
json_out_path.write(names)
|
67
|
-
end
|
68
|
-
end
|
14
|
+
Converter.make_files(options, ARGV)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "json"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
module Converter
|
5
|
+
def build_tokens_scss(tokens)
|
6
|
+
tokens.select{ |token|
|
7
|
+
token.key?("name")
|
8
|
+
}.uniq{ |token|
|
9
|
+
token["name"]
|
10
|
+
}.select{ |token|
|
11
|
+
not token["name"].include? "[" and not token["name"].include? "]" and not token["name"].include? "/"
|
12
|
+
}.select{ |token|
|
13
|
+
token["settings"].key?("foreground")
|
14
|
+
}.map{ |token|
|
15
|
+
"\t\t#{token["name"].downcase.gsub(/ /, "-")}-color: #{token["settings"]["foreground"]},"
|
16
|
+
}.join("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_scss_theme(theme)
|
20
|
+
colors = theme["colors"]
|
21
|
+
tokens = theme["tokenColors"]
|
22
|
+
[
|
23
|
+
"\t#{theme["name"].downcase.gsub(/ /, "-")}: (",
|
24
|
+
"\t\tbackground-color: #{colors["editor.background"]},",
|
25
|
+
"\t\tforeground-color: #{colors["editor.foreground"]},",
|
26
|
+
"#{build_tokens_scss(tokens)}",
|
27
|
+
].join("\n") + "\n\t),"
|
28
|
+
end
|
29
|
+
|
30
|
+
def theme_files_to_hash(themes)
|
31
|
+
json_res = themes.map{ |theme_file|
|
32
|
+
theme_path = Pathname.new(theme_file)
|
33
|
+
if not theme_path.directory?
|
34
|
+
theme = JSON.parse(theme_path.read)
|
35
|
+
else
|
36
|
+
puts "Error: #{theme_path.dirname}#{theme_path.basename} was not a file."
|
37
|
+
end
|
38
|
+
theme_path.directory? ? nil : JSON.parse(theme_path.read)
|
39
|
+
}.select{ |theme| theme != nil }
|
40
|
+
end
|
41
|
+
|
42
|
+
def make_files(options, themes)
|
43
|
+
if not options[:out_file]
|
44
|
+
puts "Error: Missing output file"
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
|
48
|
+
out_path = Pathname.new(options[:out_file])
|
49
|
+
json_res = theme_files_to_hash(themes)
|
50
|
+
out_res = json_res.map{ |theme| build_scss_theme(theme) }.join("\n")
|
51
|
+
out_path.write("$themes: (\n#{out_res}\n);\n")
|
52
|
+
|
53
|
+
if options[:json_list]
|
54
|
+
json_out_path = Pathname.new(options[:json_list])
|
55
|
+
if json_out_path.directory?
|
56
|
+
puts "Error #{json_out_path.dirname}#{json_out_path.basename} is not a file"
|
57
|
+
else
|
58
|
+
names = json_res.map{ |theme| "#{theme["name"].downcase.gsub(/ /, "-")}" }
|
59
|
+
json_out_path.write(names)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vstheme2scss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Kruhlmann
|
@@ -18,7 +18,7 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- bin/vstheme2scss
|
21
|
-
- lib/converter.rb
|
21
|
+
- lib/vstheme2scss/converter.rb
|
22
22
|
homepage: https://github.com/Kruhlmann/vs-theme-2-scss
|
23
23
|
licenses:
|
24
24
|
- GPL-3.0-or-later
|
data/lib/converter.rb
DELETED
File without changes
|