simple_form_recurring_select 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6c150429f5402f819650d6b20b152fad13e3416
4
+ data.tar.gz: 6c9e5309ddb5c8bc1d0c2409ff49c1bec35824d5
5
+ SHA512:
6
+ metadata.gz: acf5dc942bcd91e58993ec9bb9e09756b5c8e32ccf818f3a7c66cb190b9c47ac216589e8e58a24eebe41bd14bfd3dd90396aebc948b6f49fc174135eb7ec6da2
7
+ data.tar.gz: 09dffede6daf501fb5d59ce839508e42ec9d4116ed986570239f5a2ac0ce533d33bada14c130a7bafd240e9cc5922160049da3073a96b75f6bb6997fccc9aea7
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simple_form_recurring_select.gemspec
4
+ gemspec
@@ -0,0 +1,5 @@
1
+ guard :minitest do
2
+ watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
3
+ watch(%r{^test/.+_test\.rb$})
4
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
5
+ end
@@ -0,0 +1,77 @@
1
+ # Simple Form Recurring Select
2
+
3
+ [![Build Status](https://travis-ci.org/tomasc/recurring_select.svg)](https://travis-ci.org/tomasc/recurring_select) [![Gem Version](https://badge.fury.io/rb/recurring_select.svg)](http://badge.fury.io/rb/recurring_select) [![Coverage Status](https://img.shields.io/coveralls/tomasc/recurring_select.svg)](https://coveralls.io/r/tomasc/recurring_select)
4
+
5
+ Wrapper around the [recurring_select](https://github.com/GetJobber/recurring_select) gem for Simple Form.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'simple_form_recurring_select'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install simple_form_recurring_select
22
+
23
+ ## Usage
24
+
25
+ In model:
26
+
27
+ ```ruby
28
+ class MyModel
29
+ include SimpleFormRecurringSelect::HasRecurrenceRule
30
+ has_recurrence_rule
31
+
32
+ def recurrence_rule
33
+ @recurrence_rule ||= schedule.recurrence_rules.first
34
+ end
35
+
36
+ private
37
+
38
+ def update_schedule
39
+ self.schedule = IceCube::Schedule.new(schedule.start_time) do |s|
40
+ s.add_recurrence_rule(@recurrence_rule) if @recurrence_rule.present?
41
+ end
42
+ end
43
+ end
44
+ ```
45
+
46
+ This will setup `#recurrence_rule` accessor that converts JSON coming from a form to (IceCube::Rule)[https://github.com/seejohnrun/ice_cube]. The logic of adding the recurrence rule to a schedule is left up to you.
47
+
48
+ In forms:
49
+
50
+ ```ruby
51
+ = form.input :recurrence_rule, as: :recurring_select
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ Accessor & schedule accessor / method names can be configured as follows:
57
+
58
+ ```ruby
59
+ class MyModel
60
+ include SimpleFormRecurringSelect::HasRecurringSelect
61
+ has_recurring_select accessor_name: :my_recurrence_rule
62
+ end
63
+ ```
64
+
65
+ ## Development
66
+
67
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
68
+
69
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it ( https://github.com/tomasc/simple_form_recurring_select/fork )
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.pattern = 'test/**/*_test.rb'
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "simple_form_recurring_select"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require "simple_form_recurring_select/has_recurrence_rule"
2
+ require "simple_form_recurring_select/recurring_select_input"
3
+ require "simple_form_recurring_select/version"
4
+
5
+ # ---------------------------------------------------------------------
6
+
7
+ module SimpleForm
8
+ class FormBuilder
9
+ map_type :recurring_select, to: SimpleFormRecurringSelect::RecurringSelectInput
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ module SimpleFormRecurringSelect
2
+ module HasRecurrenceRule
3
+
4
+ def self.included base
5
+ base.extend ClassMethods
6
+ base.class_eval do
7
+ end
8
+ end
9
+
10
+ # =====================================================================
11
+
12
+ module ClassMethods
13
+ def has_recurrence_rule options={}
14
+ accessor_name = options.fetch :accessor_name, :recurrence_rule
15
+
16
+ attr_reader accessor_name
17
+
18
+ define_method "#{accessor_name}=" do |value|
19
+ case value
20
+ when NilClass, 'null' then nil
21
+ else instance_variable_set "@#{accessor_name}", IceCube::Rule.from_hash( JSON.parse(value) )
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ require "simple_form"
2
+
3
+ module SimpleFormRecurringSelect
4
+ class RecurringSelectInput < SimpleForm::Inputs::Base
5
+
6
+ def input wrapper_options
7
+ template.content_tag :div, class: "inputs #{attribute_name}" do
8
+ template.concat select_recurring_tag.html_safe
9
+ end
10
+ end
11
+
12
+ private # =============================================================
13
+
14
+ def select_recurring_tag
15
+ @builder.select_recurring attribute_name, options[:default_schedules], options.slice(:allow_blank), { data: { recurring_select_position: options.fetch(:position, 'inline') } }
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleFormRecurringSelect
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simple_form_recurring_select/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simple_form_recurring_select"
8
+ spec.version = SimpleFormRecurringSelect::VERSION
9
+ spec.authors = ["Tomas Celizna"]
10
+ spec.email = ["tomas.celizna@gmail.com"]
11
+
12
+ spec.summary = %q{Wrapper around the 'recurring_select' gem for SimpleForm.}
13
+ spec.homepage = "https://github.com/tomasc/simple_form_recurring_select"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "ice_cube"
21
+ spec.add_dependency "rails"
22
+ spec.add_dependency "recurring_select"
23
+ spec.add_dependency "simple_form"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "coveralls"
27
+ spec.add_development_dependency "guard"
28
+ spec.add_development_dependency "guard-minitest"
29
+ spec.add_development_dependency "minitest"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_form_recurring_select
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomas Celizna
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ice_cube
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: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: recurring_select
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simple_form
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-minitest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: minitest
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rake
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '10.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '10.0'
153
+ description:
154
+ email:
155
+ - tomas.celizna@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".travis.yml"
162
+ - Gemfile
163
+ - Guardfile
164
+ - README.md
165
+ - Rakefile
166
+ - bin/console
167
+ - bin/setup
168
+ - lib/simple_form_recurring_select.rb
169
+ - lib/simple_form_recurring_select/has_recurrence_rule.rb
170
+ - lib/simple_form_recurring_select/recurring_select_input.rb
171
+ - lib/simple_form_recurring_select/version.rb
172
+ - simple_form_recurring_select.gemspec
173
+ homepage: https://github.com/tomasc/simple_form_recurring_select
174
+ licenses: []
175
+ metadata: {}
176
+ post_install_message:
177
+ rdoc_options: []
178
+ require_paths:
179
+ - lib
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ requirements: []
191
+ rubyforge_project:
192
+ rubygems_version: 2.4.8
193
+ signing_key:
194
+ specification_version: 4
195
+ summary: Wrapper around the 'recurring_select' gem for SimpleForm.
196
+ test_files: []