class Sublimetheme::Make

Public Class Methods

new(maindir, author="") click to toggle source
# File lib/sublimetheme.rb, line 6602
def initialize(maindir, author="")

        @about = "A Vibrant Sublime text 2 and 3 Color Scheme"

        @maindir = maindir
        @author = author

        # Directory paths
        @mypath = Dir.pwd() 
        @themedir = (@mypath + "/" + @maindir)

        #Create folder if not present
        Dir.mkdir(@themedir) if not Dir.exists?(@themedir)
        puts (@maindir + " folder created in current working directory")

        @filename = @maindir + '.tmTheme'  # Name of file
        @filepath = File.join(@themedir, @filename)

        @file = File.open(@filepath,'w') 

        @file.close()

        puts (@maindir.to_s + "/" + @filename.to_s + " created. Feel free to rename it\n\n")
        puts ("TODO: call .start() on class instance\n\n")
end

Public Instance Methods

body(desc, scope, **options) click to toggle source
# File lib/sublimetheme.rb, line 6719
def body(desc, scope, **options)
        desc[0] = desc[0].capitalize

        ln1 = "\t\t<dict>"
        ln2 = "\t\t\t<key>name</key>"
        ln3 = "\t\t\t<string>%s</string>" % (desc)
        ln4 = "\t\t\t<key>scope</key>"
        ln5 = "\t\t\t<string>%s</string>" % (scope)
        ln6 = "\t\t\t<key>settings</key>"
        ln7 = "\t\t\t<dict>\n"

        lnend = "\t\t\t</dict>\n\t\t</dict>\n\n"

        if ((options).size) == 0
                ln7 = "\t\t\t<dict/>\n"
                lnend = "\t\t</dict>\n\n"
        end

        lines = [ln1, ln2, ln3, ln4, ln5, ln6, ln7]

        lines.each{|x| @file.puts(x)}

        (options.sort.map).each{|x, y|
                _write(@file, "background", y.upcase) if x.to_s == "bg"
                _write(@file, "foreground", y.upcase) if x.to_s == "fg"
                _write(@file, "fontStyle", y) if x.to_s == "fs"
        }
        
        @file.write(lnend)

end
complete(uuid="c5873966-71ae-43da-8711-a22542e06922") click to toggle source
# File lib/sublimetheme.rb, line 6751
def complete(uuid="c5873966-71ae-43da-8711-a22542e06922")

        ln1 = ("\t</array>")
        ln2 = ("\t<key>uuid</key>\n\t<string>%s</string>\n" % (uuid))
        ln3 = ("</dict>\n</plist>")
        
        lines = [ln1, ln2, ln3]

        # @file = open(@filepath,'a')

        lines.each{|x| @file.puts(x) }
        # @file.close()

        puts("\nCongratulations. Color Scheme completed")
        puts("\nTODO: call .readme() on your class instance to generate a README file\nArguments are ('repository URL', 'email address', 'screenshot image filename'). \n\nYou can leave all the arguments blank like this '' for each of them if you don't want to supply any but it's advisable to supply them.\nMake sure the image is in the safe folder as the generated README.md file\n\n")

end
head(**options) click to toggle source
# File lib/sublimetheme.rb, line 6667
def head(**options)
        @file = open(@filepath,'a') 

        (options.sort.map).each{|x, y|
                _write(@file, "activeGuide", y.upcase) if x.to_s == "ag"
                _write(@file, "background", y.upcase) if x.to_s == "bg"
                _write(@file, "caret", y.upcase) if x.to_s == "ct"
                _write(@file, "foreground", y.upcase) if x.to_s == "fg"
                _write(@file, "findHighlight", y.upcase) if x.to_s == "fh"
                _write(@file, "findHighlightForeground", y.upcase) if x.to_s == "fhf"
                _write(@file, "gutterForeground", y.upcase) if x.to_s == "gf"        
                _write(@file, "guide", y.upcase) if x.to_s == "gu"   
                _write(@file, "gutter", y.upcase) if x.to_s == "gut" 
                _write(@file, "inactiveSelection", y.upcase) if x.to_s == "ins"      
                _write(@file, "invisibles", y.upcase) if x.to_s == "inv"
                _write(@file, "lineHighlight", y.upcase) if x.to_s == "lh"
                _write(@file, "selectionBorder", y.upcase) if x.to_s == "sb"
                _write(@file, "selection", y.upcase) if x.to_s == "se"
                _write(@file, "stackGuide", y.upcase) if x.to_s == "sg"
        }

        @file.puts("\t\t\t</dict>\n\t\t</dict>\n\n")

        self.body("Comment", "comment", fg: "#919191")
        self.body("String", "string", fg: "#00A33F")
        self.body("Number", "constant.numeric")
        self.body("Built-in constant", "constant.language", fg: "#A535AE")
        self.body("User-defined constant", "constant.character, constant.other")
        self.body("Variable", "variable.language, variable.other")
        self.body("Keyword", "keyword", fg: "#FF5600")
        self.body("Storage", "storage", fg: "#FF5600")
        self.body("Type name", "entity.name.type", fg: "#21439C")
        self.body("Inherited class", "entity.other.inherited-class")
        self.body("Function name", "entity.name.function", fg: "#21439C")
        self.body("Function argument", "variable.parameter")
        self.body("Tag name", "entity.name.tag")
        self.body("Tag attribute", "entity.other.attribute-name")
        self.body("Library function", "support.function", fg: "#A535AE")
        self.body("Library constant", "support.constant", fg: "#A535AE")
        self.body("Library class/type", "support.type, support.class", fg: "#A535AE")
        self.body("Library variable", "support.variable", fg: "#A535AE")
        self.body("Invalid", "invalid", bg: "#990000", fg: "#FFFFFF")
        self.body("String interpolation", "constant.other.placeholder.py", fs: "", fg: "#990000")
        
        puts("IDLE look-alike generated but you can add more customization to your file")
        puts("\nTODO: call .body() on your class instance with arguments:")
        puts("\tinstance.body('description','language scope', 'optional: text decoration')")
        puts("\ne.g. instance.body('Ruby: Comments', 'constant.numeric.ruby', fs='bold italic', fg='#f0f')\n\n")

end
package(repo) click to toggle source
# File lib/sublimetheme.rb, line 6810
def package(repo)
        ln0 = "// If you intend to publish it on packagecontrol.io, then copy the following code into the forked repository and paste it in the corresponding repository folder.\n\n"
        ln1 = '%s %s"name": "%s",' % ['{', "\n\t", @maindir]
        ln2 = '%s"details": "%s",' % ["\t", repo]
        ln3 = '%s"labels": ["color scheme","highlighting","linting"],' % ("\t")
        ln4 = '%s"releases": [' % ["\t"]
        ln5 = '%s%s' % ["\t\t", '{']
        ln6 = '%s"sublime_text": "*",' % ["\t\t\t"]
        ln7 = '%s"tags": true' % ["\t\t\t"]
        ln8 = "%s%s\n\t%s\n%s%s" % ["\t\t",'}', ']', '}', '  //,']

        lines = [ln0, ln1, ln2, ln3, ln4, ln5, ln6, ln7, ln8]

        filename = 'packages.json'   
        filepath = File.join(@themedir, filename)

        file_ = open(filepath,'w')

        lines.each {|x| file_.puts(x) }
        file_.close()

        puts ("Packages.json file created. Check it to make sure it contains the right data")
        puts ("Feel free to delete it too.\n\n")

end
readme(link="", email="", screenshot="") click to toggle source
# File lib/sublimetheme.rb, line 6769
def readme(link="", email="", screenshot="")

        title = "\n# %s Sublime Color Scheme\n\n" % (@maindir)

        img = "\n"

        if (screenshot).size > 4
                img = "## Screenshot\n\n![%s Screenshot preview](./%s)\n\n" % [@maindir, screenshot]
        end

        about = "## About\n\n%s\n\n" % (@about)
        inst = "## Installation\n\nOpen `Tools -> Command Palette...`. Search for `Package Control: Install Package` and click enter. Wait for the available packages to show up and then search for `%s`. Click enter and the color scheme should be installed.\n\n" % (@maindir)

        # Check whether to add a contribution header.
        contrb = ""
        if (link).size >= 5
                contrb = "## Contributing\nAll contributions are welcome. You can fork me on %s\n\n" % (link) 
        else
                contrib = "\n"
        end
                
        licsn = "## License\n\nMIT (c) 2015 %s | %s\n\nThis is free software. It is licensed under the MIT License. Feel free to use this in your own work. However, if you modify and/or redistribute it, please attribute me in some way, and it would be great if you distribute your work under this or a similar license, but it's not required.\n\n"% [@author, email]

        ack = "## Acknowledgements\n\nCreated using Ruby's [sublimetheme](https://rubygems.org/gems/sublimetheme) package by [Taiwo Kareem](https://github.com/tushortz). Alternatively, Use Python's [SublimeScheme](https://pypi.python.org/pypi/Sublimescheme). \n\nAll glory belongs to God.\n\n"


        lines = [title, img, about, inst, contrb, licsn, ack]

        filename = 'README.md'   
        filepath = File.join(@themedir, filename)

        file_ = open(filepath,'w')

        lines.each{|x| file_.write(x) }
        file_.close()

        puts ("\nREADME.md file created. Feel free to customize it.\n\n")
        
end
start() click to toggle source
# File lib/sublimetheme.rb, line 6628
def start()
        ln1 = ('%s<?xml version="1.0" encoding="UTF-8"?>%s') % ["\n", "\n"]
        ln2 = ('<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">')
        ln3 = ('<plist version="1.0">%s<dict>') % ["\n"]
        ln4 = ('%s<key>author</key>%s<string>%s</string>') % ["\t", "\n\t" ,@author]
        ln5 = ('%s<key>name</key>%s<string>%s</string>') % ["\t", "\n\t", @maindir]
        ln6 = ("\t<key>settings</key>\n\t<array>")
        ln7 = ("\t\t<dict>")
        ln8 = ("\t\t\t<key>settings</key>")
        ln9 = ("\t\t\t<dict>\n")

        lines = [ln1, ln2, ln3, ln4, ln5, ln6, ln7, ln8, ln9]
        @file = File.open(@filepath,'w') 

        lines.each{|x| @file.puts(x)}

        @file.close()

        puts ("Main xml heading written")
        puts ("TODO: Call .head() on class instance with any params and values")
        puts ("\ne.g. instance.head(fg='#F0F', bg='#0FF')")
        puts ("options are:\n\tag --> activeGuide")
        puts ("\tbg --> background")
        puts ("\tct --> caret")
        puts ("\tfg --> foreground")
        puts ("\tfh --> findHighlight")
        puts ("\tfhf --> findHighlightForeground")
        puts ("\tgf --> gutterForeground")
        puts ("\tgu --> guide")
        puts ("\tgut --> gutter")
        puts ("\tins --> inactiveSelection")
        puts ("\tinv --> invisibles")
        puts ("\tlh --> lineHighlight")
        puts ("\tsb --> selectionBorder")
        puts ("\tse --> selection")
        puts ("\tsg --> stackGuide\n")
        puts
end