watir-ng 1.1.0 → 2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daffebcf1004af9928c5d468d28bd07722574d11
4
- data.tar.gz: 21fab3bcbda254b190279a8588e56bbb5e8d6b30
3
+ metadata.gz: e244c588c9457a7795771827961a9e0b4bd373a3
4
+ data.tar.gz: 15cd2d67ff0705e6f84fcd6a17a760c80109237a
5
5
  SHA512:
6
- metadata.gz: eb78ff0b2eaac8d750d3b57572b79693ce55b1f7e80c5be24e4aff09606baa209611ac3fe5bf9f1e0610086727f44832699506ab39df4f448a25a1440bc6cf2c
7
- data.tar.gz: 26a63b760614a571c629d6e15fc851e43adcd8106ea79f9d779b75e0a2e55f308e5da88c2292ded778a60d52f8df243cba6dc20412518209e203425892f56cf6
6
+ metadata.gz: 932b756b7e15874008d5180fbb27aa81040f32b0af650d4ff0c3a49a7416e1bbe9e5e1972a127d25a9dfc0c0aeb03056fadeab934ba8e7b93dd9368d89803388
7
+ data.tar.gz: 4edd75c60cc563aab5e9a89276fe14767e19d5d25a4fe3fd26be08af32be0c7d0277534654c3b23a812e23d31646cf56e445dde2c7b9505922257ca63cbe78ae
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v2.0.0 (Feb 24 2016)
4
+ - Patch browser objects with `WatirNg.patch!`
5
+ - Add custom directive identifiers with `WatirNg.register`
6
+
3
7
  ## v1.1.0 (Sep 18 2015)
4
8
  - Register custom attributes for identifying elements
5
9
  - Thanks Yehuda Miller (@pittgoose) for the idea
