iconoclast 0.0.1 → 0.1.0

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.
data/README.rdoc CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  Description goes here.
4
4
 
5
- Call like this:
6
- <%= IconHelper.icon 'key' %>
7
- http://robots.thoughtbot.com/post/159808152/disambiguate-rails-helpers
5
+ In application_controller.rb:
6
+ helper Iconoclast::IconHelper
7
+
8
+ In your views:
9
+ <%= icon 'name' %>
10
+ <%= icon 'name', 'alt text' %>
11
+ <%= icon 'name', 'alt text', { :border => 1 } %>
8
12
 
9
13
  == Note on Patches/Pull Requests
10
14
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ $:.unshift(File.dirname(__FILE__) + "/lib")
2
+
1
3
  require 'rubygems'
2
4
  require 'rake'
3
5
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
data/bin/iconify CHANGED
@@ -12,19 +12,19 @@ Main do
12
12
  EOS
13
13
 
14
14
  examples <<-EOS
15
- To add famfamfam icons to your app
15
+ To add icons to your app
16
16
 
17
17
  cd /your/rails/app/dir
18
18
 
19
- famify #copies icons to public/images
19
+ iconify #copies icons to public/images
20
20
 
21
- famify my_images/icons #copies icons to /your/rails/apps/dir/myimages/icons
21
+ iconify my_images/icons #copies icons to /your/rails/apps/dir/myimages/icons
22
22
 
23
- To remove famfamfam icons from your app (and only famfamfam icons)
23
+ To remove icons from your app (and only famfamfam icons)
24
24
 
25
- famify remove #removes only famfamfam icons from public/images
25
+ iconify remove #removes only famfamfam icons from public/images
26
26
 
27
- famify remove my_images/icons #removes only famfamfam icons from /your/rails/apps/dir/myimages/icons
27
+ iconify remove my_images/icons #removes only famfamfam icons from /your/rails/apps/dir/myimages/icons
28
28
 
29
29
  EOS
30
30
 
@@ -35,27 +35,58 @@ Main do
35
35
  default File.expand_path("." + "/public/images")
36
36
  end
37
37
  end
38
+
39
+ mixin :collection_option do
40
+ option "collection" do
41
+ argument_optional
42
+ attribute
43
+ default 'famfamfam'
44
+ end
45
+ end
46
+
47
+ mixin :set_option do
48
+ option "set" do
49
+ argument_optional
50
+ attribute
51
+ default 'silk'
52
+ end
53
+ end
54
+
55
+ mixin :format_option do
56
+ option "format" do
57
+ argument_optional
58
+ attribute
59
+ default 'png'
60
+ end
61
+ end
38
62
 
39
63
  mode "remove" do
40
64
  mixin :path_argument
65
+ mixin :collection_option
66
+ mixin :set_option
67
+ mixin :format_option
41
68
  run do
42
- Iconoclast.remove_icons path
69
+ Iconoclast.remove_icons path, {:collection => collection, :set => set, :format => format}
43
70
  end
44
71
  end
45
72
 
46
73
  mode "refresh" do
47
74
  mixin :path_argument
75
+ mixin :collection_option
76
+ mixin :set_option
77
+ mixin :format_option
48
78
  run do
49
- Iconoclast.remove_icons path
50
- Iconoclast.copy_icons path
79
+ Iconoclast.remove_icons path, {:collection => collection, :set => set, :format => format}
80
+ Iconoclast.install_icons path, {:collection => collection, :set => set, :format => format}
51
81
  end
52
82
  end
53
83
 
54
84
  mixin :path_argument
85
+ mixin :collection_option
86
+ mixin :set_option
87
+ mixin :format_option
55
88
 
56
89
  run do
57
- Iconoclast.copy_icons path
90
+ Iconoclast.install_icons path, {:collection => collection, :set => set, :format => format}
58
91
  end
59
92
  end
60
-
61
- end
@@ -5,4 +5,4 @@ Feature: Version
5
5
 
6
6
  Scenario: Get application version
7
7
  When I call the Iconoclast version method
