norwegian-county-select 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 ADDED
@@ -0,0 +1,14 @@
1
+ Norwegian County Select
2
+ =============
3
+
4
+ Helper for Rails to list Norwegian Counties in a select.
5
+ Pretty much a modified copy of the country_select plugin for rails.
6
+
7
+
8
+ Example
9
+ =======
10
+
11
+ norwegian_county_select("user", "norwegian_county_name")
12
+
13
+
14
+ Copyright (c) 2009 Amund Sivertsen, under the WTFPL.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar
5
+ 14 rue de Plaisance, 75014 Paris, France
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'norwegian_county_select'
@@ -0,0 +1,40 @@
1
+ # NorwegianCountySelect
2
+ module ActionView
3
+ module Helpers
4
+ module FormOptionsHelper
5
+ # Return select and option tags for the given object and method, using norwegian_county_options_for_select to generate the list of option tags.
6
+ def norwegian_county_select(object, method, options = {}, html_options = {})
7
+ InstanceTag.new(object, method, self, options.delete(:object)).to_norwegian_county_select_tag(options, html_options)
8
+ end
9
+ # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
10
+ def norwegian_county_options_for_select(selected = nil)
11
+ norwegian_county_options = ""
12
+ return norwegian_county_options + options_for_select(NORWEGIAN_COUNTIES, selected)
13
+ end
14
+ # All the counties included in the norwegian_county_options output.
15
+ NORWEGIAN_COUNTIES = ["Akershus", "Aust-Agder", "Buskerud", "Finnmark", "Hedmark", "Hordalan", "Møre og Romsdal",
16
+ "Nord-Trøndelag", "Nordland", "Oppland", "Oslo", "Rogaland", "Sogn og Fjordane", "Sør-Trøndelag", "Telemark",
17
+ "Troms", "Vest-Agder", "Vestfold", "Østfold"] unless const_defined?("NORWEGIAN_COUNTIES")
18
+ end
19
+
20
+ class InstanceTag
21
+ def to_norwegian_county_select_tag(options, html_options)
22
+ html_options = html_options.stringify_keys
23
+ add_default_name_and_id(html_options)
24
+ value = value(object)
25
+ content_tag("select",
26
+ add_options(
27
+ norwegian_county_options_for_select(value),
28
+ options, value
29
+ ), html_options
30
+ )
31
+ end
32
+ end
33
+
34
+ class FormBuilder
35
+ def norwegian_county_select(method, options = {}, html_options = {})
36
+ @template.norwegian_county_select(@object_name, method, options.merge(:object => @object), html_options)
37
+ end
38
+ end
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: norwegian-county-select
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Amund Sivertsen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-28 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Rails select helper for Norwegian Counties
17
+ email: amunds@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ files:
25
+ - README
26
+ - VERSION
27
+ - WTFPL-LICENSE
28
+ - init.rb
29
+ - lib/norwegian_county_select.rb
30
+ has_rdoc: true
31
+ homepage: http://github.com/Amunds/Norwegian-County-Select
32
+ licenses: []
33
+
34
+ post_install_message:
35
+ rdoc_options:
36
+ - --charset=UTF-8
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.3.5
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Rails select helper for Norwegian Counties
58
+ test_files: []
59
+