Module: WebifyRuby

Defined in:
lib/webify_ruby.rb,
lib/webify_ruby/css.rb,
lib/webify_ruby/html.rb,
lib/webify_ruby/tasks.rb,
lib/webify_ruby/errors.rb,
lib/webify_ruby/convert.rb,
lib/webify_ruby/railtie.rb,
lib/webify_ruby/version.rb

Overview

Public: Main module that you should be using to use this library. You will be mainly using Convert class that lives here. You can use module’s Css class too if customization is required.

Examples

WebifyRuby::Css.new('name', 'file.ttf', :svg, :woff)
# => #<WebifyRuby::Css:0x007ff9e31dcf60>

Defined Under Namespace

Classes: Convert, Css, Error, Html, Railtie

Constant Summary collapse

EXT =

Internal: File extensions that are allowed to be processed

%w(.ttf .otf)
TEMPLATE =

Internal: Template which is according to what a CSS Styles will be generated. This might change in future versions, so that you will be able to pass in your own template definitions.

<<-CSS.gsub /^\s*/, ''
@font-face {
  font-family: '<%= @name %>';
  <% if has_eot %>src: url('<%= @url %>.eot'); <% end %>
  <% if has_eot %>src: url('<%= @url %>.eot?#iefix') format('embedded-opentype')<%if has_ttf or has_woff or has_svg %>,<%end%><%else%>src:<% end %>
      <% if has_svg %>     url('<%= @url %>.svg#<%= @name %>') format('svg')<%if has_ttf or has_woff %>,<%end%><% end %>
      <% if has_woff %>     url('<%= @url %>.woff') format('woff')<%if has_ttf%>,<%end%><% end %>
      <% if has_ttf %>     url('<%= @url %>.ttf') format('truetype')<% end %>;
  font-weight: normal;
  font-style: normal;
}
CSS
HTML_DOC_DEFAULT =

Internal: HTML template that is used in in generated .html file by default.

<<-HTML.gsub /^\s*/, ''
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title><%=@font_name%> - WebifyRuby</title>
  <link rel="stylesheet" type="text/css" href="<%=@css_file%>">
  <style>
  ::-moz-selection {
    background: #b3d4fc;
    text-shadow: none;
  }

  ::selection {
    background: #b3d4fc;
    text-shadow: none;
  }

  html {
    padding: 30px 10px;
    font-size: 20px;
    line-height: 1.4;
    color: #737373;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
 
    background-color: #fff; 
    background-image: 
    linear-gradient(90deg, transparent 79px, #737373 79px, #737373 81px, transparent 81px),
    linear-gradient(#eee .1em, transparent .1em);
    background-size: 100% 1.2em;
  
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  }

  a:link,a:visited,a:hover,a:active {
    color:inherit; 
    text-decoration:none;
  }

  body {
    max-width: 750px;
    _width: 750px;
    padding: 30px 20px 50px;
    margin: 0 auto;
  }

  h1 {
    margin: 5px 10px;
    font-size: 40px;
    text-align: center;
  }

  h1 span {
    color: #bbb;
  }

  h3 {
    margin: 1.5em 0 0.5em;
  }

  p {
    margin: 0.5em 0;
  }

  ul {
    margin: 1em 0;
    list-style:none;
    font-family:<%=@font_name%>;
    border:1px solid #ccc;
    padding:15px;
    background: #fff;
  }

  ul li {
    display:inline-block;
    height:50px;
    width:50px;;
    text-align:center;
    line-height:50px;
    margin:10px;
    background: #fff;
  }

  .container {
    max-width: 700px;
    _width: 700px;
    margin: 0 auto;
  }

  input::-moz-focus-inner {
    padding: 0;
    border: 0;
  }
  </style>
</head>
<body>
  <a href="https://github.com/dachi-gh/webify_ruby"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://github-camo.global.ssl.fastly.net/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
  
  <div class="container">
    <h1><a href="https://github.com/dachi-gh/webify_ruby">WebifyRuby <span>Gem</span></a></h1>
    <p>
      <strong><%=Time.now%></strong>
    </p>
    <p>
      <strong><%=@font_name%></strong>
    </p>
    <p>The result looks like this:</p>
    <ul>
      <%("a".."z").each do |l|%>
      <li><%=l.upcase%> <%=l%></li>
      <%end%>
    </ul>
    <p>
      <small>Github page: <a href="https://github.com/dachi-gh/webify_ruby">https://github.com/dachi-gh/webify_ruby</a></small>
    </p>
  </div>
</body>
</html>
HTML
VERSION =

Public: WebifyRuby version

"0.1.3"

Class Method Summary collapse

Class Method Details

.html_docObject

Public: You can get a current HTML template that is used by the module.



134
135
136
137
# File 'lib/webify_ruby/html.rb', line 134

def self.html_doc
  return @html_doc if @html_doc
  @html_doc = WebifyRuby::HTML_DOC_DEFAULT
end

.html_doc=(str) ⇒ Object

Public: You can set a custom HTML template by using this method.



129
130
131
# File 'lib/webify_ruby/html.rb', line 129

def self.html_doc=(str)
  @html_doc = str
end

.load_tasksObject

Internal: Loads rake tasks

Returns nothing



5
6
7
# File 'lib/webify_ruby/tasks.rb', line 5

def self.load_tasks
  Dir[File.join(File.dirname(__FILE__),'../tasks/*.rake')].each { |f| load f; }
end

.loggerObject

Internal: Gets a Logger object to use for logging

Returns the Logger object



43
44
45
46
47
48
# File 'lib/webify_ruby.rb', line 43

def self.logger
  return @logger if @logger
  logger = Logger.new(STDOUT)
  logger.level = Logger::INFO
  @logger = logger
end

.logger=(log) ⇒ Object

Public: Set your own logger if wanted

log - The Logger object.

Examples

WebifyRuby::logger = Logger.new(STDOUT)
# => #<Logger:0x007fd740837ec0

Returns the set logger



36
37
38
# File 'lib/webify_ruby.rb', line 36

def self.logger=(log)
  @logger = log
end

.webify_binaryObject

Internal: Gets a String object pointing to the binary

Returns the String of executable



67
68
69
# File 'lib/webify_ruby.rb', line 67

def self.webify_binary
  @webify_binary || 'webify'
end

.webify_binary=(bin) ⇒ Object

Public: Set a correct webify binary path to use

bin - The String object with path to binary file. (default: ‘webify’)

Examples

WebifyRuby::webify_binary = '/usr/bin/webify'
# => "/usr/bin/webify"

Returns the given binary path



60
61
62
# File 'lib/webify_ruby.rb', line 60

def self.webify_binary=(bin)
  @webify_binary = bin
end