evertils 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/lib/command.rb +179 -0
 - data/lib/config.rb +14 -0
 - data/lib/configs/templates/daily-friday.enml +14 -0
 - data/lib/configs/templates/daily.enml +9 -0
 - data/lib/configs/templates/monthly.enml +21 -0
 - data/lib/configs/templates/quarterly.enml +0 -0
 - data/lib/configs/templates/weekly.enml +18 -0
 - data/lib/constants.rb +12 -0
 - data/lib/controller.rb +113 -0
 - data/lib/controllers/convert.rb +63 -0
 - data/lib/controllers/generate.rb +51 -0
 - data/lib/controllers/get.rb +70 -0
 - data/lib/controllers/new.rb +88 -0
 - data/lib/helper.rb +19 -0
 - data/lib/helpers/evernote-enml.rb +33 -0
 - data/lib/helpers/evernote-markdown.rb +210 -0
 - data/lib/helpers/evernote.rb +260 -0
 - data/lib/helpers/generate.rb +39 -0
 - data/lib/helpers/time.rb +28 -0
 - data/lib/log.rb +111 -0
 - data/lib/logs.rb +34 -0
 - data/lib/model.rb +26 -0
 - data/lib/model_data.rb +97 -0
 - data/lib/request.rb +20 -0
 - data/lib/router.rb +73 -0
 - data/lib/utils.rb +123 -0
 - metadata +69 -0
 
    
        data/lib/logs.rb
    ADDED
    
    | 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Granify
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Logs
         
     | 
| 
      
 3 
     | 
    
         
            +
                MAX_LOGS_TO_STORE = 30
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                @files = Dir["#{Granify::LOG_DIR}/*/*.log"]
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def self.clean
         
     | 
| 
      
 8 
     | 
    
         
            +
                  if @files.size > 0
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @files.each do |file|
         
     | 
| 
      
 10 
     | 
    
         
            +
                      File.delete file if File.exist? file
         
     | 
| 
      
 11 
     | 
    
         
            +
                    end
         
     | 
| 
      
 12 
     | 
    
         
            +
                    Notify.info("Removed #{@files.size} old log files")
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                def self.dirty?
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @files.size >= MAX_LOGS_TO_STORE
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                # Create a directory if required
         
     | 
| 
      
 21 
     | 
    
         
            +
                def self.mkdir(name)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  dir = "#{Granify::LOG_DIR}/#{name.downcase}"
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  if !Dir.exist? dir
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Dir.mkdir dir
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  # Create the default .gitignore
         
     | 
| 
      
 29 
     | 
    
         
            +
                  File.open("#{dir}/.gitignore", "w+") do |file|
         
     | 
| 
      
 30 
     | 
    
         
            +
                    file.write "# Ignore everything in this directory\n*\n# Except this file\n!.gitignore"
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/model.rb
    ADDED
    
    | 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Granify
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Model
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Base
         
     | 
| 
      
 4 
     | 
    
         
            +
                  attr_accessor :data, :branch, :browser, :command, :start
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  def initialize(hash = nil)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    @data = hash || Granify::Model::Data.new
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    # Current time
         
     | 
| 
      
 10 
     | 
    
         
            +
                    #@time = @data.start
         
     | 
| 
      
 11 
     | 
    
         
            +
                    # Time the command was executed
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @start = Time.now
         
     | 
| 
      
 13 
     | 
    
         
            +
                    # Current working branch
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @branch = @data.branch
         
     | 
| 
      
 15 
     | 
    
         
            +
                    # Browser to execute tests in
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @browser = @data.browser
         
     | 
| 
      
 17 
     | 
    
         
            +
                    # Instantiate the command execution class
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @command = Command::Exec.new
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def bind(hash)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    initialize(hash)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/model_data.rb
    ADDED
    
    | 
         @@ -0,0 +1,97 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Granify
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Model
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Data
         
     | 
