world-flags 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,20 +1,25 @@
1
1
  module WorldFlagsHelper
2
- def flags_list size, &block
2
+ def self.flag_sizes
3
+ [16, 32]
4
+ end
5
+
6
+ def flags_list size = 16, &block
3
7
  raise "Missing block" unless block_given?
8
+ raise "Supported sizes are only #{WorldFlagsHelper.flag_sizes}" unless WorldFlagsHelper.flag_sizes.include?(size.to_i)
4
9
  content_tag :ul, yield, :class => "f#{size}"
5
10
  end
6
11
 
7
12
  def flags flags_hash
8
- flags_hash.each_pair do |code, name|
9
- flag code, name
10
- end
13
+ flags_hash.inject("") do |res, element|
14
+ res << flag(element.first, element.last)
15
+ end.html_safe
11
16
  end
12
17
 
13
18
  def flag code, name
14
- content_tag :li, name, :class => "flag #{code}"
19
+ content_tag :li, name.html_safe, :class => "flag #{code}"
15
20
  end
16
21
 
17
- def use_flags size
22
+ def use_flags size = 16
18
23
  stylesheet_link_tag "flags#{size}"
19
24
  end
20
25
  end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,47 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
1
+ # coding: utf-8
2
+ require 'rubygems'
3
+ require 'rails'
4
+ require 'json'
5
+ require 'active_support'
6
+ require 'action_pack'
7
+ require 'action_view'
8
+ require 'action_controller'
9
+ require 'action_view/template'
10
+
3
11
  require 'rspec'
4
12
  require 'world-flags'
5
13
 
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
14
+ module ControllerTestHelpers
9
15
 
10
- RSpec.configure do |config|
16
+ def self.included(base)
17
+ base.class_eval do
18
+
19
+ include ActionView::Helpers,
20
+ ActionView::Helpers::CaptureHelper,
21
+ ActionView::Helpers::JavaScriptHelper
22
+
23
+ # allow tabs.create to run by stubbing an output_buffer
24
+ attr_accessor :output_buffer
25
+ @output_buffer = ""
11
26
 
27
+ # stub content_for for testing
28
+ def content_for(name, content = nil, &block)
29
+ # this doesn't exist, and causes errors
30
+ @_content_for = {} unless defined? @_content_for
31
+ # we've got to initialize this, so we can concat to it
32
+ @_content_for[name] = '' if @_content_for[name].nil?
33
+ # now the rest is the same as in rails
34
+ content = capture(&block) if block_given?
35
+ @_content_for[name] << content if content
36
+ @_content_for[name] unless content
37
+ end
38
+
39
+ end
40
+ end
41
+
12
42
  end
43
+
44
+ RSpec.configure do |c|
45
+ # c.filter_run :focus => true
46
+ # c.run_all_when_everything_filtered = true
47
+ end
@@ -1,7 +1,38 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
- describe "WorldFlags" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
3
+ describe WorldFlagsHelper do
4
+ include ControllerTestHelpers,
5
+ WorldFlagsHelper
6
+
7
+ it "should be empty, with an empty block" do
8
+ output = flags_list do
9
+ end
10
+ output.should == "<ul class=\"f16\"></ul>"
11
+ end
12
+
13
+ it "should set size to 16 or 32" do
14
+ lambda do flags_list(8) { }
15
+ end.should raise_error
16
+ end
17
+
18
+ it "should set size to 16 or 32" do
19
+ output = flags_list 32 do
20
+ end
21
+ output.should == "<ul class=\"f32\"></ul>"
22
+ end
23
+
24
+ it "should list flags" do
25
+ output = flags_list 32 do
26
+ flags :ar => 'Argentina', :en => 'England'
27
+ end
28
+ output.should == "<ul class=\"f32\"><li class=\"flag ar\">Argentina</li><li class=\"flag en\">England</li></ul>"
29
+ end
30
+
31
+ it "should list flags combined" do
32
+ output = flags_list 32 do
33
+ [flags(:ar => 'Argentina', :en => 'England'), flag(:br, 'Brazil')].join.html_safe
34
+ end
35
+ output.should == "<ul class=\"f32\"><li class=\"flag ar\">Argentina</li><li class=\"flag en\">England</li><li class=\"flag br\">Brazil</li></ul>"
6
36
  end
7
37
  end
38
+
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "world-flags"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kristian Mandrup"]
12
+ s.date = "2012-03-20"
13
+ s.description = "Use world flag icons in your Rails app"
14
+ s.email = "kmandrup@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.textile"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.textile",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/rails_plugin/engine.rb",
29
+ "lib/world-flags.rb",
30
+ "lib/world_flags/world_flags_helper.rb",
31
+ "spec/spec_helper.rb",
32
+ "spec/world-flags_spec.rb",
33
+ "vendor/assets/images/flags/flags16.png",
34
+ "vendor/assets/images/flags/flags32.png",
35
+ "vendor/assets/stylesheets/flags/flags16.css",
36
+ "vendor/assets/stylesheets/flags/flags16.scss",
37
+ "vendor/assets/stylesheets/flags/flags32.css",
38
+ "vendor/assets/stylesheets/flags/flags32.scss",
39
+ "world-flags.gemspec"
40
+ ]
41
+ s.homepage = "http://github.com/kristianmandrup/world-flags"
42
+ s.licenses = ["MIT"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = "1.8.10"
45
+ s.summary = "World flags as sprites"
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
52
+ s.add_development_dependency(%q<rdoc>, [">= 3.12"])
53
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
54
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.3"])
55
+ s.add_development_dependency(%q<simplecov>, [">= 0.5"])
56
+ else
57
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
58
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
59
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
60
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
61
+ s.add_dependency(%q<simplecov>, [">= 0.5"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
65
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
66
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
68
+ s.add_dependency(%q<simplecov>, [">= 0.5"])
69
+ end
70
+ end
71
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: world-flags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70314142865020 !ruby/object:Gem::Requirement
16
+ requirement: &70365288406560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.8.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70314142865020
24
+ version_requirements: *70365288406560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &70314142873960 !ruby/object:Gem::Requirement
27
+ requirement: &70365288427120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70314142873960
35
+ version_requirements: *70365288427120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70314142871380 !ruby/object:Gem::Requirement
38
+ requirement: &70365288425660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70314142871380
46
+ version_requirements: *70365288425660
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70314142884620 !ruby/object:Gem::Requirement
49
+ requirement: &70365288423940 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.8.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70314142884620
57
+ version_requirements: *70365288423940
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &70314142881140 !ruby/object:Gem::Requirement
60
+ requirement: &70365288421960 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0.5'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70314142881140
68
+ version_requirements: *70365288421960
69
69
  description: Use world flag icons in your Rails app
70
70
  email: kmandrup@gmail.com
71
71
  executables: []
@@ -93,6 +93,7 @@ files:
93
93
  - vendor/assets/stylesheets/flags/flags16.scss
94
94
  - vendor/assets/stylesheets/flags/flags32.css
95
95
  - vendor/assets/stylesheets/flags/flags32.scss
96
+ - world-flags.gemspec
96
97
  homepage: http://github.com/kristianmandrup/world-flags
97
98
  licenses:
98
99
  - MIT
@@ -108,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
109
  version: '0'
109
110
  segments:
110
111
  - 0
111
- hash: -2540679231362697712
112
+ hash: -4338299657571122949
112
113
  required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  none: false
114
115
  requirements: