world-flags 0.1.3 → 0.1.4

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.3
1
+ 0.1.4
data/lib/world-flags.rb CHANGED
@@ -1,6 +1,5 @@
1
- require "world_flags/world_flags_helper"
1
+ require "world_flags/view_helper"
2
2
  require "world_flags/locale_helper"
3
3
  require "rails"
4
- require 'world_flags/rails_plugin/engine'
4
+ require 'world_flags/rails/engine'
5
5
 
6
- ActionView::Base.send :include, WorldFlagsHelper
@@ -0,0 +1,19 @@
1
+ module WorldFlags
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+
5
+ initializer "setup for rails" do
6
+ puts "WorldFlags engine loaded"
7
+ WorldFlags::Rails::Engine.add_view_ext
8
+ end
9
+
10
+ def self.add_view_ext
11
+ ActionView::Base.send :include, WorldFlagsHelper
12
+ end
13
+
14
+ def self.add_controller_ext
15
+ # ActionController::Base.send(:include, UiControllerExtensions)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,41 @@
1
+ module WorldFlags
2
+ module ViewHelper
3
+ def self.flag_sizes
4
+ [16, 32, 64]
5
+ end
6
+
7
+ def flags_list size = 16, &block
8
+ raise "Missing block" unless block_given?
9
+ raise "Supported sizes are only #{WorldFlagsHelper.flag_sizes}" unless WorldFlagsHelper.flag_sizes.include?(size.to_i)
10
+ content = capture(&block)
11
+ content_tag :ul, content, :class => "f#{size}"
12
+ end
13
+ alias_method :flag_list, :flags_list
14
+
15
+ def flags flags_hash, display = false
16
+ flags_hash.inject("") do |res, element|
17
+ res << flag(element.first, element.last, display)
18
+ end.html_safe
19
+ end
20
+
21
+ def flags_title flags_hash
22
+ flags_hash.inject("") do |res, element|
23
+ res << flag_title(element.first, element.last)
24
+ end.html_safe
25
+ end
26
+
27
+ def flag code, name, display = false
28
+ label = display ? name : '&nbsp;'
29
+ content_tag :li, label.html_safe, :class => "flag #{code}", :'data-country' => name, :'data-cc' => code
30
+ end
31
+
32
+ def flag_title code, name, display = false
33
+ label = display ? name : '&nbsp;'
34
+ content_tag :li, label.html_safe, :class => "flag #{code}", :title => name, :'data-cc' => code
35
+ end
36
+
37
+ def use_flags size = 16
38
+ stylesheet_link_tag "flags/flags#{size}"
39
+ end
40
+ end
41
+ end
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,8 @@ require 'action_view/template'
11
11
  require 'rspec'
12
12
  require 'world-flags'
13
13
 
14
+ # WorldFlags::Rails::Engine.add_view_ext
15
+
14
16
  module ControllerTestHelpers
15
17
 
16
18
  def self.included(base)
@@ -0,0 +1 @@
1
+ # TODO
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe WorldFlagsHelper do
3
+ describe WorldFlags::ViewHelper do
4
4
  include ControllerTestHelpers,
5
- WorldFlagsHelper
5
+ WorldFlags::ViewHelper
6
6
 
7
7
  it "should be empty, with an empty block" do
8
8
  output = flags_list do
data/world-flags.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "world-flags"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
@@ -27,10 +27,11 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "lib/world-flags.rb",
29
29
  "lib/world_flags/locale_helper.rb",
30
- "lib/world_flags/rails_plugin/engine.rb",
31
- "lib/world_flags/world_flags_helper.rb",
30
+ "lib/world_flags/rails/engine.rb",
31
+ "lib/world_flags/view_helper.rb",
32
32
  "spec/spec_helper.rb",
33
- "spec/world-flags_spec.rb",
33
+ "spec/world_flags/locale_helper_spec.rb",
34
+ "spec/world_flags/view_helper_spec.rb",
34
35
  "vendor/assets/images/flags/flags16.png",