| 
      
 4 
     | 
    
         
            +
                  attr_accessor :identifier, :branch, :browser, :files_with_errors
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  def initialize()
         
     | 
| 
      
 7 
     | 
    
         
            +
                    @d = Hash.new([])
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    # setup defaults
         
     | 
| 
      
 10 
     | 
    
         
            +
                    defaults = {
         
     | 
| 
      
 11 
     | 
    
         
            +
                      :issues => {:errors => 0, :warnings => 0},
         
     | 
| 
      
 12 
     | 
    
         
            +
                      :status => {:success => 0, :error => 0, :total => 0, :errors_per_file => 0},
         
     | 
| 
      
 13 
     | 
    
         
            +
                      :success_rate => {:int => 0, :str => "0%"},
         
     | 
| 
      
 14 
     | 
    
         
            +
                      :log => '',
         
     | 
| 
      
 15 
     | 
    
         
            +
                      :below_acceptable_limit => false
         
     | 
| 
      
 16 
     | 
    
         
            +
                    }
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    @branch = Command::Exec.git_current_branch
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @files_with_errors = []
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    @d.merge! defaults
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def unset(key)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    @d.delete(key.to_sym)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  def instance_var(key, val = nil)
         
     | 
| 
      
 29 
     | 
    
         
            +
                    self.class.__send__(:attr_accessor, key)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    instance_variable_set("@#{key}", val)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  def serialize
         
     | 
| 
      
 34 
     | 
    
         
            +
                    @d.to_json
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  def status
         
     | 
| 
      
 38 
     | 
    
         
            +
                    get(:status)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  def success_rate
         
     | 
| 
      
 42 
     | 
    
         
            +
                    get(:success_rate)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  def increment_issues(key, val)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    @d[:issues][key.to_sym] += val
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  def increment_status(key, val)
         
     | 
| 
      
 50 
     | 
    
         
            +
                    @d[:status][key.to_sym] += val
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  def issues
         
     | 
| 
      
 54 
     | 
    
         
            +
                    get(:issues)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  def issues=(val)
         
     | 
| 
      
 58 
     | 
    
         
            +
                    set(:issues, val)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  def log
         
     | 
| 
      
 62 
     | 
    
         
            +
                    get(:log, Granify::DEFAULT_LOG)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  def add_to_error_list(file)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    @files_with_errors << file
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                  def identifier=(val)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    @identifier = val
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                    # create the log file now
         
     | 
| 
      
 73 
     | 
    
         
            +
                    @d[:log] = Log.new(@branch, Time.now, @identifier)
         
     | 
| 
      
 74 
     | 
    
         
            +
                  end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                  def below_acceptable_limit?
         
     | 
| 
      
 77 
     | 
    
         
            +
                    get(:below_acceptable_limit) == true
         
     | 
| 
      
 78 
     | 
    
         
            +
                  end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                  def below_acceptable_limit=(val)
         
     | 
| 
      
 81 
     | 
    
         
            +
                    set(:below_acceptable_limit, val)
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                  def bind!(seed_data)
         
     | 
| 
      
 85 
     | 
    
         
            +
                    @d = seed_data
         
     | 
| 
      
 86 
     | 
    
         
            +
                  end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                  def get(key, default = @d.default)
         
     | 
| 
      
 89 
     | 
    
         
            +
                    @d[key] || default
         
     | 
| 
      
 90 
     | 
    
         
            +
                  end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                  def set(key, val = nil)
         
     | 
| 
      
 93 
     | 
    
         
            +
                    @d[key] = val
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/request.rb
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Granify
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Request
         
     | 
| 
      
 3 
     | 
    
         
            +
                attr_reader :controller, :command, :custom, :flags, :raw_flags
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @controller = ARGV[0].to_sym rescue nil
         
     | 
| 
      
 7 
     | 
    
         
            +
                  
         
     | 
| 
      
 8 
     | 
    
         
            +
                  if ARGV.size > 1
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @command = ARGV[1].to_sym rescue nil
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    if ARGV.size > 2
         
     | 
