i18n-router 0.0.1

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/.Gemfile.swp ADDED
Binary file
data/.Rakefile.swp ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
Binary file
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in i18n-router.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "i18n-router/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "i18n-router"
7
+ s.version = I18nRouter::VERSION
8
+ s.authors = ["Christian Mortaro"]
9
+ s.email = ["mortaro@towsta.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{International routes API for sinatra}
12
+ s.description = %q{Simple multi-routes for sinatra i18n}
13
+
14
+ s.rubyforge_project = "i18n-router"
15
+ s.add_dependency("sinatra-r18n")
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rspec"
24
+ # s.add_runtime_dependency "rest-client"
25
+ end
Binary file
Binary file
Binary file
@@ -0,0 +1,37 @@
1
+ module I18nRouter
2
+
3
+ def i18n_get paths={}, opts={}, &code
4
+ i18n_route 'get', paths, opts, &code
5
+ end
6
+
7
+ def i18n_post paths={}, opts={}, &code
8
+ i18n_route 'post', paths, opts, &code
9
+ end
10
+
11
+ def i18n_delete paths={}, opts={}, &code
12
+ i18n_route 'delete', paths, opts, &code
13
+ end
14
+
15
+ private
16
+
17
+ def i18n_route method, paths, opts, &code
18
+ helper = paths.keys.include?(:helper) ? paths.delete(:helper) : paths.first[1]
19
+ paths.each do |lang, path|
20
+ before path do
21
+ session[:locale] = lang.to_s
22
+ end
23
+ eval 'get path, opts, &code'
24
+ end
25
+ method = "helpers do \n"
26
+ method += " def #{helper.gsub('/','_').gsub('-','_')[1..-1]}_path args={} \n"
27
+ paths.each do |lang, path|
28
+ method += " result = '#{path}' if '#{lang}' == session[:locale] \n"
29
+ end
30
+ method += ' args.each {|key,value| result = result.gsub(":#{key.to_s}",value.to_s)}' + "\n"
31
+ method += " result \n"
32
+ method += " end \n"
33
+ method += "end"
34
+ eval method
35
+ end
36
+
37
+ end
@@ -0,0 +1,3 @@
1
+ module I18nRouter
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ require "i18n-router/version"
2
+ require "i18n-router/router"
3
+
4
+ module I18nRouter
5
+ end
6
+
7
+ include I18nRouter
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n-router
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Christian Mortaro
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-12-13 00:00:00 -02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: sinatra-r18n
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: Simple multi-routes for sinatra i18n
34
+ email:
35
+ - mortaro@towsta.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - .Gemfile.swp
44
+ - .Rakefile.swp
45
+ - .gitignore
46
+ - .i18n-router.gemspec.swp
47
+ - Gemfile
48
+ - Rakefile
49
+ - i18n-router.gemspec
50
+ - lib/.i18n-router.rb.swp
51
+ - lib/i18n-router.rb
52
+ - lib/i18n-router/.router.rb.swp
53
+ - lib/i18n-router/.version.rb.swp
54
+ - lib/i18n-router/router.rb
55
+ - lib/i18n-router/version.rb
56
+ has_rdoc: true
57
+ homepage: ""
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project: i18n-router
84
+ rubygems_version: 1.3.7
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: International routes API for sinatra
88
+ test_files: []
89
+