day_greeter 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 +2 -2
- data/README.md +6 -1
- data/app/assets/javascripts/day_greeter.js +22 -0
- data/lib/day_greeter.rb +3 -24
- data/lib/day_greeter/version.rb +1 -1
- metadata +6 -9
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/day_greeter.gemspec +0 -23
checksums.yaml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
---
|
2
2
|
SHA512:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f39d084e0f45cac372bfca7bc1f5eaca2cb17b1b2c5c4871f92bce02b5da922677fcadeb908f41521586d01e5899e36fce83c388a494cdd58324d2ba293f9fcb
|
4
|
+
data.tar.gz: 9bb07325d69fa50852d3ba9ecab6bc4caa7b9797ae292383b23d63e24b332614a1e37e9c11561d6c00d89d98fa4a5d1d44d2756a927d49fdac02fa03b1d49763
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# DayGreeter
|
2
2
|
|
3
|
-
This gem allows you to greet your user with good morning, afternoon etc, based on the server timezone
|
3
|
+
This gem allows you to greet your user with good morning, afternoon etc, based on the server timezone.
|
4
4
|
|
5
5
|
If your users are going to be from different timezones you can use our javascript option so that they can have correct greeting based on their timezones.
|
6
6
|
|
@@ -27,6 +27,11 @@ If your user are going to be from different timezones you just have to set confi
|
|
27
27
|
```
|
28
28
|
config.jsdaygreeter = true
|
29
29
|
```
|
30
|
+
##### Using JavaScript
|
31
|
+
Require DayGreeter JS (day_greeter.js) in your application.js
|
32
|
+
```
|
33
|
+
//= require day_greeter
|
34
|
+
```
|
30
35
|
Pass already existing element id to greet method were you want greeting to be appended.
|
31
36
|
```
|
32
37
|
<span id='greet'></span>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
var date =new Date();
|
2
|
+
var hrs = date.getHours();
|
3
|
+
var msg='';
|
4
|
+
function getGreeting(hrs){
|
5
|
+
if(hrs > 0){
|
6
|
+
msg = 'Morning Sunshine' //REALLY early
|
7
|
+
}
|
8
|
+
if(hrs >= 6){
|
9
|
+
msg = 'Good morning' //After 6am
|
10
|
+
}
|
11
|
+
if(hrs >= 12){
|
12
|
+
msg = 'Good afternoon'; //After 12pm
|
13
|
+
}
|
14
|
+
if(hrs >= 17){
|
15
|
+
msg = 'Good evening'; //After 5pm
|
16
|
+
}
|
17
|
+
if(hrs >= 22){
|
18
|
+
msg = 'Go to bed!';
|
19
|
+
}
|
20
|
+
|
21
|
+
return msg
|
22
|
+
}
|
data/lib/day_greeter.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require "day_greeter/version"
|
2
2
|
|
3
3
|
module DayGreeter
|
4
|
-
|
5
|
-
|
6
|
-
end
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
end
|
7
6
|
def self.greet element_id=''
|
8
7
|
jsdaygreeter = Rails.application.config.respond_to?(:jsdaygreeter) ? Rails.application.config.jsdaygreeter : false
|
9
8
|
greet_message = jsdaygreeter ? get_msg_js(element_id).html_safe : get_msg
|
@@ -29,27 +28,7 @@ module DayGreeter
|
|
29
28
|
msg
|
30
29
|
end
|
31
30
|
def self.get_msg_js element_id
|
32
|
-
"<script>
|
33
|
-
function getGreeting(hrs){
|
34
|
-
if(hrs > 0){
|
35
|
-
msg = 'Morning Sunshine' //REALLY early
|
36
|
-
}
|
37
|
-
if(hrs >= 6){
|
38
|
-
msg = 'Good morning' //After 6am
|
39
|
-
}
|
40
|
-
if(hrs >= 12){
|
41
|
-
msg = 'Good afternoon'; //After 12pm
|
42
|
-
}
|
43
|
-
if(hrs >= 17){
|
44
|
-
msg = 'Good evening'; //After 5pm
|
45
|
-
}
|
46
|
-
if(hrs >= 22){
|
47
|
-
msg = 'Go to bed!';
|
48
|
-
}
|
49
|
-
document.getElementById('"+element_id+"').innerHTML = msg;
|
50
|
-
return msg}
|
51
|
-
getGreeting(hrs);
|
52
|
-
</script>"
|
31
|
+
"<script>document.getElementById('"+element_id+"').innerHTML = getGreeting(hrs);</script>"
|
53
32
|
end
|
54
33
|
end
|
55
34
|
ActionView::Base.send :include, DayGreeter
|
data/lib/day_greeter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: day_greeter
|
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
|
- anant
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-23 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -42,14 +42,11 @@ extensions: []
|
|
42
42
|
extra_rdoc_files: []
|
43
43
|
|
44
44
|
files:
|
45
|
-
- .gitignore
|
46
|
-
- Gemfile
|
47
|
-
- LICENSE.txt
|
48
|
-
- README.md
|
49
|
-
- Rakefile
|
50
|
-
- day_greeter.gemspec
|
51
45
|
- lib/day_greeter.rb
|
52
46
|
- lib/day_greeter/version.rb
|
47
|
+
- app/assets/javascripts/day_greeter.js
|
48
|
+
- Rakefile
|
49
|
+
- README.md
|
53
50
|
homepage: ""
|
54
51
|
licenses:
|
55
52
|
- MIT
|
@@ -59,7 +56,7 @@ post_install_message:
|
|
59
56
|
rdoc_options: []
|
60
57
|
|
61
58
|
require_paths:
|
62
|
-
- lib
|
59
|
+
- "{lib,app}/**/*"
|
63
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
61
|
requirements:
|
65
62
|
- *id003
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 anant
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/day_greeter.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'day_greeter/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "day_greeter"
|
8
|
-
spec.version = DayGreeter::VERSION
|
9
|
-
spec.authors = ["anant"]
|
10
|
-
spec.email = ["ani.kolvankar@gmail.com"]
|
11
|
-
spec.description = %q{This gem allows you to greet your user}
|
12
|
-
spec.summary = %q{This gem allows you to say hello and will be saying good morning, afternoon, evening based on current time}
|
13
|
-
spec.homepage = ""
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
end
|