8
- Then the result should be 0.0.1
8
+ Then the result should be 0.1.0
data/iconoclast.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{iconoclast}
8
- s.version = "0.0.1"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Eric Dennis"]
12
- s.date = %q{2009-11-29}
12
+ s.date = %q{2009-12-17}
13
13
  s.description = %q{Rails icon library and helpers}
14
14
  s.email = %q{e@wb.com}
15
15
  s.executables = ["iconify", "test.rb"]
@@ -1530,7 +1530,10 @@ Gem::Specification.new do |s|
1530
1530
  "lib/tasks/cucumber.rake",
1531
1531
  "rails/init.rb",
1532
1532
  "tasks/iconoclast.rake",
1533
- "test/helper.rb",
1533
+ "test/fixtures/content/icon.html.erb",
1534
+ "test/fixtures/layouts/iconoclast.html.erb",
1535
+ "test/test_helper.rb",
1536
+ "test/test_icon_helper.rb",
1534
1537
  "test/test_iconoclast.rb"
1535
1538
  ]
1536
1539
  s.homepage = %q{http://github.com/threetee/iconoclast}
@@ -1539,7 +1542,8 @@ Gem::Specification.new do |s|
1539
1542
  s.rubygems_version = %q{1.3.5}
1540
1543
  s.summary = %q{Rails icon library and helpers}
1541
1544
  s.test_files = [
1542
- "test/helper.rb",
1545
+ "test/test_helper.rb",
1546
+ "test/test_icon_helper.rb",
1543
1547
  "test/test_iconoclast.rb"
1544
1548
  ]
1545
1549
 
@@ -8,14 +8,24 @@ module Iconoclast
8
8
  # <%= icon :information, "Information icon", :border => 0 %>
9
9
  # will generate:
10
10
  # <img src="../icons/information.png" alt="Information icon" border="0" />
11
- def self.icon(name, alt = nil, opts = {})
11
+ def icon(name, alt = nil, opts = {})
12
+ # Set up some defaults
13
+ collection = 'famfamfam'
14
+ family = 'silk'
15
+ format = 'png'
16
+
17
+ # Replace the defaults if specified
18
+ ['collection', 'family', 'format'].each do |var|
19
+ eval("#{var} = opts[:#{var}] unless opts[:#{var}].nil?")
20
+ eval("opts.delete #{var}")
21
+ end
22
+
12
23
  opts[:border] ||= 0
13
24
  opts[:align] ||= "bottom"
14
25
  opts[:alt] ||= alt
15
26
 
16
- image_tag "../icons/#{name}.png", opts
27
+ image_tag "icons/#{collection}/#{family}/#{format}/#{name}.png", opts
17
28
  end
18
-
19
29
  end
20
30
 
21
31
  end
data/lib/iconoclast.rb CHANGED
@@ -16,6 +16,7 @@ unless defined? Iconoclast
16
16
  case arg
17
17
  when String, Symbol
18
18
  file_name = 'iconoclast/' + arg.to_s.underscore
19
+ print "setting up helper for file_name = #{file_name}"
19
20
  helper(file_name)
20
21
  else
21
22
  helper(arg, &block)
@@ -31,18 +32,46 @@ unless defined? Iconoclast
31
32
  VERSION
32
33
  end
33
34
 
34
- def self.icons ( options = {} )
35
- options[:provider] ||= 'famfamfam'
36
- options[:set] ||= 'silk'
37
- options[:format] ||= 'png'
38
- # print options.inspect
39
- globpath = ::File.join(libpath, 'iconoclast/icons', options[:provider], options[:set], options[:format], '*')
40
- # print "#{globpath}\n"
35
+ # Installs the specified icon set into the specified directory
36
+ def self.install_icons( dest_dir, opts = {} )
37
+ opts[:provider] ||= 'famfamfam'
38
+ opts[:set] ||= 'silk'
39
+ opts[:format] ||= 'png'
40
+
41
+ action_dir = File.join(dest_dir, 'icons', opts[:provider], opts[:set], opts[:format])
42
+ puts "=="*45
43
+ puts "making dir #{action_dir}" unless File.exists? action_dir
44
+ puts "copying icons to #{action_dir}"
45
+ puts "=="*45
46
+ FileUtils.mkdir_p action_dir unless File.exists? action_dir
47
+ FileUtils.cp(Iconoclast.icons(opts), action_dir)
48
+ end
49
+
50
+ def self.remove_icons( dest_dir, opts = {} )
51
+ opts[:provider] ||= 'famfamfam'
52
+ opts[:set] ||= 'silk'
53
+ opts[:format] ||= 'png'
54
+
55
+ action_dir = File.join(dest_dir, 'icons', opts[:provider], opts[:set], opts[:format])
56
+ puts "=="*45
57
+ puts "removing icons from #{action_dir}"
58
+ puts "=="*45
59
+ icons = icon_names(opts)
60
+ icons.collect!{|icon| action_dir + "/" + icon}
61
+ FileUtils.rm(icons)
62
+ # TODO: remove any empty directories in the structure
63
+ end
64
+
65
+ def self.icons ( opts = {} )
66
+ opts[:provider] ||= 'famfamfam'
67
+ opts[:set] ||= 'silk'
68
+ opts[:format] ||= 'png'
69
+ globpath = ::File.join(libpath, 'iconoclast/icons', opts[:provider], opts[:set], opts[:format], '*')
41
70
  Dir[globpath]
42
71
  end
43
72
 
44
- def self.icon_names ( options = {} )
45
- icons = self.icons(options)
73
+ def self.icon_names ( opts = {} )
74
+ icons = self.icons(opts)
46
75
  icons.collect!{|icon| File.basename(icon)}
47
76
  end
48
77
 
@@ -0,0 +1 @@
1
+ <%= icon('zoom') %>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -22,7 +22,7 @@ ActionController::Routing::Routes.reload rescue nil
22
22
 
23
23
  #$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
24
24
  #$LOAD_PATH.unshift(File.dirname(__FILE__))
25
- require 'iconoclast'
25
+ #require 'iconoclast'
26
26
 
27
- class Test::Unit::TestCase
28
- end
27
+ #class Test::Unit::TestCase
28
+ #end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+ require 'iconoclast'
3
+
4
+ class IconHelperTest < ActionView::TestCase
5
+ context "The iconoclast view helper" do
6
+ tests Iconoclast::IconHelper
7
+
8
+ setup do
9
+ IconTag = {
10
+ %(icon('zoom')) => %(<img align="bottom" alt="Zoom" border="0" src="/images/icons/famfamfam/silk/png/zoom.png" />),
11
+ %(icon('zoom', 'alttext')) => %(<img align="bottom" alt="alttext" border="0" src="/images/icons/famfamfam/silk/png/zoom.png" />),
12
+ %(icon('zoom', 'alttext', { :border => 1 })) => %(<img align="bottom" alt="alttext" border="1" src="/images/icons/famfamfam/silk/png/zoom.png" />),
13
+ }
14
+ end
15
+
16
+ should "return the proper HTML" do
17
+ IconTag.each do |method, tag|
18
+ assert_dom_equal(tag, eval(method))
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'test_helper'
2
2
 
3
3
  class TestIconoclast < Test::Unit::TestCase
4
4
  # Tests:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iconoclast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dennis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-29 00:00:00 -08:00
12
+ date: 2009-12-17 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -1565,7 +1565,10 @@ files:
1565
1565
  - lib/tasks/cucumber.rake
1566
1566
  - rails/init.rb
1567
1567
  - tasks/iconoclast.rake
1568
- - test/helper.rb
1568
+ - test/fixtures/content/icon.html.erb
1569
+ - test/fixtures/layouts/iconoclast.html.erb
1570
+ - test/test_helper.rb
1571
+ - test/test_icon_helper.rb
1569
1572
  - test/test_iconoclast.rb
1570
1573
  has_rdoc: true
1571
1574
  homepage: http://github.com/threetee/iconoclast
@@ -1596,5 +1599,6 @@ signing_key:
1596
1599
  specification_version: 3
1597
1600
  summary: Rails icon library and helpers
1598
1601
  test_files:
1599
- - test/helper.rb
1602
+ - test/test_helper.rb
1603
+ - test/test_icon_helper.rb
1600
1604
  - test/test_iconoclast.rb