35
36
  "vendor/assets/images/flags/flags16_semi.png",
36
37
  "vendor/assets/images/flags/flags32.png",
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.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70328223440720 !ruby/object:Gem::Requirement
16
+ requirement: &70338380156160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70328223440720
24
+ version_requirements: *70338380156160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70328223454620 !ruby/object:Gem::Requirement
27
+ requirement: &70338380155620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70328223454620
35
+ version_requirements: *70338380155620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdoc
38
- requirement: &70328223453240 !ruby/object:Gem::Requirement
38
+ requirement: &70338380155120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.12'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70328223453240
46
+ version_requirements: *70338380155120
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70328223451300 !ruby/object:Gem::Requirement
49
+ requirement: &70338380154620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70328223451300
57
+ version_requirements: *70338380154620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70328223464260 !ruby/object:Gem::Requirement
60
+ requirement: &70338380154060 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.8.3
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70328223464260
68
+ version_requirements: *70338380154060
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &70328223461500 !ruby/object:Gem::Requirement
71
+ requirement: &70338380153520 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0.5'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70328223461500
79
+ version_requirements: *70338380153520
80
80
  description: Use world flag icons in your Rails app
81
81
  email: kmandrup@gmail.com
82
82
  executables: []
@@ -95,10 +95,11 @@ files:
95
95
  - VERSION
96
96
  - lib/world-flags.rb
97
97
  - lib/world_flags/locale_helper.rb
98
- - lib/world_flags/rails_plugin/engine.rb
99
- - lib/world_flags/world_flags_helper.rb
98
+ - lib/world_flags/rails/engine.rb
99
+ - lib/world_flags/view_helper.rb
100
100
  - spec/spec_helper.rb
101
- - spec/world-flags_spec.rb
101
+ - spec/world_flags/locale_helper_spec.rb
102
+ - spec/world_flags/view_helper_spec.rb
102
103
  - vendor/assets/images/flags/flags16.png
103
104
  - vendor/assets/images/flags/flags16_semi.png
104
105
  - vendor/assets/images/flags/flags32.png
@@ -131,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
132
  version: '0'
132
133
  segments:
133
134
  - 0
134
- hash: 690155774062235835
135
+ hash: -2167813305194718238
135
136
  required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  none: false
137
138
  requirements:
@@ -1,7 +0,0 @@
1
- module WorldFlags
2
- module Rails
3
- class Engine < ::Rails::Engine
4
- puts "WorldFlags engine loaded"
5
- end
6
- end
7
- end
@@ -1,39 +0,0 @@
1
- module WorldFlagsHelper
2
- def self.flag_sizes
3
- [16, 32, 64]
4
- end
5
-
6
- def flags_list size = 16, &block
7
- raise "Missing block" unless block_given?
8
- raise "Supported sizes are only #{WorldFlagsHelper.flag_sizes}" unless WorldFlagsHelper.flag_sizes.include?(size.to_i)
9
- content = capture(&block)
10
- content_tag :ul, content, :class => "f#{size}"
11
- end
12
- alias_method :flag_list, :flags_list
13
-
14
- def flags flags_hash, display = false
15
- flags_hash.inject("") do |res, element|
16
- res << flag(element.first, element.last, display)
17
- end.html_safe
18
- end
19
-
20
- def flags_title flags_hash
21
- flags_hash.inject("") do |res, element|
22
- res << flag_title(element.first, element.last)
23
- end.html_safe
24
- end
25
-
26
- def flag code, name, display = false
27
- label = display ? name : '&nbsp;'
28
- content_tag :li, label.html_safe, :class => "flag #{code}", :'data-country' => name, :'data-cc' => code
29
- end
30
-
31
- def flag_title code, name, display = false
32
- label = display ? name : '&nbsp;'
33
- content_tag :li, label.html_safe, :class => "flag #{code}", :title => name, :'data-cc' => code
34
- end
35
-
36
- def use_flags size = 16
37
- stylesheet_link_tag "flags/flags#{size}"
38
- end
39
- end