davinci-text 1.0.0.1
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 +7 -0
- data/.byebug_history +86 -0
- data/.circleci/config.yml +57 -0
- data/.gitignore +53 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/REFERENCE.md +71 -0
- data/Rakefile +4 -0
- data/bin/davinci +16 -0
- data/controllers/atom_input_controller.rb +146 -0
- data/controllers/atom_output_controller.rb +107 -0
- data/controllers/cl_args_controller.rb +62 -0
- data/controllers/menu_controller.rb +148 -0
- data/controllers/sublime_input_controller.rb +97 -0
- data/controllers/sublime_output_controller.rb +62 -0
- data/davinci-text.gemspec +34 -0
- data/example_files/atom/atom-dark-syntax/CONTRIBUTING.md +1 -0
- data/example_files/atom/atom-dark-syntax/ISSUE_TEMPLATE.md +40 -0
- data/example_files/atom/atom-dark-syntax/LICENSE.md +20 -0
- data/example_files/atom/atom-dark-syntax/PULL_REQUEST_TEMPLATE.md +28 -0
- data/example_files/atom/atom-dark-syntax/README.md +9 -0
- data/example_files/atom/atom-dark-syntax/index.less +7 -0
- data/example_files/atom/atom-dark-syntax/output.less +384 -0
- data/example_files/atom/atom-dark-syntax/package.json +11 -0
- data/example_files/atom/atom-dark-syntax/styles/editor.less +50 -0
- data/example_files/atom/atom-dark-syntax/styles/syntax-variables.less +44 -0
- data/example_files/atom/atom-dark-syntax/styles/syntax.less +283 -0
- data/example_files/atom/loved-syntax/CONTRIBUTING.md +1 -0
- data/example_files/atom/loved-syntax/LICENSE.md +20 -0
- data/example_files/atom/loved-syntax/README.md +14 -0
- data/example_files/atom/loved-syntax/index.less +18 -0
- data/example_files/atom/loved-syntax/output.less +648 -0
- data/example_files/atom/loved-syntax/package.json +15 -0
- data/example_files/atom/loved-syntax/styles/colors.less +44 -0
- data/example_files/atom/loved-syntax/styles/editor.less +96 -0
- data/example_files/atom/loved-syntax/styles/syntax-variables.less +56 -0
- data/example_files/atom/loved-syntax/styles/syntax/_base.less +311 -0
- data/example_files/atom/loved-syntax/styles/syntax/c.less +5 -0
- data/example_files/atom/loved-syntax/styles/syntax/cpp.less +5 -0
- data/example_files/atom/loved-syntax/styles/syntax/cs.less +5 -0
- data/example_files/atom/loved-syntax/styles/syntax/css.less +13 -0
- data/example_files/atom/loved-syntax/styles/syntax/gfm.less +9 -0
- data/example_files/atom/loved-syntax/styles/syntax/go.less +5 -0
- data/example_files/atom/loved-syntax/styles/syntax/ini.less +5 -0
- data/example_files/atom/loved-syntax/styles/syntax/java.less +24 -0
- data/example_files/atom/loved-syntax/styles/syntax/javascript.less +17 -0
- data/example_files/atom/loved-syntax/styles/syntax/json.less +21 -0
- data/example_files/atom/loved-syntax/styles/syntax/python.less +9 -0
- data/example_files/atom/loved-syntax/styles/syntax/ruby.less +5 -0
- data/example_files/sublime/material.tmTheme +1011 -0
- data/example_files/sublime/monokai.tmTheme +432 -0
- data/lib/.byebug_history +3 -0
- data/lib/templates/atom/.gitignore +3 -0
- data/lib/templates/atom/LICENSE.md +20 -0
- data/lib/templates/atom/README.md +5 -0
- data/lib/templates/atom/index.less +1 -0
- data/lib/templates/atom/package.json +15 -0
- data/lib/templates/atom/styles/base.less +307 -0
- data/lib/templates/atom/styles/colors.less +15 -0
- data/lib/templates/atom/styles/syntax-variables.less +31 -0
- data/lib/templates/sublime/newTheme.tmTheme +438 -0
- data/lib/utility.rb +21 -0
- data/lib/version.rb +3 -0
- metadata +209 -0
data/REFERENCE.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Davinci Reference
|
2
|
+
|
3
|
+
## How does davinci work?
|
4
|
+
|
5
|
+
Sublime Text themes are parsed using [Nokogiri](https://github.com/sparklemotion/nokogiri), an HTML/XML parser.
|
6
|
+
Atom theme files (.less) are combined into one file using [Coyote](https://github.com/xorcery/coyote) and then parsed using regex.
|
7
|
+
|
8
|
+
Once these files are parsed, the colors for categories of code are slotted into an options hash which looks similar to this:
|
9
|
+
|
10
|
+
@options{
|
11
|
+
:foreground => "#000000" // Primary Text Color is Black
|
12
|
+
:background => "#FFFFFF" // Primary Background Color is White
|
13
|
+
:comment_foreground => "#555555" // Comment color is grey
|
14
|
+
:number_foreground => "#FF0000" // Number/Integer color is red
|
15
|
+
:string_foreground => "#00FF00" // String color is green
|
16
|
+
}
|
17
|
+
|
18
|
+
Once the input theme has been parsed and the options hash is full, davinci will clone a template for your output theme and find/replace strings representing options with the actual colors, like so:
|
19
|
+
|
20
|
+
<key>name</key>
|
21
|
+
<string>String</string>
|
22
|
+
<key>foreground</key>
|
23
|
+
<string>":::string_foreground:::"</string>
|
24
|
+
|
25
|
+
@template.gsub!(/":::string_foreground:::"/, "#00FF00")
|
26
|
+
|
27
|
+
To see a list of options and where each color is set in each theme's file(s), view the [reference spreadsheet](https://docs.google.com/spreadsheets/d/1DqhOP7L2ApQSOU6tKnh1Bx-92pzY7-BJK2Yccf6wr-c/edit?usp=sharing).
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
## Theme files from Sublime
|
32
|
+
|
33
|
+
### Finding Sublime Theme Files
|
34
|
+
|
35
|
+
__WINDOWS__
|
36
|
+
|
37
|
+
* If you've downloaded a non-default theme and are using it in Sublime, it is most likely in your Packages/User/ folder. In the Sublime menu, select Preferences > Browse Packages, which will open an explorer/finder window in your Sublime's packages folder. Navigate to /User/ or find the folder in which you selected your theme originally (Preferences > Color Scheme > [Folder])
|
38
|
+
|
39
|
+
* If you'd like to translate a default color scheme, it is recommended that you download (PackageResourceViewer)[https://github.com/skuroda/PackageResourceViewer] and install it in Sublime to easily view your default color scheme files. After installing, open the command palette (Ctrl+Shift+P) and search for "Open Resource". Click that and then choose "Color Scheme - Default". Then choose the color scheme you want to translate.
|
40
|
+
|
41
|
+
|
42
|
+
### Installing Translated Sublime Theme Files
|
43
|
+
|
44
|
+
__WINDOWS__
|
45
|
+
|
46
|
+
* The best way to install a new sublime theme is to go to /packages/user/ and create a folder called "Color Scheme", then place your new .tmTheme file inside that folder.
|
47
|
+
|
48
|
+
* Next, open up your user settings by going to Preferences > Settings - User, and set the filepath in the options: `"color_scheme": "Packages/User/Color Scheme/[YOUR THEME].tmTheme",`
|
49
|
+
|
50
|
+
* This should add your Color Scheme folder to the Color Scheme option under Preferences, and allow you to choose this theme whenever you want.
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
## Theme files from Atom
|
55
|
+
|
56
|
+
### Finding Atom Theme Files
|
57
|
+
|
58
|
+
__WINDOWS__
|
59
|
+
|
60
|
+
* If you're using a custom theme that you've installed already, it is most likely in `/Users/[USER]/.atom/packages`. If it is not, your best bet would be to go to the Atom settings>Theme, and click the 'settings' cog icon next to your chosen syntax-theme. Next to the "View on Atom.io" and "LICENSE" buttons, there should be a "View Code" button. This will open your theme folder as a new project, where you can right click the folder and choose "show in explorer"
|
61
|
+
|
62
|
+
* If you're using a default theme, the easiest way to get these files is to clone it from github. The theme repository can be found when you select the default theme in Settings > Themes, and then click the 'settings' cog icon to reveal a link to github.
|
63
|
+
|
64
|
+
|
65
|
+
### Installing Translated Atom Theme Files
|
66
|
+
|
67
|
+
__WINDOWS__
|
68
|
+
|
69
|
+
* Move your new theme folder into `/Users/[USER]/.atom/packages` and refresh Atom if you're not in dev mode (Ctrl+Shift+f5). Your theme should be available in the Settings > Themes > Syntax Themes dropdown.
|
70
|
+
|
71
|
+
* If this doesn't work, or you want your theme directory in another location, open a terminal in the location where your theme folder is and type `apm link [YOUR THEME FOLDER]`. A link should be created from the .atom/packages folder to your theme folder. Then refresh Atom.
|
data/Rakefile
ADDED
data/bin/davinci
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative "../controllers/menu_controller.rb"
|
3
|
+
require_relative "../controllers/cl_args_controller.rb"
|
4
|
+
require "utility.rb"
|
5
|
+
require "version.rb"
|
6
|
+
|
7
|
+
args = ARGV
|
8
|
+
if args.length == 0
|
9
|
+
menu = Davinci::MenuController.new()
|
10
|
+
menu.start_menu
|
11
|
+
else
|
12
|
+
cl_controller = Davinci::ClArgsController.new(args)
|
13
|
+
cl_controller.run
|
14
|
+
end
|
15
|
+
|
16
|
+
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require "pp"
|
2
|
+
require 'byebug'
|
3
|
+
|
4
|
+
class AtomInputController
|
5
|
+
attr_accessor :options
|
6
|
+
|
7
|
+
def initialize(directory_path)
|
8
|
+
|
9
|
+
@directory_path = directory_path
|
10
|
+
if File.exist?("#{@directory_path}/package.json") && File.exist?("#{@directory_path}/index.less")
|
11
|
+
@package = File.read("#{@directory_path}/package.json")
|
12
|
+
else
|
13
|
+
raise "Error: Atom directory needs a package.json file and an index.less file at path in the directory: #{directory_path}"
|
14
|
+
end
|
15
|
+
@options = {}
|
16
|
+
@color_hash = {}
|
17
|
+
`coyote '#{@directory_path}/index.less:#{@directory_path}/output.less'`
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse_input_files
|
21
|
+
|
22
|
+
@base = File.read("#{@directory_path}/output.less")
|
23
|
+
|
24
|
+
get_theme_name
|
25
|
+
parse_colors
|
26
|
+
get_base_options
|
27
|
+
|
28
|
+
puts "done!"
|
29
|
+
puts ""
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def get_theme_name
|
36
|
+
@package.scan(/"name":\s"(.*?)"\,.*?"theme":\s"syntax"/mx) do |m|
|
37
|
+
@options[:theme_name] = m[0]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_colors
|
42
|
+
|
43
|
+
@less = {}
|
44
|
+
|
45
|
+
@base.scan(/^(@.*):\s*(.*);/i) do |m|
|
46
|
+
if m[1][0] == "@"
|
47
|
+
@less[m[0]] = m[1]
|
48
|
+
else
|
49
|
+
@color_hash[m[0].underscore.to_sym] = m[1]
|
50
|
+
end
|
51
|
+
|
52
|
+
print "."
|
53
|
+
end
|
54
|
+
|
55
|
+
if @less.length > 0
|
56
|
+
less_variable_reduce()
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def less_variable_reduce()
|
62
|
+
|
63
|
+
temp_less_var = {}
|
64
|
+
@less.each do |key, value|
|
65
|
+
|
66
|
+
if @color_hash.has_key?(value.underscore.to_sym)
|
67
|
+
@color_hash[key.underscore.to_sym] = @color_hash[value.underscore.to_sym]
|
68
|
+
@less.delete(key)
|
69
|
+
end
|
70
|
+
|
71
|
+
@base.scan(/^#{value}:\s+(.*);$/x) do |m|
|
72
|
+
if m
|
73
|
+
if m[0][0] == "@"
|
74
|
+
temp_less_var[key] = m[0]
|
75
|
+
else
|
76
|
+
@color_hash[value.underscore.to_sym] = m[0]
|
77
|
+
@color_hash[key.underscore.to_sym] = m[0]
|
78
|
+
@less.delete(key)
|
79
|
+
print "."
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
@less.merge(temp_less_var)
|
87
|
+
|
88
|
+
if @less.length > 0
|
89
|
+
less_variable_reduce()
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_base_options
|
94
|
+
|
95
|
+
parse_options = {
|
96
|
+
foreground: /atom-text-editor.*?^\s*[^background-]color:\s*(.*?);.*?}/mx,
|
97
|
+
background: /atom-text-editor.*?background-color:\s*(.*?);/mx,
|
98
|
+
caret: /atom-text-editor.*?\s*cursor\s*{.*?color:\s*(.*?);/mx,
|
99
|
+
invisibles: /atom-text-editor.*?invisible-character.*?\{.*?color:\s*(.*?)/mx,
|
100
|
+
line_highlight: /\.line-number\.cursor-line.*?\{.*?background-color:\s*(.*?);/mx,
|
101
|
+
selection: /\.selection.*?\.region\s*?{.*?color:\s*(.*?);/mx,
|
102
|
+
brackets_foreground: /\.bracket-matcher\s*?\.region.*?border-bottom:\s*?[0-9]*px\s*?(?:solid|dotted|dashed)\s+?(.*?);/mx,
|
103
|
+
bracket_contents_foreground: /\.bracket-matcher\s*?\.region.*?border-bottom:\s*?[0-9]*px\s*?(?:solid|dotted|dashed)\s+?(.*?);/mx,
|
104
|
+
comment_foreground: /\.syntax--comment.*?\{.*?color:\s*(.*?);/mx,
|
105
|
+
string_foreground: /^\.syntax--string\s*{\n?\s+color:\s*(.*?);$/mx,
|
106
|
+
number_foreground: /\.syntax--constant.*?syntax--numeric.*?\{.*?color:\s*(.*?);/mx,
|
107
|
+
build_in_constant_foreground: /\.syntax--constant.*?\{.*?color:\s*(.*?);/mx,
|
108
|
+
user_defined_constant_foreground: /\.syntax--constant.*?\{.*?color:\s*(.*?);/mx,
|
109
|
+
variable_foreground: /\.syntax--variable.*?\{.*?color:\s*(.*?);/mx,
|
110
|
+
keyword_foreground: /\.syntax--keyword.*?\{.*?color:\s*(.*?);/mx,
|
111
|
+
storage_foreground: /\.syntax--storage.*?\.syntax--modifier.*?\{.*?color:\s*(.*?);/mx,
|
112
|
+
storage_type_foreground: /\.syntax--storage.*?\{.*?color:\s*(.*?);/mx,
|
113
|
+
entity_name_foreground: /^\.syntax--entity.*?color:\s*(.*?);/mx,
|
114
|
+
function_argument_foreground: /syntax--support.*?\{.*?color:\s*(.*?);/mx,
|
115
|
+
tag_name_foreground: /\.syntax--entity\.syntax--name\.syntax--tag.*?{.*?color:\s*(.*?);/mx,
|
116
|
+
tag_attribute_foreground: /\.syntax--other\.syntax--attribute-name.*?\{.*?color:\s*(.*?);/mx,
|
117
|
+
function_call_foreground: /syntax--function.*?\{.*?color:\s*(.*?);.*?\}/mx,
|
118
|
+
library_function_foreground: /syntax--function.*?\{.*?color:\s*(.*?);/mx,
|
119
|
+
library_class_type_foreground: /syntax--support\s*\{.*?color:\s*(.*?);/mx,
|
120
|
+
invalid_foreground: /syntax--illegal.*?\{.*?color:\s*(.*?);/mx,
|
121
|
+
invalid_background: /syntax--illegal.*?\{.*?background-color:\s*(.*?);/mx,
|
122
|
+
}
|
123
|
+
|
124
|
+
parse_options.each do |key, value|
|
125
|
+
|
126
|
+
color = get_hex_value(@base.match(value))
|
127
|
+
|
128
|
+
@options[key] = color
|
129
|
+
# puts "#{key.to_s}: #{color}"
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
return @options
|
135
|
+
end
|
136
|
+
|
137
|
+
def get_hex_value(options_match)
|
138
|
+
if options_match
|
139
|
+
if options_match[1][0] == '@'
|
140
|
+
return @color_hash[options_match[1].underscore.to_sym]
|
141
|
+
else
|
142
|
+
return options_match[1]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
class AtomOutputController
|
5
|
+
attr_reader :options
|
6
|
+
|
7
|
+
def initialize(options, filepath)
|
8
|
+
@directory = filepath.split("/")[0..-2].join("/")
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def duplicate_template_files
|
13
|
+
current_dir = File.expand_path(__FILE__)
|
14
|
+
root_dir = current_dir.split("/")[0..-3].join("/")
|
15
|
+
@new_dir = "#{@directory}/#{@options[:theme_name]}/"
|
16
|
+
|
17
|
+
if File.directory?(@new_dir)
|
18
|
+
FileUtils.rm_rf(@new_dir, secure: true)
|
19
|
+
end
|
20
|
+
|
21
|
+
FileUtils.chmod(0755, "#{root_dir}/lib/templates/atom/")
|
22
|
+
FileUtils.cp_r("#{root_dir}/lib/templates/atom/", @new_dir)
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def insert_styles
|
27
|
+
read_files
|
28
|
+
insert_package_info
|
29
|
+
insert_syntax_variables
|
30
|
+
write_base_info
|
31
|
+
insert_changelog_info
|
32
|
+
cleanup_leftovers
|
33
|
+
|
34
|
+
File.open("#{@new_dir}/styles/base.less", 'w') { |f| f.write(@base) }
|
35
|
+
File.open("#{@new_dir}/styles/syntax-variables.less", 'w') { |f| f.write(@syntax_variables) }
|
36
|
+
puts "done!"
|
37
|
+
puts "Atom theme files created at #{@new_dir}"
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def read_files
|
43
|
+
@package = File.read("#{@new_dir}/package.json")
|
44
|
+
@base = File.read("#{@new_dir}/styles/base.less")
|
45
|
+
@syntax_variables = File.read("#{@new_dir}/styles/syntax-variables.less")
|
46
|
+
end
|
47
|
+
|
48
|
+
def insert_syntax_variables
|
49
|
+
|
50
|
+
syntax_array = ["foreground", "background", "selection", "active_guide", "invisibles", "find_highlight", "diff_header_foreground", "diff_inserted_foreground", "diff_changed_foreground", "diff_deleted_foreground"]
|
51
|
+
|
52
|
+
syntax_array.each do |opt|
|
53
|
+
if @options.key?(opt.to_sym)
|
54
|
+
print "."
|
55
|
+
@syntax_variables.gsub!(/":::#{opt}:::"/, @options[opt.to_sym])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def insert_package_info
|
63
|
+
print "."
|
64
|
+
|
65
|
+
@package.gsub!(/:::theme_name:::/, "#{@options[:theme_name]}-syntax")
|
66
|
+
File.open("#{@new_dir}/package.json", 'w') { |f| f.write(@package) }
|
67
|
+
end
|
68
|
+
|
69
|
+
def write_base_info
|
70
|
+
|
71
|
+
# base_array = ["comment_foreground", "storage_foreground", "built_in_constant_foreground", "keyword_foreground", "language_variable_foreground", "function_argument_foreground", "invalid_deprecated_background", "invalid_deprecated_foreground", "string_foreground", "comment_foreground", "inherited_class_foreground", "function_call_foreground", "library_class_type_foreground", "inherited_class_foreground", "tag_name_foreground", "tag_attribute_foreground", "entity_name_foreground"]
|
72
|
+
|
73
|
+
@options.keys.each do |key|
|
74
|
+
print "."
|
75
|
+
@base.gsub!(/":::#{key.to_s}:::"/, @options[key])
|
76
|
+
end
|
77
|
+
|
78
|
+
# base_array.each do |opt|
|
79
|
+
# print "."
|
80
|
+
# @base.gsub!(/":::#{opt}:::"/, @options[opt.to_sym])
|
81
|
+
# end
|
82
|
+
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
def insert_changelog_info
|
87
|
+
|
88
|
+
date = Date.today()
|
89
|
+
|
90
|
+
changelog_text = "## 0.1.0 - First Release
|
91
|
+
* #{@options[:theme_name]} Theme Translated to Atom on #{date.month}/#{date.mday}/#{date.year}, by DaVinci-Text (https://github.com/mattcheah/davinci)"
|
92
|
+
|
93
|
+
File.open("#{@new_dir}/CHANGELOG.MD", "w") { |f| f.write(changelog_text) }
|
94
|
+
end
|
95
|
+
|
96
|
+
def cleanup_leftovers
|
97
|
+
|
98
|
+
@base.gsub!(/":::.*?_font_style:::"/, "")
|
99
|
+
@base.gsub!(/":::.*?_background:::"/, "")
|
100
|
+
@base.gsub!(/":::.*?_foreground:::"/, @options[:foreground])
|
101
|
+
@base.gsub!(/":::.*?:::"/, @options[:foreground])
|
102
|
+
@syntax_variables.gsub!(/":::.*?:::"/, @options[:foreground])
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative './atom_input_controller.rb'
|
2
|
+
require_relative './atom_output_controller.rb'
|
3
|
+
require_relative './sublime_input_controller.rb'
|
4
|
+
require_relative './sublime_output_controller.rb'
|
5
|
+
|
6
|
+
module Davinci
|
7
|
+
|
8
|
+
class ClArgsController
|
9
|
+
def initialize(args)
|
10
|
+
@args = args
|
11
|
+
@filepath = clean_directory_path(@args[0])
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
|
16
|
+
input_controller = get_input_controller
|
17
|
+
print "reading input file(s)"
|
18
|
+
input_controller.parse_input_files
|
19
|
+
output_controller = get_output_controller(@args[1], input_controller.options)
|
20
|
+
output_controller.duplicate_template_files
|
21
|
+
print "creating output file(s)"
|
22
|
+
output_controller.insert_styles
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_input_controller
|
27
|
+
|
28
|
+
if @filepath[-8..-1] == ".tmTheme"
|
29
|
+
begin
|
30
|
+
return SublimeInputController.new(@filepath)
|
31
|
+
rescue => e
|
32
|
+
puts e
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
else
|
36
|
+
begin
|
37
|
+
return AtomInputController.new(@filepath)
|
38
|
+
rescue => e
|
39
|
+
puts e
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_output_controller(output_editor, options)
|
47
|
+
|
48
|
+
case output_editor
|
49
|
+
when "atom"
|
50
|
+
return AtomOutputController.new(options, @filepath)
|
51
|
+
when "sublime"
|
52
|
+
return SublimeOutputController.new(options, @filepath)
|
53
|
+
else
|
54
|
+
puts "Error: Davinci requires a second argument to know what text editor to output to."
|
55
|
+
puts "eg. `davinci /example_files/atom sublime`"
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require_relative './atom_input_controller.rb'
|
2
|
+
require_relative './atom_output_controller.rb'
|
3
|
+
require_relative './sublime_input_controller.rb'
|
4
|
+
require_relative './sublime_output_controller.rb'
|
5
|
+
|
6
|
+
module Davinci
|
7
|
+
|
8
|
+
class MenuController
|
9
|
+
def initialize
|
10
|
+
puts "##### Color Scheme Translator #####"
|
11
|
+
puts ""
|
12
|
+
puts "Takes a XML/CSS/Less document from your text-editor that specifies syntax colors and outputs a formatted document that is compatible with the text editor you are switching to."
|
13
|
+
|
14
|
+
@from_editor = ""
|
15
|
+
@to_editor = ""
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def start_menu
|
20
|
+
|
21
|
+
puts ""
|
22
|
+
puts "What Text Editor are you currently using?"
|
23
|
+
puts "(1) Sublime"
|
24
|
+
puts "(2) Atom"
|
25
|
+
# puts "(3) Dreamweaver"
|
26
|
+
# puts "(4) Brackets"
|
27
|
+
|
28
|
+
get_from_editor
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_from_editor(option = nil)
|
32
|
+
if option
|
33
|
+
selection = option
|
34
|
+
else
|
35
|
+
selection = gets.chomp
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
case selection
|
40
|
+
when "1"
|
41
|
+
@from_editor = "sublime"
|
42
|
+
puts "Enter the full filepath of your Sublime tmTheme syntax color file."
|
43
|
+
puts "If you do not know where this can be found, please read the documentation."
|
44
|
+
@filepath = clean_directory_path(gets.chomp)
|
45
|
+
|
46
|
+
begin
|
47
|
+
@input_controller = SublimeInputController.new(@filepath)
|
48
|
+
rescue => e
|
49
|
+
puts e
|
50
|
+
raise
|
51
|
+
end
|
52
|
+
|
53
|
+
when "2"
|
54
|
+
@from_editor = "atom"
|
55
|
+
puts "Enter the full filepath of your Atom theme directory"
|
56
|
+
puts "If you do not know where this can be found, please read the documentation."
|
57
|
+
@filepath = clean_directory_path(gets.chomp)
|
58
|
+
|
59
|
+
begin
|
60
|
+
@input_controller = AtomInputController.new(@filepath)
|
61
|
+
rescue => e
|
62
|
+
puts e
|
63
|
+
raise
|
64
|
+
end
|
65
|
+
|
66
|
+
# when "3"
|
67
|
+
# @from_editor = "dreamweaver"
|
68
|
+
# puts "Enter the full filepath of your Dreamweaver _____ file."
|
69
|
+
# puts "If you do not know where this can be found, please read the documentation."
|
70
|
+
# @input_controller = DreamweaverInputController.new(gets.chomp)
|
71
|
+
# when "4"
|
72
|
+
# @from_editor = "brackets"
|
73
|
+
# puts "Enter the full filepath of your Brackets _____ file."
|
74
|
+
# puts "If you do not know where this can be found, please read the documentation."
|
75
|
+
# @input_controller = BracketsInputController.new(gets.chomp)
|
76
|
+
else
|
77
|
+
puts "You did not choose one of the 2 options."
|
78
|
+
start_menu
|
79
|
+
return
|
80
|
+
end
|
81
|
+
|
82
|
+
rescue
|
83
|
+
puts ""
|
84
|
+
puts "This file path was not valid. Please enter your file path again."
|
85
|
+
if @filepath[0] == "/"
|
86
|
+
puts "Did you mean to include a / at the beginning of your path?"
|
87
|
+
end
|
88
|
+
return get_from_editor(selection)
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
parse_file
|
93
|
+
end
|
94
|
+
|
95
|
+
def parse_file
|
96
|
+
print "parsing file"
|
97
|
+
print "."
|
98
|
+
@input_controller.parse_input_files
|
99
|
+
|
100
|
+
get_to_editor
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_to_editor
|
105
|
+
puts ""
|
106
|
+
puts "What editor would you like to move your color scheme to?"
|
107
|
+
puts "(1) Sublime"
|
108
|
+
puts "(2) Atom"
|
109
|
+
# puts "(3) Dreamweaver"
|
110
|
+
# puts "(4) Brackets"
|
111
|
+
|
112
|
+
selection = gets.chomp
|
113
|
+
|
114
|
+
case selection
|
115
|
+
when "1"
|
116
|
+
@to_editor = "sublime"
|
117
|
+
@output_controller = SublimeOutputController.new(@input_controller.options, @filepath)
|
118
|
+
when "2"
|
119
|
+
@to_editor = "atom"
|
120
|
+
@output_controller = AtomOutputController.new(@input_controller.options, @filepath)
|
121
|
+
# when "3"
|
122
|
+
# @to_editor = "dreamweaver"
|
123
|
+
# when "4"
|
124
|
+
# @to_editor = "brackets"
|
125
|
+
else
|
126
|
+
puts "You did not choose one of the 2 options."
|
127
|
+
get_to_editor
|
128
|
+
return
|
129
|
+
end
|
130
|
+
|
131
|
+
if @to_editor == @from_editor
|
132
|
+
puts "That's the editor you started with! Pick a different editor."
|
133
|
+
get_to_editor
|
134
|
+
return
|
135
|
+
end
|
136
|
+
|
137
|
+
translate_to_output
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
def translate_to_output
|
142
|
+
@output_controller.duplicate_template_files
|
143
|
+
print "inserting theme colors"
|
144
|
+
@output_controller.insert_styles
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|