Module: Iconoclast
- Defined in:
- lib/iconoclast.rb,
lib/iconoclast/icon_helper.rb
Defined Under Namespace
Modules: ControllerMixin, IconHelper
Constant Summary collapse
- LIBPATH =
:stopdoc:
::File.(::File.dirname(__FILE__)) + ::File::SEPARATOR
- PATH =
::File.dirname(LIBPATH) + ::File::SEPARATOR
- VERSION =
File.open(File.join(LIBPATH, '..', 'VERSION')).gets
Class Method Summary collapse
- .icon_names(opts = {}) ⇒ Object
- .icons(opts = {}) ⇒ Object
-
.install_icons(dest_dir, opts = {}) ⇒ Object
Installs the specified icon set into the specified directory.
-
.libpath(*args) ⇒ Object
Returns the library path for the module.
-
.path(*args) ⇒ Object
Returns the path for the module.
- .remove_icons(dest_dir, opts = {}) ⇒ Object
-
.require_all_libs_relative_to(fname, dir = nil) ⇒ Object
Utility method used to require all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in.
-
.version ⇒ Object
Returns the version string for the library.
Class Method Details
.icon_names(opts = {}) ⇒ Object
72 73 74 75 |
# File 'lib/iconoclast.rb', line 72 def self.icon_names ( opts = {} ) icons = self.icons(opts) icons.collect!{|icon| File.basename(icon)} end |
.icons(opts = {}) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/iconoclast.rb', line 64 def self.icons ( opts = {} ) opts[:provider] ||= 'famfamfam' opts[:set] ||= 'silk' opts[:format] ||= 'png' globpath = ::File.join(libpath, 'iconoclast/icons', opts[:provider], opts[:set], opts[:format], '*') Dir[globpath] end |
.install_icons(dest_dir, opts = {}) ⇒ Object
Installs the specified icon set into the specified directory
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/iconoclast.rb', line 35 def self.install_icons( dest_dir, opts = {} ) opts[:provider] ||= 'famfamfam' opts[:set] ||= 'silk' opts[:format] ||= 'png' action_dir = File.join(dest_dir, 'icons', opts[:provider], opts[:set], opts[:format]) puts "=="*45 puts "making dir #{action_dir}" unless File.exists? action_dir puts "copying icons to #{action_dir}" puts "=="*45 FileUtils.mkdir_p action_dir unless File.exists? action_dir FileUtils.cp(Iconoclast.icons(opts), action_dir) end |
.libpath(*args) ⇒ Object
Returns the library path for the module. If any arguments are given, they will be joined to the end of the library path using File.join
.
81 82 83 |
# File 'lib/iconoclast.rb', line 81 def self.libpath( *args ) args.empty? ? LIBPATH : ::File.join(LIBPATH, *args) end |
.path(*args) ⇒ Object
Returns the path for the module. If any arguments are given, they will be joined to the end of the path using File.join
.
89 90 91 |
# File 'lib/iconoclast.rb', line 89 def self.path( *args ) args.empty? ? PATH : ::File.join(PATH, *args) end |
.remove_icons(dest_dir, opts = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/iconoclast.rb', line 49 def self.remove_icons( dest_dir, opts = {} ) opts[:provider] ||= 'famfamfam' opts[:set] ||= 'silk' opts[:format] ||= 'png' action_dir = File.join(dest_dir, 'icons', opts[:provider], opts[:set], opts[:format]) puts "=="*45 puts "removing icons from #{action_dir}" puts "=="*45 icons = icon_names(opts) icons.collect!{|icon| action_dir + "/" + icon} FileUtils.rm(icons) # TODO: remove any empty directories in the structure end |
.require_all_libs_relative_to(fname, dir = nil) ⇒ Object
Utility method used to require all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in. Optionally, a specific directory name can be passed in such that the filename does not have to be equivalent to the directory.
99 100 101 102 103 104 105 |
# File 'lib/iconoclast.rb', line 99 def self.require_all_libs_relative_to( fname, dir = nil ) dir ||= ::File.basename(fname, '.*') search_me = ::File.( ::File.join(::File.dirname(fname), dir, '**', '*.rb')) Dir.glob(search_me).sort.each {|rb| require rb} end |
.version ⇒ Object
Returns the version string for the library.
30 31 32 |
# File 'lib/iconoclast.rb', line 30 def self.version VERSION end |