awesome_form_attributes 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- data.tar.gz: 776b1caaa304e6762cfb7d538fe0132021130ee0
4
- metadata.gz: a69f2eed39b248a8c28a8573d0edafeacd9d56da
5
- SHA512:
6
- data.tar.gz: 19891e150d2bc8ff23e67d2f16a170fc9b32d188f13735634c856e3c50c86db3a84d79e1dda41315ac6bd8df335605009cb1e91f3cd5bd84d50a183b72ca4011
7
- metadata.gz: 543b4320186d9515bcc2e874721a44f5b9ecd30163f7ae63aecdad0ba8c21ba818f00357a8919c1cfb642308db492d3bcc52f2b914495f801a5a6b41df22dbff
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 77ea3b90f59a11a3da94953d14ec25b36cca3e0f
4
+ data.tar.gz: 989217e41491388734106ebe40d0b74066e9f046
5
+ SHA512:
6
+ metadata.gz: 20a544c2a6633f6cd81945b9c4f2a9ea4027e4874b019a05a55c92aa7042d403513e0a350f3a3fcf6e35107eca17431a336208f51d739ace32bd7ea93c3fe7c6
7
+ data.tar.gz: bac97afd0faf1f2cdeb57949199b4ea93da40119d1053ddf97094f8ee98be66e582a59f6d33387b789838950e2323096b9ceb283de96b83240aec8ecf0061ce9
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'awesome_form_attributes'
5
- s.version = '0.0.1'
5
+ s.version = '0.0.2'
6
6
  s.authors = ['Zhimeng Sun']
7
7
  s.email = ['zhimengSun@gmail.com']
8
8
  s.homepage = 'https://github.com/zhimengSun/awesome_form_attributes'
@@ -1,4 +1,6 @@
1
1
  require "rails"
2
+ require "awesome_form_attributes/version"
3
+ require "awesome_form_attributes/setting"
2
4
  require "awesome_form_attributes/helpers"
3
5
  require "awesome_form_attributes/used_attr_columns"
4
6
 
@@ -4,8 +4,12 @@ module ActionView
4
4
  [["是", 1], ["否", 0]]
5
5
  end
6
6
 
7
- def localize_attr(sym, otps = {})
8
- I18n.t("activerecord.attributes.#{controller_name.singularize}.#{sym.to_s}")
7
+ def localize_attr(sym, opts = {})
8
+ klass = controller_name.classify.constantize
9
+ displayed_name = I18n.t("#{klass.displayed_columns_local_path}.#{sym.to_s}")
10
+ basic_name = I18n.t("#{klass.default_local_path}.#{sym.to_s}")
11
+ return displayed_name || basic_name if opts[:display] == true
12
+ basic_name
9
13
  end
10
14
  end
11
15
  end
@@ -3,4 +3,20 @@ class << ActiveRecord::Base
3
3
  end
4
4
  end
5
5
 
6
+ class ActiveRecord::Base
7
+ class << self
8
+ def oname
9
+ self.table_name.singularize
10
+ end
11
+
12
+ def default_local_path(singname = oname)
13
+ "activerecord.attributes.#{singname}"
14
+ end
15
+
16
+ def displayed_columns_local_path(singname = oname)
17
+ "awesome_form_attributes.displayed_columns.#{singname}"
18
+ end
19
+ end
20
+ end
21
+
6
22
 
@@ -3,13 +3,14 @@ module UsedAttrColumns
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  module ClassMethods
6
- end
7
6
 
7
+ end
8
+
8
9
  def used_attrs
9
- I18n.t("activerecord.attributes.#{self.class.table_name.singularize}").keys
10
+ I18n.t(self.class.default_local_path).try(:keys) || []
10
11
  end
11
12
 
12
13
  def short_used_attrs
13
- []
14
+ base_clos = I18n.t(self.class.displayed_columns_local_path).try(:keys) || used_attrs[0, 5]
14
15
  end
15
16
  end
@@ -1,5 +1,5 @@
1
1
  module AwesomeFormAttributes
2
2
  def self.version
3
- "0.0.1"
3
+ "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,37 +1,36 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: awesome_form_attributes
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Zhimeng Sun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2014-11-07 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
15
14
  name: rails
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - &id002
20
- - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
23
20
  type: :runtime
24
- version_requirements: *id001
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  description: Easy way to write attributes for DB based Object in the VIEWS
26
- email:
28
+ email:
27
29
  - zhimengSun@gmail.com
28
30
  executables: []
29
-
30
31
  extensions: []
31
-
32
32
  extra_rdoc_files: []
33
-
34
- files:
33
+ files:
35
34
  - .gitignore
36
35
  - README.md
37
36
  - awesome_form_attributes.gemspec
@@ -42,26 +41,25 @@ files:
42
41
  - lib/awesome_form_attributes/version.rb
43
42
  homepage: https://github.com/zhimengSun/awesome_form_attributes
44
43
  licenses: []
45
-
46
44
  metadata: {}
47
-
48
45
  post_install_message:
49
46
  rdoc_options: []
50
-
51
- require_paths:
47
+ require_paths:
52
48
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
54
- requirements:
55
- - *id002
56
- required_rubygems_version: !ruby/object:Gem::Requirement
57
- requirements:
58
- - *id002
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
59
  requirements: []
60
-
61
60
  rubyforge_project:
62
61
  rubygems_version: 2.4.2
63
62
  signing_key:
64
63
  specification_version: 4
65
64
  summary: Easy way to write attributes for DB based Object
66
65
  test_files: []
67
-