stringify_date 0.1.0 → 0.1.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 +4 -4
- data/.travis.yml +2 -1
- data/Dockerfile +14 -0
- data/docker-compose.yml +11 -0
- data/lib/stringify_date/active_record/stringify.rb +1 -1
- data/lib/stringify_date/version.rb +1 -1
- data/spec/active_record/stringify_spec.rb +37 -11
- data/spec/dummy/config/application.rb +5 -18
- data/stringify_date.gemspec +7 -6
- metadata +33 -21
- data/Guardfile +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd301ddc54c6aa6c1bc9ee56cc93ffdabd8c6c86f99e37bfad5f277352741bc2
|
|
4
|
+
data.tar.gz: 7e974e20bffdad47ebaa6297ae40c1e72e4c48b878bb473ea880110439cb052f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 329af031309954f55ffe2fff799fb7e541c08fa02e1c54de2b4bbc8b99ff51076ca7d2e79e634694eec35588cab0c6a915999682b8e8f23bf072fe772a87f11e
|
|
7
|
+
data.tar.gz: 6f8a9a2d1eb84350ca1809fa5ef49e7f5265ef155d816dc359ac408d1d4ed9bad5a5275bf67f722ea2f8c353c0fe3d67a8a6ffb62f9ee68682ab111d4c2bdd90
|
data/.travis.yml
CHANGED
data/Dockerfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
FROM ruby:2.6-alpine
|
|
2
|
+
|
|
3
|
+
RUN apk --update --no-cache add build-base sqlite-dev libffi-dev git tzdata
|
|
4
|
+
|
|
5
|
+
RUN mkdir /app
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
ADD . /app
|
|
8
|
+
|
|
9
|
+
ENV BUNDLE_PATH=/bundle \
|
|
10
|
+
BUNDLE_BIN=/bundle/bin \
|
|
11
|
+
GEM_HOME=/bundle
|
|
12
|
+
ENV PATH="${BUNDLE_BIN}:${PATH}"
|
|
13
|
+
|
|
14
|
+
RUN gem install bundler && bundle install
|
data/docker-compose.yml
ADDED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe StringifyDate::ActiveRecord::Stringify do
|
|
4
|
+
before { Time.zone = 'Eastern Time (US & Canada)' }
|
|
5
|
+
|
|
4
6
|
let(:test_date) do
|
|
5
7
|
TestDate.new(start_at: Date.today, end_at: DateTime.now)
|
|
6
8
|
end
|
|
@@ -9,11 +11,11 @@ describe StringifyDate::ActiveRecord::Stringify do
|
|
|
9
11
|
TestDate.new(start_at_string: Date.today.to_s, end_at_string: DateTime.now.to_s)
|
|
10
12
|
end
|
|
11
13
|
|
|
12
|
-
it '
|
|
14
|
+
it 'responds to #stringify' do
|
|
13
15
|
expect(TestDate).to respond_to(:stringify)
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
it '
|
|
18
|
+
it 'responds to _string and _string=' do
|
|
17
19
|
expect(test_date).to respond_to(:start_at_string)
|
|
18
20
|
expect(test_date).to respond_to(:start_at_string=)
|
|
19
21
|
expect(test_date).to respond_to(:end_at_string)
|
|
@@ -22,39 +24,63 @@ describe StringifyDate::ActiveRecord::Stringify do
|
|
|
22
24
|
expect(test_date).to respond_to(:published_at_string=)
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
it '
|
|
27
|
+
it 'sets start_at_string to 22/10/2012 when start_at 2012-10-22 and stringify format is "%d/%m/%Y"' do
|
|
26
28
|
test_date.start_at = Date.new(2012, 10, 22)
|
|
27
29
|
|
|
28
30
|
expect(test_date.start_at_string).to eq('22/10/2012')
|
|
29
31
|
end
|
|
30
32
|
|
|
31
|
-
it '
|
|
33
|
+
it 'is invalid when parse invalid date' do
|
|
32
34
|
test_date.start_at_string = 'invalid'
|
|
33
35
|
|
|
34
36
|
expect(test_date.valid?).to be(false)
|
|
35
37
|
end
|
|
36
38
|
|
|
37
|
-
it '
|
|
39
|
+
it 'real attribute is nil when parse invalid date' do
|
|
38
40
|
test_date.start_at_string = 'invalid'
|
|
39
41
|
|
|
40
42
|
expect(test_date.start_at).to be(nil)
|
|
41
43
|
end
|
|
42
44
|
|
|
43
|
-
it '
|
|
45
|
+
it 'is valid when parse empty string' do
|
|
44
46
|
test_date.start_at_string = ''
|
|
45
47
|
|
|
46
48
|
expect(test_date.valid?).to be(true)
|
|
47
49
|
end
|
|
48
50
|
|
|
49
|
-
it '
|
|
50
|
-
test_date.
|
|
51
|
+
it 'sets start_at to 31/10/2001 when start_at 2001-02-03 and stringify format is "%d/%m/%Y %H:%M:%S"' do
|
|
52
|
+
test_date.start_at_string = '31/10/2001 02:02:02'
|
|
51
53
|
|
|
52
|
-
expect(test_date.
|
|
54
|
+
expect(test_date.start_at).to eq(Date.new(2001, 10, 31))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'sets end_at to 31/10/2001 when start_at 2001-02-03 and stringify format is "%d/%m/%Y %H:%M:%S"' do
|
|
58
|
+
test_date.end_at_string = '31/10/2001 02:02:02 -0300'
|
|
59
|
+
|
|
60
|
+
expect(test_date.end_at).to eq(Time.new(2001, 10, 31, 2, 2, 2, '-05:00'))
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'sets end_at to 31/10/2001 when start_at 2001-02-03 and stringify format is "%d/%m/%Y %H:%M:%S"' do
|
|
64
|
+
test_date.end_at_string = '31/10/2001 00:00:00 -0300'
|
|
65
|
+
|
|
66
|
+
expect(test_date.end_at).to eq(Time.new(2001, 10, 31, 0, 0, 0, '-05:00'))
|
|
53
67
|
end
|
|
54
68
|
|
|
55
|
-
it '
|
|
56
|
-
test_date.published_at =
|
|
69
|
+
it 'sets published_at_string to 2001-02-03 when published_at 2001-02-03 and stringify format is not passing' do
|
|
70
|
+
test_date.published_at = DateTime.new(2001, 2, 3)
|
|
57
71
|
|
|
58
72
|
expect(test_date.published_at_string).to eq('2001-02-03')
|
|
59
73
|
end
|
|
74
|
+
|
|
75
|
+
it 'sets end_at_string to 22/10/2001 when start_at 2001-02-03 and stringify format is "%d/%m/%Y %H:%M:%S"' do
|
|
76
|
+
test_date.end_at = Date.new(2001, 2, 3)
|
|
77
|
+
|
|
78
|
+
expect(test_date.end_at_string).to eq('03/02/2001 00:00:00')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'sets end_at_string to 31/10/2002 when start_at 2001-02-03 and stringify format is "%d/%m/%Y %H:%M:%S"' do
|
|
82
|
+
test_date.end_at = Time.new(2002, 10, 31, 2, 2, 2, '-05:00')
|
|
83
|
+
|
|
84
|
+
expect(test_date.end_at_string).to eq('31/10/2002 02:02:02')
|
|
85
|
+
end
|
|
60
86
|
end
|
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
|
2
2
|
|
|
3
3
|
# Pick the frameworks you want:
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require "action_view/railtie"
|
|
8
|
-
require "sprockets/railtie"
|
|
9
|
-
# require "rails/test_unit/railtie"
|
|
4
|
+
require 'active_record/railtie'
|
|
5
|
+
require 'action_controller/railtie'
|
|
6
|
+
require 'action_mailer/railtie'
|
|
10
7
|
|
|
11
8
|
Bundler.require(*Rails.groups)
|
|
12
|
-
require
|
|
9
|
+
require 'stringify_date'
|
|
13
10
|
|
|
14
11
|
module Dummy
|
|
15
12
|
class Application < Rails::Application
|
|
16
|
-
|
|
17
|
-
# Application configuration should go into files in config/initializers
|
|
18
|
-
# -- all .rb files in that directory are automatically loaded.
|
|
19
|
-
|
|
20
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
21
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
22
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
|
23
|
-
|
|
24
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
25
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
26
|
-
# config.i18n.default_locale = :de
|
|
13
|
+
config.time_zone = 'Brasilia'
|
|
27
14
|
end
|
|
28
15
|
end
|
|
29
16
|
|
data/stringify_date.gemspec
CHANGED
|
@@ -23,13 +23,14 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.test_files = spec.files.grep(%r{^(spec)/})
|
|
24
24
|
spec.require_paths = ['lib']
|
|
25
25
|
|
|
26
|
-
spec.add_dependency 'activesupport', '>=
|
|
27
|
-
spec.add_dependency 'railties', '>=
|
|
26
|
+
spec.add_dependency 'activesupport', '>= 5.0'
|
|
27
|
+
spec.add_dependency 'railties', '>= 5.0'
|
|
28
28
|
|
|
29
|
-
spec.add_development_dependency 'bundler', '
|
|
30
|
-
spec.add_development_dependency 'rake'
|
|
29
|
+
spec.add_development_dependency 'bundler', '>= 2'
|
|
30
|
+
spec.add_development_dependency 'rake', '13.0.1'
|
|
31
31
|
spec.add_development_dependency 'rails'
|
|
32
|
-
spec.add_development_dependency 'rspec-rails'
|
|
32
|
+
spec.add_development_dependency 'rspec-rails', '4.0.1'
|
|
33
33
|
spec.add_development_dependency 'sqlite3'
|
|
34
|
-
spec.add_development_dependency '
|
|
34
|
+
spec.add_development_dependency 'tzinfo-data'
|
|
35
|
+
spec.add_development_dependency 'byebug'
|
|
35
36
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stringify_date
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matheus Oliveira
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -16,56 +16,56 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '5.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '5.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: railties
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '5.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '5.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: bundler
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
47
|
+
version: '2'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - "
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
54
|
+
version: '2'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rake
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - '='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 13.0.1
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - '='
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: 13.0.1
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rails
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -82,6 +82,20 @@ dependencies:
|
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: rspec-rails
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - '='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 4.0.1
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - '='
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 4.0.1
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: sqlite3
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
86
100
|
requirements:
|
|
87
101
|
- - ">="
|
|
@@ -95,7 +109,7 @@ dependencies:
|
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
110
|
version: '0'
|
|
97
111
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
112
|
+
name: tzinfo-data
|
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
|
100
114
|
requirements:
|
|
101
115
|
- - ">="
|
|
@@ -109,7 +123,7 @@ dependencies:
|
|
|
109
123
|
- !ruby/object:Gem::Version
|
|
110
124
|
version: '0'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
126
|
+
name: byebug
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
114
128
|
requirements:
|
|
115
129
|
- - ">="
|
|
@@ -132,11 +146,12 @@ extra_rdoc_files: []
|
|
|
132
146
|
files:
|
|
133
147
|
- ".gitignore"
|
|
134
148
|
- ".travis.yml"
|
|
149
|
+
- Dockerfile
|
|
135
150
|
- Gemfile
|
|
136
|
-
- Guardfile
|
|
137
151
|
- LICENSE.txt
|
|
138
152
|
- README.md
|
|
139
153
|
- Rakefile
|
|
154
|
+
- docker-compose.yml
|
|
140
155
|
- lib/stringify_date.rb
|
|
141
156
|
- lib/stringify_date/active_record/stringify.rb
|
|
142
157
|
- lib/stringify_date/version.rb
|
|
@@ -156,7 +171,6 @@ files:
|
|
|
156
171
|
- spec/dummy/config/environments/development.rb
|
|
157
172
|
- spec/dummy/config/environments/production.rb
|
|
158
173
|
- spec/dummy/config/environments/test.rb
|
|
159
|
-
- spec/dummy/config/initializers/assets.rb
|
|
160
174
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
|
161
175
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
|
162
176
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
|
@@ -200,8 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
200
214
|
- !ruby/object:Gem::Version
|
|
201
215
|
version: '0'
|
|
202
216
|
requirements: []
|
|
203
|
-
|
|
204
|
-
rubygems_version: 2.7.4
|
|
217
|
+
rubygems_version: 3.0.3
|
|
205
218
|
signing_key:
|
|
206
219
|
specification_version: 4
|
|
207
220
|
summary: Parser for string an date/datetime
|
|
@@ -222,7 +235,6 @@ test_files:
|
|
|
222
235
|
- spec/dummy/config/environments/development.rb
|
|
223
236
|
- spec/dummy/config/environments/production.rb
|
|
224
237
|
- spec/dummy/config/environments/test.rb
|
|
225
|
-
- spec/dummy/config/initializers/assets.rb
|
|
226
238
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
|
227
239
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
|
228
240
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
data/Guardfile
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
guard :rspec, cmd: 'bundle exec rspec' do
|
|
2
|
-
require 'guard/rspec/dsl'
|
|
3
|
-
dsl = Guard::RSpec::Dsl.new(self)
|
|
4
|
-
|
|
5
|
-
# RSpec files
|
|
6
|
-
rspec = dsl.rspec
|
|
7
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
8
|
-
watch(rspec.spec_support) { rspec.spec_dir }
|
|
9
|
-
watch(rspec.spec_files)
|
|
10
|
-
|
|
11
|
-
# Ruby files
|
|
12
|
-
ruby = dsl.ruby
|
|
13
|
-
dsl.watch_spec_files_for(ruby.lib_files)
|
|
14
|
-
|
|
15
|
-
# Rails files
|
|
16
|
-
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
|
17
|
-
dsl.watch_spec_files_for(rails.app_files)
|
|
18
|
-
dsl.watch_spec_files_for(rails.views)
|
|
19
|
-
|
|
20
|
-
watch(rails.controllers) do |m|
|
|
21
|
-
[
|
|
22
|
-
rspec.spec.call("routing/#{m[1]}_routing"),
|
|
23
|
-
rspec.spec.call("controllers/#{m[1]}_controller"),
|
|
24
|
-
rspec.spec.call("acceptance/#{m[1]}")
|
|
25
|
-
]
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Rails config changes
|
|
29
|
-
watch(rails.spec_helper) { rspec.spec_dir }
|
|
30
|
-
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
|
31
|
-
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
|
32
|
-
|
|
33
|
-
# Capybara features specs
|
|
34
|
-
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
|
35
|
-
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
|
36
|
-
|
|
37
|
-
# Turnip features and steps
|
|
38
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
39
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
|
40
|
-
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
|
2
|
-
|
|
3
|
-
# Version of your assets, change this if you want to expire all your assets.
|
|
4
|
-
Rails.application.config.assets.version = '1.0'
|
|
5
|
-
|
|
6
|
-
# Precompile additional assets.
|
|
7
|
-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
|
8
|
-
# Rails.application.config.assets.precompile += %w( search.js )
|