| 
      
 12 
     | 
    
         
            +
                      @custom = ARGV[2..ARGV.size].select { |p| !p.start_with?('-') }.map &:to_sym || []
         
     | 
| 
      
 13 
     | 
    
         
            +
                      # TODO: parameterize flag key/values
         
     | 
| 
      
 14 
     | 
    
         
            +
                      @flags = ARGV[2..ARGV.size].select { |f| f.start_with?('-') }.map { |f| f.split("=").map &:to_sym } || []
         
     | 
| 
      
 15 
     | 
    
         
            +
                      @raw_flags = ARGV[2..ARGV.size].select { |f| f.start_with?('-') } || []
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/router.rb
    ADDED
    
    | 
         @@ -0,0 +1,73 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Granify
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Router
         
     | 
| 
      
 3 
     | 
    
         
            +
                def route
         
     | 
| 
      
 4 
     | 
    
         
            +
                  # Populate request params
         
     | 
| 
      
 5 
     | 
    
         
            +
                  $request = Request.new
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                  # include the controller
         
     | 
| 
      
 8 
     | 
    
         
            +
                  if File.exists? "#{Granify::CONTROLLER_DIR}#{$request.controller}.rb"
         
     | 
| 
      
 9 
     | 
    
         
            +
                    require "#{Granify::CONTROLLER_DIR}#{$request.controller}.rb"
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  # include helpers
         
     | 
| 
      
 13 
     | 
    
         
            +
                  if File.exists? "#{Granify::HELPER_DIR}#{$request.controller}.rb"
         
     | 
| 
      
 14 
     | 
    
         
            +
                    require "#{Granify::HELPER_DIR}#{$request.controller}.rb"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  # include models
         
     | 
| 
      
 18 
     | 
    
         
            +
                  if File.exists? "#{Granify::MODEL_DIR}#{$request.controller}.rb"
         
     | 
| 
      
 19 
     | 
    
         
            +
                    require "#{Granify::MODEL_DIR}#{$request.controller}.rb"
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  # Create object context and pass it the required command line arguments
         
     | 
| 
      
 23 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 24 
     | 
    
         
            +
                    controller = Granify::Controller.const_get $request.controller.capitalize rescue false
         
     | 
| 
      
 25 
     | 
    
         
            +
                    
         
     | 
| 
      
 26 
     | 
    
         
            +
                    if !controller
         
     | 
| 
      
 27 
     | 
    
         
            +
                      raise "Controller not found: #{$request.controller.capitalize}"
         
     | 
| 
      
 28 
     | 
    
         
            +
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    context = controller.new
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    if context.can_exec? $request.controller, $request.command
         
     | 
| 
      
 33 
     | 
    
         
            +
                      context.pre_exec
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                      # no command sent?  Use default to populate model data
         
     | 
| 
      
 36 
     | 
    
         
            +
                      model_method = ($request.command ? $request.command : context.default_method).to_s + "_data"
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                      # populate model data
         
     | 
| 
      
 39 
     | 
    
         
            +
                      method = context.model.public_method(model_method) rescue false
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                      # model is not set, use Base model instead so the controller still has
         
     | 
| 
      
 42 
     | 
    
         
            +
                      # access to model methods
         
     | 
| 
      
 43 
     | 
    
         
            +
                      if context.model.nil?
         
     | 
| 
      
 44 
     | 
    
         
            +
                        context.model = Model::Base.new
         
     | 
| 
      
 45 
     | 
    
         
            +
                      end
         
     | 
| 
      
 46 
     | 
    
         
            +
                      
         
     | 
| 
      
 47 
     | 
    
         
            +
                      # If the method exists, set model data accordingly
         
     | 
| 
      
 48 
     | 
    
         
            +
                      # If it doesn't exist then just fail silently, the model may not
         
     | 
