language_switcher 0.0.0 → 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/.gitignore CHANGED
@@ -17,5 +17,6 @@ tmtags
17
17
  coverage
18
18
  rdoc
19
19
  pkg
20
+ *.gemspec
20
21
 
21
22
  ## PROJECT::SPECIFIC
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Stefano Diem Benatti
1
+ Copyright (c) 2010 Stefano Diem Benatti
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,17 +1,20 @@
1
- = language_switcher
1
+ = Language Switcher
2
2
 
3
- Description goes here.
3
+ This is a gem for Rails to easily change and iterate over languages defined in I18n.available_locales.
4
4
 
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
5
+ == Usage
6
+
7
+ The most useful command should be language_switcher helper,
8
+ which add a div and ul to allow to see an element in several different languages.
9
+
10
+ I also recommend using some tabbing with js, such as Jquery tabs:
11
+ $(document).ready(function(){
12
+ $('[data-tabs]').tabs();
13
+ });
14
+
15
+ language and each_language are also useful methods.
14
16
 
15
17
  == Copyright
18
+ This is a pretty simple plugin, but i started to use the same set of methods in
19
+ several projects and decided to make it a gem.
16
20
 
17
- Copyright (c) 2010 Stefano Diem Benatti. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require 'rubygems'
2
1
  require 'rake'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  begin
5
5
  require 'jeweler'
@@ -12,7 +12,8 @@ begin
12
12
  gem.email = "stefano.diem@gmail.com"
13
13
  gem.homepage = "http://github.com/teonimesic/language_switcher"
14
14
  gem.authors = ["Stefano Diem Benatti"]
15
- gem.add_development_dependency "rspec", ">= 1.2.9"
15
+ gem.add_development_dependency "rspec-core", ">= 2.0.0.beta.13"
16
+ gem.add_dependency 'activerecord', '>= 3.0.0.beta4'
16
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
18
  end
18
19
  Jeweler::GemcutterTasks.new
@@ -20,28 +21,6 @@ rescue LoadError
20
21
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
22
  end
22
23
 
23
- #require 'rspec/core/rake_task'
24
- #RSpec::Core::RakeTask.new(:spec) do |spec|
25
- # spec.libs << 'lib' << 'spec'
26
- # spec.spec_files = FileList['spec/**/*_spec.rb']
27
- #end
28
-
29
- #RSpec::Core::RakeTask.new(:rcov) do |spec|
30
- # spec.libs << 'lib' << 'spec'
31
- # spec.pattern = 'spec/**/*_spec.rb'
32
- # spec.rcov = true
33
- #end
34
-
35
- task :spec => :check_dependencies
36
-
24
+ RSpec::Core::RakeTask.new(:spec)
37
25
  task :default => :spec
38
26
 
39
- require 'rake/rdoctask'
40
- Rake::RDocTask.new do |rdoc|
41
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
-
43
- rdoc.rdoc_dir = 'rdoc'
44
- rdoc.title = "language_switcher #{version}"
45
- rdoc.rdoc_files.include('README*')
46
- rdoc.rdoc_files.include('lib/**/*.rb')
47
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.1.0
@@ -1,7 +1,26 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require_relative 'spec_helper'
2
+
3
+ include LanguageSwitcher
4
+ I18n.available_locales = [:pt, :en]
2
5
 
3
6
  describe "LanguageSwitcher" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
7
+ it "should be able to switch to a language" do
8
+ language(:pt){ I18n.locale.should == :pt }
9
+ language(:en){ I18n.locale.should == :en }
10
+ end
11
+
12
+ it "should not be able to switch to a language unless it is included in I18n.default_locales" do
13
+ lambda { language(:es) }.should raise_error
6
14
  end
15
+
16
+ it "should pass thought each locale in I18n in order" do
17
+ i = 0
18
+ each_language do |l|
19
+ I18n.locale.should == I18n.available_locales[i]
20
+ I18n.locale.should == l
21
+ i+=1
22
+ end
23
+ end
24
+
25
+ # TODO: Add language_switcher view specs
7
26
  end
@@ -1,9 +1,5 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ $:.unshift File.expand_path('../lib', __FILE__)
2
+ require 'active_record'
3
3
  require 'language_switcher'
4
- require 'spec'
5
- require 'spec/autorun'
4
+ require 'rspec'
6
5
 
7
- Spec::Runner.configure do |config|
8
-
9
- end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 0
9
- version: 0.0.0
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Stefano Diem Benatti
@@ -14,11 +14,11 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-10 00:00:00 -03:00
17
+ date: 2010-07-12 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: rspec
21
+ name: rspec-core
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -26,12 +26,30 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
- - 1
30
29
  - 2
31
- - 9
32
- version: 1.2.9
30
+ - 0
31
+ - 0
32
+ - beta
33
+ - 13
34
+ version: 2.0.0.beta.13
33
35
  type: :development
34
36
  version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: activerecord
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ segments:
46
+ - 3
47
+ - 0
48
+ - 0
49
+ - beta4
50
+ version: 3.0.0.beta4
51
+ type: :runtime
52
+ version_requirements: *id002
35
53
  description: |-
36
54
  This gem adds a few methods to switch between locales,
37
55
  and a helper to be used with jquery tabs or some other js tabbing behavior,
@@ -51,10 +69,8 @@ files:
51
69
  - README.rdoc
52
70
  - Rakefile
53
71
  - VERSION
54
- - language_switcher.gemspec
55
72
  - lib/language_switcher.rb
56
73
  - spec/language_switcher_spec.rb
57
- - spec/spec.opts
58
74
  - spec/spec_helper.rb
59
75
  has_rdoc: true
60
76
  homepage: http://github.com/teonimesic/language_switcher
@@ -1,57 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{language_switcher}
8
- s.version = "0.0.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Stefano Diem Benatti"]
12
- s.date = %q{2010-07-10}
13
- s.description = %q{This gem adds a few methods to switch between locales,
14
- and a helper to be used with jquery tabs or some other js tabbing behavior,
15
- to be able to change locales within a view for Rails}
16
- s.email = %q{stefano.diem@gmail.com}
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".gitignore",
24
- "LICENSE",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "language_switcher.gemspec",
29
- "lib/language_switcher.rb",
30
- "spec/language_switcher_spec.rb",
31
- "spec/spec.opts",
32
- "spec/spec_helper.rb"
33
- ]
34
- s.homepage = %q{http://github.com/teonimesic/language_switcher}
35
- s.rdoc_options = ["--charset=UTF-8"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
38
- s.summary = %q{A gem to easily handling switching between I18n locales}
39
- s.test_files = [
40
- "spec/spec_helper.rb",
41
- "spec/language_switcher_spec.rb"
42
- ]
43
-
44
- if s.respond_to? :specification_version then
45
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
- s.specification_version = 3
47
-
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
50
- else
51
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
52
- end
53
- else
54
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
55
- end
56
- end
57
-
@@ -1 +0,0 @@
1
- --color