parfait 0.8.0 → 0.9.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: 4c35819f92d949b909c2178dacdff7caa9fe40c4
4
- data.tar.gz: d8dceab268f4ab11dd69a518810ebd5c006b4659
3
+ metadata.gz: 093767b0830d5bd17b0a1f3e67a646aec8f45a48
4
+ data.tar.gz: 66528f64042e6e9ccbe7a4ba5666a18f0a513506
5
5
  SHA512:
6
- metadata.gz: 049efbccf79d1f8eea86d5206a431f2c78381c81f8f58f1fadfe4c9bc5f3ddec58ce84b7ad0a36a0afc4df6d56614abb6b0a01a9c3a4a8f6b9dcab7252074587
7
- data.tar.gz: b4ced0aeac0417e23d60966408b74e5e1e18964371e20b9f46b98e9c5acb8914df2669afa752f90434aa86e8bfe02e11cb1a520c1a10ebf0e2c61bd864bac31b
6
+ metadata.gz: 25a38de727f4bbe2a7ac4db1cb9c4663b82be2a6cecfdaab7ce260f122039f791816a15034839db4b1c1420e298ff9812fb60b633184a63db9c5c7f6089a4987
7
+ data.tar.gz: 187cfc2da14a076745c8d90905974e4518a014df37273b7e24057442fc6485cf8a7e3c313d4ac72b957d9c737370afec3d6955a5867cb8fb201fdcdd9f4cbf37
@@ -1,7 +1,10 @@
1
1
  module Parfait
2
2
 
3
3
  class Application
4
-
4
+
5
+ # List of all defined applications
6
+ @@all = Hash.new
7
+
5
8
  # Define an application
6
9
  #
7
10
  # *Options*
@@ -30,6 +33,22 @@ module Parfait
30
33
  set_browser(o[:browser])
31
34
 
32
35
  @pages = Hash.new
36
+ @@all[@name] = self
37
+ end
38
+
39
+
40
+ # Find an application object by name
41
+ #
42
+ # *Options*
43
+ #
44
+ # +name+:: specifies the name of the application to search for
45
+ #
46
+ # *Example*
47
+ #
48
+ # blog_app = Parfait::Application.find("Blog App")
49
+ #
50
+ def self.find(name)
51
+ @@all[name]
33
52
  end
34
53
 
35
54
 
@@ -63,6 +63,72 @@ module Parfait
63
63
  end
64
64
 
65
65
 
66
+ # Add this Control to a Page
67
+ #
68
+ # *Options*
69
+ #
70
+ # +page+:: specifies a Parfait::Page object to add this Control to
71
+ #
72
+ # *Example*
73
+ #
74
+ # loginpage = Parfait::Page.new(
75
+ # :name => "Login Page"
76
+ # )
77
+ # newcontrol = Parfait::Control.new(
78
+ # :name => "User ID",
79
+ # :logtext = "user ID"
80
+ # )
81
+ # newcontrol.add_to_page(loginpage)
82
+ #
83
+ def add_to_page(page)
84
+
85
+ if page
86
+ case
87
+ when page.is_a?(Parfait::Page)
88
+ page.add_control(self)
89
+ else
90
+ raise "Input value must be a Page object when adding this Control to a Page"
91
+ end
92
+ else
93
+ raise "Input value cannot be nil when adding this Control to a Page"
94
+ end
95
+ self
96
+ end
97
+
98
+
99
+ # Add this Control to a Region
100
+ #
101
+ # *Options*
102
+ #
103
+ # +region+:: specifies a Parfait::Region object to add this Control to
104
+ #
105
+ # *Example*
106
+ #
107
+ # user = Parfait::Region.new(
108
+ # :name => "User"
109
+ # )
110
+ # newcontrol = Parfait::Control.new(
111
+ # :name => "Edit User",
112
+ # :logtext = "edit user link"
113
+ # )
114
+ # user.add_to_region(newcontrol)
115
+ #
116
+ def add_to_region(region)
117
+
118
+ if region
119
+ case
120
+ when region.is_a?(Parfait::Region)
121
+ region.add_control(self)
122
+ else
123
+ raise "Input value must be a Region object when adding this Control to a Region"
124
+ end
125
+ else
126
+ raise "Input value cannot be nil when adding this Control to a Region"
127
+ end
128
+ self
129
+ end
130
+
131
+
66
132
  # Method description
67
133
  #
68
134
  # *Options*
data/lib/parfait/page.rb CHANGED
@@ -43,6 +43,43 @@ module Parfait
43
43
  end
44
44
 
45
45
 