data/README.md CHANGED
@@ -6,23 +6,34 @@ Identify [watir-webdriver](http://github.com/watir/watir-webdriver) elements wit
6
6
 
7
7
  ## Usage
8
8
 
9
- Require `watir-ng` anywhere you'd instantiate a browser instance and `watir-ng` will patch directive identifiers onto `Watir::HTMLElement`.
9
+ When identifying elements, use the `ng` directives like you would `id`, `class`, etc. Be sure to use underscores instead of dashes though!
10
+
11
+ ```ruby
12
+ # To find and click this HTML element:
13
+ # <button ng-click="foo">Submit</button>
14
+
15
+ submit_button = @browser.button(ng_click: "foo")
16
+ submit_button.click
17
+ ```
18
+
19
+ To ensure your browser objects have access to the ng identifiers, run `patch!` before instantiating.
10
20
 
11
21
  ```ruby
12
- require 'watir-webdriver'
13
22
  require 'watir-ng'
14
23
 
15
- browser = Watir::Browser.new :chrome
24
+ WatirNg.patch!
25
+
26
+ @browser = Watir::Browser.new
16
27
  ```
17
28
 
18
- When identifying elements, use the `ng` directives like you would `id`, `class`, etc. Be sure to use underscores instead of dashes though!
29
+ You can identify elements with custom directives by registering them before patching the browser.
19
30
 
20
31
  ```ruby
21
- # To find and click this HTML element:
22
- # <button ng-click="foo">Submit</button>
32
+ require 'watir-ng'
23
33
 
24
- submit_button = browser.button(ng_click: "foo")
25
- submit_button.click
34
+ WatirNg.register(:ng_foo, :ng_bar).patch!
35
+
36
+ @browser = Watir::Browser.new
26
37
  ```
27
38
 
28
39
  ## Installation
@@ -49,5 +60,5 @@ Or install it yourself with:
49
60
 
50
61
  ## Questions, Comments, Concerns
51
62
 
52
- Find me on Twitter ([@jpdenen](http://twitter.com/jpdenen)) or write up an issue.
63
+ Find me on Twitter ([@jpdenen](http://twitter.com/jpdenen)), gitter ([@jdenen](http://gitter.im/jdenen)) or write up an [issue](https://github.com/jdenen/watir-ng/issues/new).
53
64
 
data/lib/watir-ng.rb CHANGED
@@ -5,57 +5,63 @@ require "watir-ng/version"
5
5
  # Adds AngularJS `ng` directives as identifiers for `Watir::Webdriver` elements.
6
6
  #
7
7
  module WatirNg
8
-
9
- #
10
- # All the ng directives from the AngularJS documentation.
11
- #
12
- # @see `https://docs.angularjs.org/api/ng/directive`
13
- #
14
- NG_STRINGS = %w(ng_jq ng_app ng_href ng_src ng_srcset ng_disabled ng_checked ng_readonly
15
- ng_selected ng_open ng_form ng_value ng_bind ng_bind_template ng_bind_html
16
- ng_change ng_class ng_class_odd ng_class_even ng_cloak ng_controller ng_csp
17
- ng_click ng_dblclick ng_mousedown ng_mouseup ng_mouseover ng_mouseenter
18
- ng_mouseleave ng_mousemove ng_keydown ng_keyup ng_keypress ng_submit ng_focus
19
- ng_blur ng_copy ng_cut ng_paste ng_if ng_include ng_init ng_list ng_model
20
- ng_model_options ng_non_bindable ng_options ng_pluralize ng_repeat ng_show
21
- ng_hide ng_style ng_switch ng_transclude
22
- )
23
-
24
- #
25
- # Inserts `NG_STRINGS` and `custom_directives` into `cls.attributes` as symbols when
26
- # included in the class.
27
- #
28
- # @param cls [Class]
29
- # @return [nil]
30
- #
31
- def self.included cls
32
- if cls.respond_to? :attributes
33
- ng_directives.push(*custom_directives).each { |ng| cls.attributes << ng }
8
+ class << self
9
+
10
+ #
11
+ # Register custom directives as element identifiers.
12
+ #
13
+ # @example
14
+ # WatirNg.register "ng_foo", :ng_bar
15
+ #
16
+ # @param custom_directives [Symbol, String]
17
+ # @return [WatirNg]
18
+ #
19
+ def register *args
20
+ tap { |ng| ng.custom_directives.push *args }
34
21
  end
35
- end
36
22
 
37
- #
38
- # Converts `NG_STRINGS` into an array of symbols.
39
- #
40
- # @api private
41
- # @return [Array<Symbol>] directives
42
- #
43
- def self.ng_directives
44
- @ng_directives ||= NG_STRINGS.map(&:to_sym)
45
- end
23
+ #
24
+ # Patch Watir::HTMLElements with ng and custom directives.
25
+ #
26
+ # @example
27
+ # require 'watir-webdriver'
28
+ # require 'watir-ng'
29
+ # WatirNg.patch!
30
+ # browser = Watir::Browser.start
31
+ #
32
+ # @return [Array]
33
+ #
34
+ def patch!
35
+ attributes = directives.push *custom_directives.map(&:to_sym)
36
+ Watir::HTMLElement.attributes.push *attributes
37
+ end
46
38
 
47
- #
48
- # Collect custom defined directives.
49
- #
50
- # @return [Array]
51
- #
52
- def self.custom_directives
53
- @custom_directives ||= []
54
- end
55
- end
39
+ # @api private
40
+ #
41
+ # Return array of ng directives.
42
+ #
43
+ # @return [Array<Symbol>]
44
+ #
45
+ def directives
46
+ %w(ng_jq ng_app ng_href ng_src ng_srcset ng_disabled ng_checked ng_readonly
47
+ ng_selected ng_open ng_form ng_value ng_bind ng_bind_template ng_bind_html
48
+ ng_change ng_class ng_class_odd ng_class_even ng_cloak ng_controller ng_csp
49
+ ng_click ng_dblclick ng_mousedown ng_mouseup ng_mouseover ng_mouseenter
50
+ ng_mouseleave ng_mousemove ng_keydown ng_keyup ng_keypress ng_submit ng_focus
51
+ ng_blur ng_copy ng_cut ng_paste ng_if ng_include ng_init ng_list ng_model
52
+ ng_model_options ng_non_bindable ng_options ng_pluralize ng_repeat ng_show
53
+ ng_hide ng_style ng_switch ng_transclude).map(&:to_sym)
54
+ end
56
55
 
57
- module Watir
58
- class HTMLElement
59
- include WatirNg
56
+ # @api private
57
+ #
58
+ # Return array of custom directives.
59
+ #
60
+ # @return [Array]
61
+ #
62
+ def custom_directives
63
+ @custom_directives ||= []
64
+ end
65
+
60
66
  end
61
67
  end
@@ -1,4 +1,4 @@
1
1
  module WatirNg
2
- # @api private
3
- VERSION = "1.1.0"
2
+ # :nodoc:
3
+ VERSION = "2.0.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir-ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnson Denen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: watir-webdriver