page_record 1.0.0.beta1 → 1.0.0

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- page_record (1.0.0.beta.1)
4
+ page_record (1.0.0)
5
5
  activemodel
6
6
  activesupport
7
7
  capybara (~> 2.1.0)
data/Guardfile CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  guard 'rspec' do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/page_record/#{m[1]}_spec.rb" }
7
- watch('spec/spec_helper.rb') { "spec" }
8
- watch('spec/support/*.rb') { "spec" }
9
- watch('spec/support/views/*.erb') { "spec" }
6
+ watch(%r{^lib/page_record/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ watch('spec/support/*.rb') { "spec" }
9
+ watch('spec/support/views/*.erb') { "spec" }
10
10
  end
11
11
 
@@ -25,24 +25,14 @@ module PageRecord
25
25
  # this name on the page
26
26
  #
27
27
  def method_missing(action)
28
- raw_action = /(.*)\?/.match(action)
29
- begin
30
- if raw_action
31
- action_for?(raw_action[1])
32
- else
33
- action_for(action)
34
- end
35
- rescue Capybara::Ambiguous
36
- raise MultipleRecords, "Found multiple #{action} tags for #{@type} on page"
37
- rescue Capybara::ElementNotFound
38
- super
39
- end
28
+ self.class.method_missing(action)
40
29
  end
41
30
 
42
31
  protected
32
+
43
33
  # @private
44
34
  def actions
45
- self.class.send('actions_on?',@record)
35
+ self.class.send('actions_on?', @record)
46
36
  end
47
37
 
48
38
  private
@@ -97,6 +87,7 @@ module PageRecord
97
87
  end
98
88
 
99
89
  protected
90
+
100
91
  # @private
101
92
  def actions
102
93
  actions_on?(page)
@@ -104,16 +95,17 @@ module PageRecord
104
95
 
105
96
  # @private
106
97
  def actions_on?(context)
107
- actions = context.all("[data-action-for]")
108
- action_hash = Hash.new
98
+ actions = context.all('[data-action-for]')
99
+ action_hash = {}
109
100
  actions.each do | action|
110
101
  name = action['data-action-for']
111
- action_hash[name] = { tag: action.tag_name, text:action.text }
102
+ action_hash[name] = { tag: action.tag_name, text: action.text }
112
103
  end
113
104
  action_hash
114
105
  end
115
106
 
116
107
  private
108
+
117
109
  # @private
118
110
  def action_for(action)
119
111
  element = action_for?(action)
@@ -17,7 +17,6 @@ module PageRecord
17
17
  find_record(selector, filter)
18
18
  end
19
19
 
20
-
21
20
  ##
22
21
  # Set's the default selector for this class
23
22
  #
@@ -30,7 +29,7 @@ module PageRecord
30
29
  # ```
31
30
  # @param new_selector [String] The default selector to be used for all finders
32
31
  #
33
- def self.selector( new_selector = nil)
32
+ def self.selector(new_selector = nil)
34
33
  @selector = new_selector if new_selector
35
34
  @selector
36
35
  end
@@ -49,7 +48,7 @@ module PageRecord
49
48
  #
50
49
  # @param new_filter [String] The default filter to be used for all finders
51
50
  #
52
- def self.filter( new_filter = nil)
51
+ def self.filter(new_filter = nil)
53
52
  @filter = new_filter if new_filter
54
53
  @filter
55
54
  end
@@ -4,16 +4,15 @@ module Formtastic
4
4
  module Base
5
5
 
6
6
  module Errors
7
-
7
+
8
8
  def error_sentence_html
9
9
  extend(PageRecord::Helpers)
10
10
  error_class = options[:error_class] || builder.default_inline_error_class
11
- options = { :class => error_class }.merge(error_for(@method))
11
+ options = { class: error_class }.merge(error_for(@method))
12
12
  template.content_tag(:p, Formtastic::Util.html_safe(errors.to_sentence.html_safe), options)
13
13
  end
14
14
  end
15
15
 
16
-
17
16
  module Html
18
17
 
19
18
  alias_method :input_html_options_org, :input_html_options
@@ -23,7 +23,7 @@ module PageRecord
23
23
  # @param type Symbol identifying the type of record and the variable to use
24
24
  # @param var the variable to use. This is optional
25
25
  #
26
- # @return Hash
26
+ # @return Hash
27
27
  #
28
28
  #
29
29
  def form_record_for(type, var = nil)
@@ -83,7 +83,7 @@ module PageRecord
83
83
  #
84
84
  # @param name Symbol or String identifying the name
85
85
  #
86
- # @return Hash
86
+ # @return Hash
87
87
  #
88
88
  #
89
89
  def attribute_for(name)
@@ -108,7 +108,7 @@ module PageRecord
108
108
  #
109
109
  # @param name Symbol or String identifying the action name
110
110
  #
111
- # @return Hash
111
+ # @return Hash
112
112
  #
113
113
  #
114
114
  def action_for(name)
@@ -117,13 +117,12 @@ module PageRecord
117
117
  Hash['data-action-for', name]
118
118
  end
119
119
 
120
-
121
120
  ##
122
121
  #
123
122
  # Returns a hash containing the error name. This can be used as html options in rails helpers
124
123
  #
125
- # example:
126
- #
124
+ # example:
125
+ #
127
126
  # TODO: Make an example
128
127
  #
129
128
  #
@@ -142,8 +141,6 @@ module PageRecord
142
141
  Hash['data-error-for', name]
143
142
  end
144
143
 
145
-
146
-
147
144
  ##
148
145
  #
149
146
  # Writes a tag containing the specified PageRecord attribute
@@ -211,7 +208,7 @@ module PageRecord
211
208
  # ```
212
209
  # @see
213
210
  #
214
- # @return formBuilder object
211
+ # @return formBuilder object
215
212
  #
216
213
  #
217
214
  def record_form_for(record, options = {}, &block)
@@ -2,7 +2,6 @@ module PageRecord
2
2
 
3
3
  module Inspector
4
4
 
5
-
6
5
  def self.included(base)
7
6
  base.extend(ClassMethods)
8
7
  end
@@ -15,12 +14,13 @@ module PageRecord
15
14
  end
16
15
 
17
16
  private
18
- #@private
17
+
18
+ # @private
19
19
  def attributes
20
- attributes = Hash.new
20
+ attributes = {}
21
21
  self.class.attributes.each do | attribute|
22
22
  begin
23
- attributes[attribute] = self.send(attribute)
23
+ attributes[attribute] = send(attribute)
24
24
  rescue AttributeNotFound
25
25
  attributes[attribute] = '--not found on page--'
26
26
  end
@@ -30,16 +30,15 @@ module PageRecord
30
30
 
31
31
  module ClassMethods
32
32
  def inspect
33
- {
34
- type: self.type,
35
- host_class: self.host_class,
36
- selector: self.selector,
37
- filter: self.filter,
38
- attributes: self.attributes,
39
- actions: self.actions
40
- }
33
+ {
34
+ type: type,
35
+ host_class: host_class,
36
+ selector: selector,
37
+ filter: filter,
38
+ attributes: attributes,
39
+ actions: actions
40
+ }
41
41
  end
42
42
  end
43
-
44
43
  end
45
44
  end
@@ -10,7 +10,7 @@ module PageRecord
10
10
  # @raise [AttributeNotFound] when the attribute is not found in the record
11
11
  #
12
12
  def errors
13
- found_errors = @record.all("[data-error-for]")
13
+ found_errors = @record.all('[data-error-for]')
14
14
  error_list = ActiveModel::Errors.new(self)
15
15
  found_errors.each do | error |
16
16
  attribute = error['data-error-for']
@@ -1,3 +1,3 @@
1
1
  module PageRecord
2
- VERSION = '1.0.0.beta1'
2
+ VERSION = '1.0.0'
3
3
  end
data/spec/actions_spec.rb CHANGED
@@ -3,11 +3,12 @@ require_relative './spec_helper'
3
3
  describe PageRecord::Actions do
4
4
 
5
5
  include_context "default context"
6
+ include_context "page one record in a form"
7
+
6
8
 
7
9
  describe "#<action>" do
8
10
 
9
11
  let(:record) { TeamPage.find(1) }
10
- include_context "page one record in a form"
11
12
 
12
13
  before do
13
14
  Capybara::Node::Element.any_instance.
@@ -25,7 +26,6 @@ describe PageRecord::Actions do
25
26
  describe "#<action>?" do
26
27
 
27
28
  let(:record) { TeamPage.find(1) }
28
- include_context "page one record in a form"
29
29
 
30
30
  it_behaves_like "a valid action finder" do
31
31
  let(:valid_action) { record.create?}
@@ -35,7 +35,6 @@ describe PageRecord::Actions do
35
35
  end
36
36
 
37
37
  describe ".<action>" do
38
- include_context "page one record in a form"
39
38
 
40
39
  before do
41
40
  Capybara::Node::Element.any_instance.
@@ -51,7 +50,6 @@ describe PageRecord::Actions do
51
50
  end
52
51
 
53
52
  describe ".<action>?" do
54
- include_context "page one record in a form"
55
53
 
56
54
  it_behaves_like "a valid action finder" do
57
55
  let(:valid_action) { TeamPage.page_action?}
data/spec/base_spec.rb CHANGED
@@ -3,6 +3,7 @@ require_relative './spec_helper'
3
3
  describe PageRecord::Base do
4
4
 
5
5
  include_context "default context"
6
+ include_context "page one record in a form"
6
7
 
7
8
  describe ".type" do
8
9
 
@@ -1 +1 @@
1
- ./spec/inspector_spec.rb:12
1
+
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
5
- prerelease: 6
4
+ version: 1.0.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Bert Hajee
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-30 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -293,13 +293,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
293
  version: '0'
294
294
  segments:
295
295
  - 0
296
- hash: 3108883402559724097
296
+ hash: -2075293908552709034
297
297
  required_rubygems_version: !ruby/object:Gem::Requirement
298
298
  none: false
299
299
  requirements:
300
- - - ! '>'
300
+ - - ! '>='
301
301
  - !ruby/object:Gem::Version
302
- version: 1.3.1
302
+ version: '0'
303
+ segments:
304
+ - 0
305
+ hash: -2075293908552709034
303
306
  requirements: []
304
307
  rubyforge_project:
305
308
  rubygems_version: 1.8.24