46
+ # Add this Page to an Application
47
+ #
48
+ # If the specified application does not exist, it will be added
49
+ #
50
+ # *Options*
51
+ #
52
+ # +application+:: specifies the Application to add this page to, either via the String name or the Parfait::Application object
53
+ #
54
+ # *Example*
55
+ #
56
+ # mypage = Parfait::Page.new(
57
+ # :name => "Edit User"
58
+ # )
59
+ # mypage.add_to_application("Blogger")
60
+ #
61
+ def add_to_application(application)
62
+
63
+ if application
64
+ case
65
+ when application.is_a?(String)
66
+ app = Parfait::Application.find(application)
67
+ unless app
68
+ app = Parfait::Application.new(:name => application)
69
+ end
70
+ app.add_page(self)
71
+ when application.is_a?(Parfait::Application)
72
+ application.add_page(self)
73
+ else
74
+ raise "Input value must be a String or an Application object when adding this Page to an Application"
75
+ end
76
+ else
77
+ raise "Input value cannot be nil when when adding this Page to an Application"
78
+ end
79
+ self
80
+ end
81
+
82
+
46
83
  # Add a Region to the current Page
47
84
  #
48
85
  # *Options*
@@ -71,6 +71,68 @@ module Parfait
71
71
  end
72
72
 
73
73
 
74
+ # Add this Region to a Page
75
+ #
76
+ # *Options*
77
+ #
78
+ # +page+:: specifies a Parfait::Page object to add this Region to
79
+ #
80
+ # *Example*
81
+ #
82
+ # mypage = Parfait::Page.new(
83
+ # :name => "Edit User",
84
+ # :aliases => ["User Edit"]
85
+ # )
86
+ # region.add_to_page(mypage)
87
+ #
88
+ def add_to_page(page)
89
+
90
+ if page
91
+ case
92
+ when page.is_a?(Parfait::Page)
93
+ page.add_region(self)
94
+ else
95
+ raise "Input value must be a Page object when adding this Region to a Page"
96
+ end
97
+ else
98
+ raise "Input value cannot be nil when adding this Region to a Page"
99
+ end
100
+ self
101
+ end
102
+
103
+
104
+ # Add this Region to a Region
105
+ #
106
+ # *Options*
107
+ #
108
+ # +region+:: specifies a Parfait::Region object to add this Region to
109
+ #
110
+ # *Example*
111
+ #
112
+ # existing_region = Parfait::Region.new(
113
+ # :name => "User"
114
+ # )
115
+ # new_region = Parfait::Region.new(
116
+ # :name => "Roles"
117
+ # )
118
+ # new_region.add_to_region(existing_region)
119
+ #
120
+ def add_to_region(region)
121
+
122
+ if region
123
+ case
124
+ when region.is_a?(Parfait::Region)
125
+ region.add_region(self)
126
+ else
127
+ raise "Input value must be a Region object when adding this Region to another Region"
128
+ end
129
+ else
130
+ raise "Input value cannot be nil when adding this Region to another Region"
131
+ end
132
+ self
133
+ end
134
+
135
+
74
136
  # Set the filter for this Region to use.
75
137
  #
76
138
  # When a child of this Region is invoked, the Region will use this
data/lib/parfait.rb CHANGED
@@ -9,6 +9,7 @@ require 'parfait/control'
9
9
  #
10
10
  #
11
11
  # * Top level comment about Parfait
12
+
12
13
  module Parfait
13
14
 
14
15
  # Global hash containing each Parfait::Page object indexed by page name (and alias)
@@ -373,4 +374,29 @@ module Parfait
373
374
  end
374
375
 
375
376
 
377
+ # Store a Watir object as a filtered browser to be used by controls called within a Region
378
+ #
379
+ # *Options*
380
+ #
381
+ # none
382
+ #
383
+ # *Example*
384
+ #
385
+ # user_region = Parfait::Region.new(:name => "User")
386
+ # user_region.add_filter { |username|
387
+ # user_list = Parfait::browser.div(:id => "users")
388
+ # users = user_list.lis
389
+ # users.each do |li|
390
+ # if li.text == username
391
+ # Parfait::filter_browser li
392
+ # break
393
+ # end
394
+ # end
395
+ # }
396
+ #
397
+ def Parfait.filter_browser(object)()
398
+ Thread.current[:parfait_region] = object
399
+ end
400
+
401
+
376
402
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parfait
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Rotter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-03 00:00:00.000000000 Z
11
+ date: 2015-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -36,7 +36,7 @@ files:
36
36
  - lib/parfait/control.rb
37
37
  - lib/parfait/page.rb
38
38
  - lib/parfait/region.rb
39
- homepage: ''
39
+ homepage: https://github.com/jrotter/parfait
40
40
  licenses:
41
41
  - MIT
42
42
  metadata: {}