| 
      
 49 
     | 
    
         
            +
                      # be required by some controllers
         
     | 
| 
      
 50 
     | 
    
         
            +
                      if method.respond_to? :call
         
     | 
| 
      
 51 
     | 
    
         
            +
                        context.model.data = method.call($request.custom || [])
         
     | 
| 
      
 52 
     | 
    
         
            +
                      end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                      if context.methods_require_internet.include? $request.command
         
     | 
| 
      
 55 
     | 
    
         
            +
                        if !Utils.has_internet_connection?
         
     | 
| 
      
 56 
     | 
    
         
            +
                          raise RuntimeError, "Command `#{Granify::PACKAGE_NAME} #{$request.controller} #{$request.command}` requires a connection to the internet.\nPlease check your network configuration settings."
         
     | 
| 
      
 57 
     | 
    
         
            +
                        end
         
     | 
| 
      
 58 
     | 
    
         
            +
                      end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                      # Run the controller
         
     | 
| 
      
 61 
     | 
    
         
            +
                      context.exec
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                      # Run cleanup commands
         
     | 
| 
      
 64 
     | 
    
         
            +
                      context.post_exec
         
     | 
| 
      
 65 
     | 
    
         
            +
                    end
         
     | 
| 
      
 66 
     | 
    
         
            +
                  rescue RuntimeError => e
         
     | 
| 
      
 67 
     | 
    
         
            +
                    Notify.error("#{e.to_s}")
         
     | 
| 
      
 68 
     | 
    
         
            +
                  rescue NameError => e
         
     | 
| 
      
 69 
     | 
    
         
            +
                    Notify.error("#{e.to_s}\n#{e.backtrace.join("\n")}")
         
     | 
| 
      
 70 
     | 
    
         
            +
                  end
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/utils.rb
    ADDED
    
    | 
         @@ -0,0 +1,123 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Granify
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Utils
         
     | 
| 
      
 3 
     | 
    
         
            +
                @cache = Hash.new
         
     | 
| 
      
 4 
     | 
    
         
            +
                
         
     | 
| 
      
 5 
     | 
    
         
            +
                # Gets a list of files from the current directory with a specific extension
         
     | 
| 
      
 6 
     | 
    
         
            +
                def self.get_files(ext)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  @cache[:files] ||= Hash.new
         
     | 
| 
      
 8 
     | 
    
         
            +
                  @cache[:files][ext] ||= []
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  Dir["*.#{ext}"].each do |file|
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @cache[:files][ext].push file
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  @cache[:files][ext]
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                # Gets a list of all files in the project with a specific extension
         
     | 
| 
      
 18 
     | 
    
         
            +
                def self.get_all_files(ext, ignore_paths = '')
         
     | 
| 
      
 19 
     | 
    
         
            +
                  @cache[:files] ||= Hash.new
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @cache[:files][ext] ||= []
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  if @cache[:files][ext].empty?
         
     | 
| 
      
 23 
     | 
    
         
            +
                    Dir["**/*.#{ext}"].each do |file|
         
     | 
| 
      
 24 
     | 
    
         
            +
                      if !ignore_paths.empty?
         
     | 
| 
      
 25 
     | 
    
         
            +
                        # file is a widget
         
     | 
| 
      
 26 
     | 
    
         
            +
                        if /\/#{ignore_paths}/.match(file)
         
     | 
| 
      
 27 
     | 
    
         
            +
                          @cache[:files][ext].push file
         
     | 
| 
      
 28 
     | 
    
         
            +
                        end
         
     | 
| 
      
 29 
     | 
    
         
            +
                      else
         
     | 
| 
      
 30 
     | 
    
         
            +
                        # file is not a widget
         
     | 
| 
      
 31 
     | 
    
         
            +
                        @cache[:files][ext].push file
         
     | 
| 
      
 32 
     | 
    
         
            +
                      end
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  @cache[:files][ext]
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                # Gets a list of files from the current git commit queue with a specific
         
     | 
