administrate-field-time 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ebab1b5623db677d1e4f436c3d19e8d76b5b03d3
4
+ data.tar.gz: f6023469b64835bb1d65654674bcb16855d9052e
5
+ SHA512:
6
+ metadata.gz: aaa9e9939a6d4030d8a9f3cbadd8c6fc9f3e9a457019796c2596e670fa7c0dabe0dea1c8dafe3e2a574cb8520b6e5decec7ab9dbb2f8df259b078abf797d2f6c
7
+ data.tar.gz: 451c369446352e67ab91b42963b13b0380095d3d93b258ad78140aa689aee191c33304ae8eb8aeaad84ea53f6f0e90450de1b002a812a5d62edfc3d8fddbb995
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rspec-rails', '~> 3.5.0'
7
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 DisruptiveAngels
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Administrate::Field::Time
2
+
3
+ A plugin to show time attributes in [Administrate].
4
+
5
+ This repository is the first field plugin extracted out of Administrate.
6
+ Although its structure may change,
7
+ it's designed to act as a template for other Administrate field plugins.
8
+
9
+ ## FAQs
10
+
11
+ **Q: How should I name my gem?**
12
+
13
+ A: Administrate field gems must be named according to the [Rubygems naming guidelines].
14
+
15
+ Essentially, name your gem after the field class that it defines.
16
+ If there's a namespace in the class name, that gets translated to a dash (`-`) in the gem name.
17
+ If the class name is CamelCased, that translates to an underscore (`_`) in the gem name.
18
+
19
+ Since all administrate field gems are under the namespace `Administrate::Field`,
20
+ every field gem name should start with the prefix `administrate-field-`.
21
+
22
+ Here are some examples (these don't correspond to actual gems):
23
+
24
+ | Gem Name | Field Name |
25
+ |----------------------------|------------------------------|
26
+ | `administrate-field-enum` | `Administrate::Field::Enum` |
27
+ | `administrate-field-file_upload` | `Administrate::Field::FileUpload` |
28
+ | `administrate-field-geocoding-region` | `Administrate::Field::Geocoding::Region` |
29
+ | `administrate-field-geocoding-geo_json` | `Administrate::Field::Geocoding::GeoJson` |
30
+
31
+ [Rubygems naming guidelines]: http://guides.rubygems.org/name-your-gem/
32
+
33
+ [Administrate]: https://github.com/thoughtbot/administrate
@@ -0,0 +1,19 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'administrate-field-time'
5
+ s.version = '0.0.1'
6
+ s.authors = ['Enrique Barragan']
7
+ s.email = ['enrique@disruptiveangels.com']
8
+ s.homepage = 'https://github.com/DisruptiveAngels/administrate-field-time'
9
+ s.summary = 'Time field plugin for Administrate'
10
+ s.description = s.summary
11
+ s.license = 'MIT'
12
+
13
+ s.require_paths = ['lib']
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+
17
+ s.add_dependency 'administrate'
18
+ s.add_dependency 'rails', '>= 4.2', '< 5.1'
19
+ end
@@ -0,0 +1,6 @@
1
+ $(function () {
2
+ $(".datetimepicker").datetimepicker({
3
+ debug: false,
4
+ format: "HH:mm:ss",
5
+ });
6
+ });
@@ -0,0 +1,22 @@
1
+ <%#
2
+ # Time Form Partial
3
+
4
+ This partial renders an input element for time attributes.
5
+ By default, the input is a select field for the time attributes.
6
+
7
+ ## Local variables:
8
+
9
+ - `f`:
10
+ A Rails form generator, used to help create the appropriate input fields.
11
+ - `field`:
12
+ An instance of [Administrate::Field::Time][1].
13
+ A wrapper around the tmie attributes pulled from the model.
14
+
15
+ %>
16
+
17
+ <div class="field-unit__label">
18
+ <%= f.label field.attribute %>
19
+ </div>
20
+ <div class="field-unit__field">
21
+ <%= f.text_field field.attribute, class: "datetimepicker" %>
22
+ </div>
@@ -0,0 +1,17 @@
1
+ <%#
2
+ # Time Index Partial
3
+
4
+ This partial renders an time attribute
5
+ to be displayed on a resource's index page.
6
+
7
+ By default, the attribute is rendered as a text tag.
8
+
9
+ ## Local variables:
10
+
11
+ - `field`:
12
+ An instance of [Administrate::Field::Time][1].
13
+ A wrapper around the time attributes pulled from the model.
14
+
15
+ %>
16
+
17
+ <%= field.data.strftime("%I:%M%p").to_s %>
@@ -0,0 +1,17 @@
1
+ <%#
2
+ # Time Show Partial
3
+
4
+ This partial renders an time attribute,
5
+ to be displayed on a resource's show page.
6
+
7
+ By default, the attribute is rendered as a text tag.
8
+
9
+ ## Local variables:
10
+
11
+ - `field`:
12
+ An instance of [Administrate::Field::Time][1].
13
+ A wrapper around the time attributes pulled from the model.
14
+
15
+ %>
16
+
17
+ <%= field.data.strftime("%I:%M%p").to_s %>
@@ -0,0 +1,11 @@
1
+ require 'administrate/field/base'
2
+ require 'rails'
3
+
4
+ module Administrate
5
+ module Field
6
+ class Time < Administrate::Field::Base
7
+ class Engine < ::Rails::Engine
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ require 'administrate/field/time'
2
+
3
+ describe Administrate::Field::Time do
4
+ describe '#to_partial_path' do
5
+ it 'returns a partial based on the page being rendered' do
6
+ page = :show
7
+ field = Administrate::Field::Time.new(:status, 'status', page)
8
+
9
+ path = field.to_partial_path
10
+
11
+ expect(path).to eq('/fields/time/#{page}')
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: administrate-field-time
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Enrique Barragan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: administrate
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '5.1'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '4.2'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '5.1'
47
+ description: Time field plugin for Administrate
48
+ email:
49
+ - enrique@disruptiveangels.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - Gemfile
55
+ - LICENSE.md
56
+ - README.md
57
+ - administrate-field-time.gemspec
58
+ - app/assets/javascripts/administrate/components/date_time_picker.js
59
+ - app/views/fields/time/_form.html.erb
60
+ - app/views/fields/time/_index.html.erb
61
+ - app/views/fields/time/_show.html.erb
62
+ - lib/administrate/field/time.rb
63
+ - spec/lib/administrate/field/time_spec.rb
64
+ homepage: https://github.com/DisruptiveAngels/administrate-field-time
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.6.11
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Time field plugin for Administrate
88
+ test_files:
89
+ - spec/lib/administrate/field/time_spec.rb