time_wrapper 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5905e9ffebb39684dbabb6f6d47eb7b7819f3961
4
- data.tar.gz: 340a0082a7cb53437aac82104289a9514cf19c2d
3
+ metadata.gz: cd0f4e500679f51a1675806f08b22beb3bcaed4d
4
+ data.tar.gz: 777554b442955594d7b87c6c9650f9b380cf3775
5
5
  SHA512:
6
- metadata.gz: 9314b2ad7909c2ef8e1cd6b3460ddb38b13c01b618224ac8272aba3e23fd4f98d95ecdb4f63f6a335eddbdd139ae72d3fadeecb93c5a39316f63150e87e7b661
7
- data.tar.gz: 4d47af8a5abf1aa3be86da665ef506277683133b5ef8a2c75f57384206886433cce3b3548811bc5e3766042be8f7dbd0cb727697765062ccf0d3dd0fffa97604
6
+ metadata.gz: b96801d84744f866f6f7558866f4dfef9717448a4dc3fd8c991315403ba66fea00819d0db8d50ebf375da18d4b3286bd7cfb4bcdd2c3d0e3a159eda3e78e1b2e
7
+ data.tar.gz: 3024e38c32caa38fde8eb063eda7137a3b99b573ea8c185ca87386628151af83ff8bfb3e19ec3a80a4fcca913c23592195d8262bc0259823a21d3aa02df52c9a
data/README.md CHANGED
@@ -48,6 +48,12 @@ Given a datetime field named `time` use the following in simple form:
48
48
  <%= f.input :time, as: :string, wrapper: :time %>
49
49
  ```
50
50
 
51
+ To get proper setter and getters, as well as basic format validation (you probably want to add your own) use the following in you model:
52
+
53
+ ```ruby
54
+ time_attribute :time
55
+ ```
56
+
51
57
  ## Generate stylesheets
52
58
 
53
59
  If you want to customize the stylesheets.
@@ -1,33 +1,14 @@
1
1
  require "time_wrapper/version"
2
2
 
3
3
  require "time_wrapper/orm/active_record"
4
+ require "time_wrapper/locale/locale"
5
+ require "time_wrapper/simple_form_wrapper"
4
6
 
5
7
  module TimeWrapper
6
8
  module Rails
7
9
  class Engine < ::Rails::Engine
8
- initializer 'time_wrapper.setup_simple_form' do
9
- ::SimpleForm.setup do |config|
10
- config.wrappers :time, tag: 'div', class: 'form-group', error_class: 'has-danger' do |b|
11
- b.use :html5
12
- b.use :placeholder
13
- b.use :label, class: 'form-control-label'
14
- b.wrapper tag: 'div', class: 'input-group time timepicker' do |input|
15
- input.use :input, class: 'form-control', autocomplete: :off
16
- input.wrapper tag: 'span', class: 'input-group-addon' do |addon|
17
- addon.wrapper tag: 'i', class: "fa fa-clock-o" do |_|
18
- end
19
- end
20
- end
21
- b.use :error, wrap_with: { tag: 'small', class: 'text-help text-muted' }
22
- b.use :hint, wrap_with: { tag: 'p', class: 'text-help text-muted' }
23
- end
24
- end
25
- end
10
+
26
11
  end
27
12
  end
28
13
  end
29
14
 
30
- ActiveSupport.on_load(:i18n) do
31
- I18n.load_path << "#{File.dirname(__FILE__)}/time_wrapper/locale/en.yml"
32
- I18n.load_path << "#{File.dirname(__FILE__)}/time_wrapper/locale/da.yml"
33
- end
@@ -0,0 +1,4 @@
1
+ ActiveSupport.on_load(:i18n) do
2
+ I18n.load_path << "#{File.dirname(__FILE__)}/time_wrapper/locale/en.yml"
3
+ I18n.load_path << "#{File.dirname(__FILE__)}/time_wrapper/locale/da.yml"
4
+ end
@@ -0,0 +1,16 @@
1
+ ::SimpleForm.setup do |config|
2
+ config.wrappers :time, tag: 'div', class: 'form-group', error_class: 'has-danger' do |b|
3
+ b.use :html5
4
+ b.use :placeholder
5
+ b.use :label, class: 'form-control-label'
6
+ b.wrapper tag: 'div', class: 'input-group time timepicker' do |input|
7
+ input.use :input, class: 'form-control', autocomplete: :off
8
+ input.wrapper tag: 'span', class: 'input-group-addon' do |addon|
9
+ addon.wrapper tag: 'i', class: "fa fa-clock-o" do |_|
10
+ end
11
+ end
12
+ end
13
+ b.use :error, wrap_with: { tag: 'small', class: 'text-help text-muted' }
14
+ b.use :hint, wrap_with: { tag: 'p', class: 'text-help text-muted' }
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module TimeWrapper
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thies Pierdola
@@ -146,7 +146,9 @@ files:
146
146
  - lib/time_wrapper.rb
147
147
  - lib/time_wrapper/locale/da.yml
148
148
  - lib/time_wrapper/locale/en.yml
149
+ - lib/time_wrapper/locale/locale.rb
149
150
  - lib/time_wrapper/orm/active_record.rb
151
+ - lib/time_wrapper/simple_form_wrapper.rb
150
152
  - lib/time_wrapper/time_attribute.rb
151
153
  - lib/time_wrapper/version.rb
152
154
  - time_wrapper.gemspec