chronic_ping 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.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Ryan Hall
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,42 @@
1
+ chronic_ping
2
+ ===========
3
+
4
+ Simple rails engine that uses ajax to ping Chronic, giving users imediate feedback regarding the date they entered in a text field.
5
+
6
+ [![Build Status](https://travis-ci.org/biola/chronic_ping.png)](https://travis-ci.org/biola/chronic_ping)
7
+
8
+ Requirements
9
+ ------------
10
+
11
+ * [chronic](https://rubygems.org/gems/chronic)
12
+ * rails > 3.1 using asset pipeline
13
+ * jquery-rails
14
+
15
+ Usage
16
+ -----
17
+ In your `Gemfile`
18
+
19
+ gem 'chronic_ping'
20
+
21
+ In your `assets/javascript/application.js`
22
+
23
+ //= require chronic_ping
24
+
25
+ In your form
26
+
27
+ = f.text_field :birthday, class: 'chronic_ping', value: @student.birth_date.to_s
28
+
29
+ Customize
30
+ ---------
31
+
32
+ The following values are already set by default, but if you want to customize them, create a file called `config/initializers/chronic_ping.rb` that should look something like this:
33
+
34
+ ChronicPing.configure do |config|
35
+ config.datetime_format = "%B %d, %Y at %I:%M%p"
36
+ config.relative_root_url = ""
37
+ end
38
+
39
+ License
40
+ -------
41
+
42
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ChronicPing'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.markdown')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
3
+
4
+ $('.chronic_ping').focusout(function() {
5
+ var input_field = this;
6
+ $.ajax({
7
+ type: "POST",
8
+ url: "<%= ChronicPing.config.relative_root_url %>/chronic_ping/parse",
9
+ data: { q: this.value },
10
+ dataType: "json"
11
+ }).done(function( msg ) {
12
+ input_field.value = msg.response;
13
+ });
14
+ });
@@ -0,0 +1,14 @@
1
+ class ChronicPingController < ApplicationController
2
+ def parse
3
+ unless params[:q].blank?
4
+ begin
5
+ response = Chronic.parse(params[:q]).strftime(ChronicPing.config.datetime_format)
6
+ render :json => { status: :success, response: response }
7
+ rescue
8
+ render :json => { status: :error, response: "" }
9
+ end
10
+ else
11
+ render :json => { status: :incomplete_query, response: "" }
12
+ end
13
+ end
14
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ post "chronic_ping/parse", :defaults => { :format => 'json' }
3
+ end
@@ -0,0 +1,14 @@
1
+ require "chronic_ping/engine"
2
+ require 'chronic'
3
+
4
+ module ChronicPing
5
+ require 'chronic_ping/configuration'
6
+
7
+ def self.configure
8
+ yield config
9
+ end
10
+
11
+ def self.config
12
+ @config ||= Configuration.new
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module ChronicPing
2
+ class Configuration
3
+ attr_accessor :datetime_format
4
+ attr_accessor :relative_root_url
5
+
6
+ def initialize
7
+ @datetime_format = '%B %d, %Y at %I:%M%p'
8
+ @relative_root_url = ""
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module ChronicPing
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module ChronicPing
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :chronic_ping do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chronic_ping
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Hall
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: chronic
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jquery-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: sqlite3
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Simple rails engine that uses ajax to ping Chronic, giving users imediate
79
+ feedback regarding the date they entered in a text field.
80
+ email:
81
+ - ryan@allegroapps.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - app/assets/javascripts/chronic_ping.js.erb
87
+ - app/controllers/chronic_ping_controller.rb
88
+ - config/routes.rb
89
+ - lib/chronic_ping/configuration.rb
90
+ - lib/chronic_ping/engine.rb
91
+ - lib/chronic_ping/version.rb
92
+ - lib/chronic_ping.rb
93
+ - lib/tasks/chronic_ping_tasks.rake
94
+ - MIT-LICENSE
95
+ - Rakefile
96
+ - README.markdown
97
+ homepage: https://github.com/biola/chronic_ping
98
+ licenses: []
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 1.8.25
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: Uses ajax and chronic to parse date text_fields
121
+ test_files: []