monglobal 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -8,12 +8,9 @@ First add to your Gemfile
8
8
 
9
9
  Then run bundle install
10
10
 
11
- Then, you need to set up the LANGS. In your environment.rb add this.
11
+ Then, you need to set up the LANGS constant.
12
12
 
13
- LANGS = []
14
- for lang in I18n.available_locales
15
- LANGS << lang.to_sym
16
- end
13
+ rails g monglobal:setup
17
14
 
18
15
 
19
16
  Then in your model:
@@ -50,6 +47,4 @@ Now your controller is pretty much the same with one difference to how you updat
50
47
  The sample app here might help with some of the details of switching the locale and setting up the default locale.
51
48
 
52
49
 
53
- TODO:
54
- Get this set up on the gem repos
55
50
 
data/app/Gemfile CHANGED
@@ -7,7 +7,7 @@ gem 'rails', '3.2.2'
7
7
 
8
8
 
9
9
  gem 'mongo_mapper'
10
- gem 'monglobal'
10
+ gem "monglobal", "~> 0.0.3"
11
11
 
12
12
 
13
13
  # Gems used only for assets and not required
@@ -4,9 +4,5 @@ require File.expand_path('../application', __FILE__)
4
4
  # Initialize the rails application
5
5
  Mongotrans::Application.initialize!
6
6
 
7
- LANGS = []
8
- for lang in I18n.available_locales
9
- LANGS << lang.to_sym
10
- end
11
7
 
12
8
 
@@ -0,0 +1,4 @@
1
+ LANGS = []
2
+ for lang in I18n.available_locales
3
+ LANGS << lang.to_sym
4
+ end
@@ -3,33 +3,9 @@ module Monglobal
3
3
  class SetupGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path("../templates/", __FILE__)
5
5
 
6
- # Commandline options can be defined here using Thor-like options:
7
- argument :model_name
8
-
9
- # all public methods in here will be run in order
10
-
11
- def build_translate_models
12
- template "model.rb", "app/models/#{class_file_name}"
13
- end
14
-
15
-
16
-
17
- protected
18
-
19
- def newklass
20
- klass = model_name.constantize
21
- return klass
22
- end
23
-
24
- def class_name
25
- "#{model_name}Translation"
6
+ def build_initializer
7
+ template "monglobal.rb", "config/initializers/monglobal.rb"
26
8
  end
27
9
 
28
- def class_file_name
29
- #"test"
30
- "#{class_name}.rb"
31
- end
32
-
33
-
34
10
  end
35
11
  end
@@ -1,13 +0,0 @@
1
- class <%= class_name %>
2
-
3
- #This class was generated by Monglobal
4
- #You should think twice before you edit this file
5
-
6
- include MongoMapper::Document
7
- include Monglobal::Translates
8
-
9
- <% newklass.keys.each do |key, val| %><% if val.name != "_id" %>
10
- <%= "key :#{val.name}, #{val.type}" %><% if val.default_value %>, :default => <%= val.default_value %><% end %><% end %><% end %>
11
- key :locale, String
12
-
13
- end
@@ -0,0 +1,4 @@
1
+ LANGS = []
2
+ for lang in I18n.available_locales
3
+ LANGS << lang.to_sym
4
+ end
@@ -1,3 +1,3 @@
1
1
  module Monglobal
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/monglobal.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require "monglobal/version"
2
2
  require 'active_support'
3
3
 
4
+ LANGS = []
5
+ for lang in I18n.available_locales
6
+ LANGS << lang.to_sym
7
+ end
4
8
 
5
9
  module Monglobal
6
10
 
@@ -10,6 +14,7 @@ module Monglobal
10
14
  end
11
15
 
12
16
  def update_translation(locale, params)
17
+
13
18
  if locale == "#{I18n.default_locale}"
14
19
  #just update the main record
15
20
  self.update_attributes(params)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: monglobal
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Wylie Thomas
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-12-31 00:00:00 -07:00
13
+ date: 2013-01-03 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -63,6 +63,7 @@ files:
63
63
  - app/config/initializers/backtrace_silencers.rb
64
64
  - app/config/initializers/inflections.rb
65
65
  - app/config/initializers/mime_types.rb
66
+ - app/config/initializers/monglobal.rb
66
67
  - app/config/initializers/mongo.rb
67
68
  - app/config/initializers/secret_token.rb
68
69
  - app/config/initializers/session_store.rb
@@ -97,6 +98,7 @@ files:
97
98
  - app/vendor/plugins/.gitkeep
98
99
  - lib/generators/monglobal/setup_generator.rb
99
100
  - lib/generators/monglobal/templates/model.rb
101
+ - lib/generators/monglobal/templates/monglobal.rb
100
102
  - lib/generators/monglobal/usage
101
103
  - lib/monglobal.rb
102
104
  - lib/monglobal/version.rb