| 
      
 40 
     | 
    
         
            +
                # extension
         
     | 
| 
      
 41 
     | 
    
         
            +
                def self.get_files_from_git(ext)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  @cache[:files] ||= Hash.new
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @cache[:files][ext] ||= []
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  modified_files = `git status --porcelain`.split("\n")
         
     | 
| 
      
 46 
     | 
    
         
            +
                  modified_files.each do |file|
         
     | 
| 
      
 47 
     | 
    
         
            +
                    if file.match(/#{ext}/)
         
     | 
| 
      
 48 
     | 
    
         
            +
                      @cache[:files][ext].push file.strip.match(/[A-Z ]+(.*)/)[1]
         
     | 
| 
      
 49 
     | 
    
         
            +
                    end
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                  
         
     | 
| 
      
 52 
     | 
    
         
            +
                  @cache[:files][ext]
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                # Generate a filename
         
     | 
| 
      
 56 
     | 
    
         
            +
                def self.generate_path(branch, time, identifier)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  # create the directory if needed
         
     | 
| 
      
 58 
     | 
    
         
            +
                  Logs.mkdir identifier
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  # create a new log file with a path based on the input parameters
         
     | 
| 
      
 61 
     | 
    
         
            +
                  #Log.new(identifier, branch, time)
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                # Convert hash keys to symbols
         
     | 
| 
      
 65 
     | 
    
         
            +
                def self.symbolize_keys(hash)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  Hash[hash.map{ |k, v| [k.to_sym, v] }]
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                 # Create a directory wherever the script is called from, if required
         
     | 
| 
      
 70 
     | 
    
         
            +
                def self.mklocaldir(name)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  dir = "#{Dir.pwd}/#{name.downcase}/"
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                  if !Dir.exist? dir
         
     | 
| 
      
 74 
     | 
    
         
            +
                    Dir.mkdir dir
         
     | 
| 
      
 75 
     | 
    
         
            +
                  else
         
     | 
| 
      
 76 
     | 
    
         
            +
                    dir
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                def self.os
         
     | 
| 
      
 81 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 82 
     | 
    
         
            +
                    @os ||= (
         
     | 
| 
      
 83 
     | 
    
         
            +
                      host_os = RbConfig::CONFIG['host_os']
         
     | 
| 
      
 84 
     | 
    
         
            +
                      case host_os
         
     | 
| 
      
 85 
     | 
    
         
            +
                      when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
         
     | 
| 
      
 86 
     | 
    
         
            +
                        :windows
         
     | 
| 
      
 87 
     | 
    
         
            +
                      when /darwin|mac os/
         
     | 
| 
      
 88 
     | 
    
         
            +
                        :macosx
         
     | 
| 
      
 89 
     | 
    
         
            +
                      when /linux/
         
     | 
| 
      
 90 
     | 
    
         
            +
                        :linux
         
     | 
| 
      
 91 
     | 
    
         
            +
                      when /solaris|bsd/
         
     | 
| 
      
 92 
     | 
    
         
            +
                        :unix
         
     | 
| 
      
 93 
     | 
    
         
            +
                      else
         
     | 
| 
      
 94 
     | 
    
         
            +
                        raise TypeError, "unknown os: #{host_os.inspect}"
         
     | 
| 
      
 95 
     | 
    
         
            +
                      end
         
     | 
| 
      
 96 
     | 
    
         
            +
                    )
         
     | 
| 
      
 97 
     | 
    
         
            +
                  rescue err
         
     | 
| 
      
 98 
     | 
    
         
            +
                    Notify.error(err.message)
         
     | 
| 
      
 99 
     | 
    
         
            +
                  end
         
     | 
| 
      
 100 
     | 
    
         
            +
                end
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                def self.json?(string)
         
     | 
| 
      
 103 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 104 
     | 
    
         
            +
                    !!JSON.parse(string)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  rescue
         
     | 
| 
      
 106 
     | 
    
         
            +
                    false
         
     | 
| 
      
 107 
     | 
    
         
            +
                  end
         
     | 
| 
      
 108 
     | 
    
         
            +
                end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                def self.http_response_code(url = nil)
         
     | 
| 
      
 111 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 112 
     | 
    
         
            +
                    request = Net::HTTP.get_response(URI.parse(url || "http://google.com"))
         
     | 
| 
      
 113 
     | 
    
         
            +
                    request.code.to_i
         
     | 
| 
      
 114 
     | 
    
         
            +
                  rescue
         
     | 
| 
      
 115 
     | 
    
         
            +
                    500
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
      
 117 
     | 
    
         
            +
                end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                def self.has_internet_connection?
         
     | 
| 
      
 120 
     | 
    
         
            +
                  Utils.http_response_code < 499
         
     | 
| 
      
 121 
     | 
    
         
            +
                end
         
     | 
| 
      
 122 
     | 
    
         
            +
              end
         
     | 
| 
      
 123 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,69 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: evertils
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Ryan Priebe
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-07-03 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 13 
     | 
    
         
            +
            description: Evernote utilities for your CLI workflow
         
     | 
| 
      
 14 
     | 
    
         
            +
            email: hello@ryanpriebe.com
         
     | 
| 
      
 15 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 16 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 17 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 18 
     | 
    
         
            +
            files:
         
     | 
| 
      
 19 
     | 
    
         
            +
            - lib/command.rb
         
     | 
| 
      
 20 
     | 
    
         
            +
            - lib/config.rb
         
     | 
| 
      
 21 
     | 
    
         
            +
            - lib/configs/templates/daily-friday.enml
         
     | 
| 
      
 22 
     | 
    
         
            +
            - lib/configs/templates/daily.enml
         
     | 
| 
      
 23 
     | 
    
         
            +
            - lib/configs/templates/monthly.enml
         
     | 
| 
      
 24 
     | 
    
         
            +
            - lib/configs/templates/quarterly.enml
         
     | 
| 
      
 25 
     | 
    
         
            +
            - lib/configs/templates/weekly.enml
         
     | 
| 
      
 26 
     | 
    
         
            +
            - lib/constants.rb
         
     | 
| 
      
 27 
     | 
    
         
            +
            - lib/controller.rb
         
     | 
| 
      
 28 
     | 
    
         
            +
            - lib/controllers/convert.rb
         
     | 
| 
      
 29 
     | 
    
         
            +
            - lib/controllers/generate.rb
         
     | 
| 
      
 30 
     | 
    
         
            +
            - lib/controllers/get.rb
         
     | 
| 
      
 31 
     | 
    
         
            +
            - lib/controllers/new.rb
         
     | 
| 
      
 32 
     | 
    
         
            +
            - lib/helper.rb
         
     | 
| 
      
 33 
     | 
    
         
            +
            - lib/helpers/evernote-enml.rb
         
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/helpers/evernote-markdown.rb
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/helpers/evernote.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/helpers/generate.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/helpers/time.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - lib/log.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - lib/logs.rb
         
     | 
| 
      
 40 
     | 
    
         
            +
            - lib/model.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/model_data.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/request.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/router.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/utils.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
            homepage: http://rubygems.org/gems/evertils
         
     | 
| 
      
 46 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 47 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 48 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 49 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 50 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 51 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 52 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 53 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 54 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 55 
     | 
    
         
            +
              - - '>='
         
     | 
| 
      
 56 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 57 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 58 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 59 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 60 
     | 
    
         
            +
              - - '>='
         
     | 
| 
      
 61 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 62 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 63 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 64 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 65 
     | 
    
         
            +
            rubygems_version: 2.0.14
         
     | 
| 
      
 66 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 67 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 68 
     | 
    
         
            +
            summary: EN (heart) CLI
         
     | 
| 
      
 69 
     | 
    
         
            +
            test_files: []
         
     |