page_object_stubs 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7343fff9ae29dab31e7311a15f938b9b6429b65
4
- data.tar.gz: bc89e3acc327f9977e0c4f321ec715b7c4f69dbc
3
+ metadata.gz: 716c20c673742b01540464d83d5183e42c85b4b2
4
+ data.tar.gz: 95efba24aede01013c5097798e02e898aeba4141
5
5
  SHA512:
6
- metadata.gz: b9d4377cc5bdafc7c5041976a89645ae3b7f0fb46db4f9256038e9f8f330cca5c4fffdeee6cdfdddb10247721b85cb8036fe2fed92f93ea413d4d14176e8ba3b
7
- data.tar.gz: 15cf30dcc987cd87a7f8c8575ab7b921730f98b07568d6bae8ce102de437ba06bb0011e5b91b3b388ce32d031d9bc76b02ac858e7dc28d848ea6cf4fd8cd3641
6
+ metadata.gz: d47c10367e54726902fbb8766fb023b1639fe3a80fa3910bb42d8cab7b049b7d5f072748033667ddd21269527b23ef59866e842aec0bcc4e74c192ab51d7acb0
7
+ data.tar.gz: 6dadc68d3ded50285fbc3ae72a9be739ccef5b53bd2ee485f8ca7a410ffe3d7911a2a1569e32bebf4bf462328733e14653feae692af01858f62c3c0ea62ba3c1
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ sudo: false
2
2
  cache: bundler
3
3
  language: ruby
4
4
  rvm:
5
- - 2.2.2
5
+ - 2.2.3
6
6
  before_install: gem update --remote bundler
7
7
  install:
8
8
  - bundle install --retry=3
data/README.md CHANGED
@@ -7,20 +7,22 @@
7
7
  [PageObject](https://github.com/cheezy/page-object) stub generator for RubyMine.
8
8
 
9
9
  ```ruby
10
- targets = Dir.glob(File.join(__dir__, '..', 'page', '*_page.rb'))
11
- output_folder = File.join(__dir__, '..', 'stub')
12
- PageObjectStubs.generate targets: targets, output_folder: output_folder, angularjs: false
10
+ targets = Dir.glob(File.join(__dir__, '..', 'page', '*_page.rb'))
11
+ output = File.join(__dir__, '..', 'stub')
12
+ exclude = /#{Regexp.escape('base_page.rb')}/
13
+ PageObjectStubs.generate targets: targets, output: output, exclude: exclude
13
14
  ```
14
15
 
15
16
  ```ruby
16
17
  # Creates stubs from target Ruby files in output folder with the format
17
18
  # target_filename_stub.rb
18
19
  #
20
+ # Note the output folder is **DELETED** each time stubs are generated.
21
+ #
19
22
  # @param [Hash] opts
20
23
  # @option opts [Array<File>] :targets Array of target files to create stubs from (required)
21
- # @option opts [Dir] :output_folder Folder to create stubs in (required)
22
- # @option opts [Boolean] :angularjs Enable angularjs support (optional, default false)
23
- def generate opts={}
24
+ # @option opts [Dir] :output Folder to create stubs in (required)
25
+ # @option opts [Dir] :exclude Exclusion regex use to reject targets (optional)
24
26
  ```
25
27
 
26
28
  ## Contributing
@@ -1,5 +1,4 @@
1
1
  module PageObjectStubs
2
-
3
2
  class ProcessPageObjects < Parser::AST::Processor
4
3
 
5
4
  attr_reader :name_type_pairs
@@ -61,6 +60,15 @@ table_cell table_row text_area text_field unordered_list video] + %w[page_url]
61
60
  # the rest of the data is in the children.
62
61
  end
63
62
 
63
+ def on_def node
64
+ if node.is_a?(AST::Node)
65
+ c = node.children
66
+ return unless c
67
+ method_name = c.first
68
+ @name_type_pairs << [method_name] if method_name.class == Symbol
69
+ end
70
+ end
71
+
64
72
  def on_send node
65
73
  generate_send node
66
74
  super
@@ -3,22 +3,30 @@ module PageObjectStubs
3
3
  # Creates stubs from target Ruby files in output folder with the format
4
4
  # target_filename_stub.rb
5
5
  #
6
+ # Note the output folder is **DELETED** each time stubs are generated.
7
+ #
6
8
  # ```ruby
7
9
  # targets = Dir.glob(File.join(__dir__, '..', 'page', '*_page.rb'))
8
10
  # output = File.join(__dir__, '..', 'stub')
9
- # PageObjectStubs.generate targets: targets, output: output
11
+ # exclude = /#{Regexp.escape('base_page.rb')}/
12
+ # PageObjectStubs.generate targets: targets, output: output, exclude: exclude
10
13
  # ```
11
14
  #
12
15
  # @param [Hash] opts
13
16
  # @option opts [Array<File>] :targets Array of target files to create stubs from (required)
14
- # @option opts [Dir] :output_folder Folder to create stubs in (required)
17
+ # @option opts [Dir] :output Folder to create stubs in (required)
18
+ # @option opts [Dir] :exclude Exclusion regex use to reject targets (optional)
15
19
  def generate opts={}
16
20
  targets = opts.fetch(:targets)
17
21
  targets = targets.select do |target|
18
22
  File.file?(target) && File.readable?(target)
19
23
  end
20
24
 
21
- output_folder = File.expand_path(opts.fetch(:output_folder))
25
+ regex = opts.fetch(:exclude, false)
26
+ targets.reject! { |t| t.match regex } if regex
27
+
28
+ output_folder = File.expand_path(opts.fetch(:output))
29
+ FileUtils.rm_rf output_folder
22
30
  FileUtils.mkdir_p output_folder
23
31
 
24
32
  targets.each do |f|
@@ -35,28 +43,34 @@ module Stub
35
43
  module #{file_module_name}
36
44
  class << self
37
45
  R
38
- output = ''
46
+ data = ''
39
47
 
40
48
  def wrap method_name
41
49
  ' ' * 6 + "def #{method_name}; fail('stub called!'); end" + "\n"
42
50
  end
43
51
 
44
52
  page_objects.name_type_pairs.each do |pair|
53
+ # process custom methods that aren't defined in page_object
54
+ if pair.length == 1
55
+ data += wrap "#{pair.first}(*args)"
56
+ next
57
+ end
58
+
45
59
  element_type = pair.first
46
60
  # if 'page_url' exists, then we need `def goto`
47
61
  # for all others, we need the name of the element to generate the remaining methods.
48
62
  if element_type == 'page_url'
49
- output += wrap 'goto'
63
+ data += wrap 'goto'
50
64
  next
51
65
  end
52
66
 
53
67
  element_name = pair.last
54
68
 
55
- output += wrap "#{element_name}"
56
- output += wrap "#{element_name}_element"
57
- output += wrap "#{element_name}?"
69
+ data += wrap "#{element_name}"
70
+ data += wrap "#{element_name}_element"
71
+ data += wrap "#{element_name}?"
58
72
 
59
- output += wrap "#{element_name}=" if element_type == 'text_field'
73
+ data += wrap "#{element_name}=" if element_type == 'text_field'
60
74
  end
61
75
 
62
76
 
@@ -83,10 +97,10 @@ module RSpec
83
97
  end
84
98
  R
85
99
 
86
- output = output_prefix + output + output_postfix
100
+ data = output_prefix + data + output_postfix
87
101
 
88
102
  File.open(stub_file, 'w') do |file|
89
- file.write output
103
+ file.write data
90
104
  end
91
105
  end
92
106
  end
@@ -7,22 +7,25 @@ module PageObjectStubs
7
7
  # @option opts [String] :task_name the name of the stubs task (optional)
8
8
  # @option opts [String] :task_desc the description of the stubs task (optional)
9
9
  # @option opts [lambda] :targets lambda that will return an array of targets (optional)
10
- # @option opts [lambda] :output_folder lambda that will return the output folder (optional)
10
+ # @option opts [lambda] :output lambda that will return the output folder (optional)
11
11
  def add_stubs_task opts={}
12
- task_name = opts.fetch(:task_name, 'stubs')
13
- task_desc = opts.fetch(:task_desc, 'Generate stubs')
12
+ task_name = opts.fetch(:task_name, 'stubs')
13
+ task_desc = opts.fetch(:task_desc, 'Generate stubs')
14
14
 
15
15
  # Get the dir that contains the Rakefile via Rake (__dir__ will not work)
16
- targets = opts.fetch(:targets, lambda { Dir.glob(File.join(Rake.application.original_dir, 'page', '*_page.rb')) })
17
- output_folder = opts.fetch(:output_folder, lambda { File.join(Rake.application.original_dir, 'helper', 'stub') })
16
+ targets = opts.fetch(:targets, lambda { Dir.glob(File.join(Rake.application.original_dir, 'page', '*_page.rb')) })
17
+ output = opts.fetch(:output, lambda { File.join(Rake.application.original_dir, 'helper', 'stub') })
18
+ exclude = opts.fetch(:exclude, false)
18
19
 
19
20
  raise 'targets must be a lambda' unless targets.lambda?
20
- raise 'output_folder must be a lambda' unless output_folder.lambda?
21
+ raise 'output must be a lambda' unless output.lambda?
22
+ raise 'exclude must be a regex' if exclude && exclude.class != Regexp
21
23
 
22
24
  Rake.application.last_description = task_desc
23
25
  Rake::Task.define_task task_name do
24
- PageObjectStubs.generate targets: targets.call,
25
- output_folder: output_folder.call
26
+ PageObjectStubs.generate targets: targets.call,
27
+ output: output.call,
28
+ exclude: exclude
26
29
  end
27
30
  end
28
31
  end
@@ -1,4 +1,4 @@
1
1
  module PageObjectStubs
2
- VERSION = '1.0.1' unless defined? ::PageObjectStubs::VERSION
3
- DATE = '2015-06-19' unless defined? ::PageObjectStubs::DATE
2
+ VERSION = '2.0.0' unless defined? ::PageObjectStubs::VERSION
3
+ DATE = '2015-09-24' unless defined? ::PageObjectStubs::DATE
4
4
  end
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.add_runtime_dependency 'parser', '~> 2.2.2.2'
20
20
 
21
21
  spec.add_development_dependency 'pry', '~> 0.10.1'
22
- spec.add_development_dependency 'appium_thor', '~> 0.0.7'
23
- spec.add_development_dependency 'rspec', '~> 3.2.0'
24
- spec.add_development_dependency 'bundler', '~> 1.9'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'coveralls', '~> 0.8.1'
22
+ spec.add_development_dependency 'appium_thor', '~> 1.0.1'
23
+ spec.add_development_dependency 'rspec', '~> 3.3.0'
24
+ spec.add_development_dependency 'bundler', '~> 1.10.6'
25
+ spec.add_development_dependency 'rake', '~> 10.4.2'
26
+ spec.add_development_dependency 'coveralls', '~> 0.8.2'
27
27
  end
data/release_notes.md CHANGED
@@ -1,3 +1,13 @@
1
+ #### v2.0.0 2015-09-24
2
+
3
+ - [8c5f194](https://github.com/bootstraponline/page_object_stubs/commit/8c5f1947d717aa0c8e434e1e26570375170090ab) Release 2.0.0
4
+ - [e3e02a2](https://github.com/bootstraponline/page_object_stubs/commit/e3e02a25ad58e02721dd8a74343fc8de372b6ea6) Update readme
5
+ - [00cb6fc](https://github.com/bootstraponline/page_object_stubs/commit/00cb6fc371bd10778c85697dfd98069092cc03b9) Add exclude regex
6
+ - [f12a90c](https://github.com/bootstraponline/page_object_stubs/commit/f12a90cbcd190bcad7d2ddc01cec5ce755c0e088) Always remove old stubs
7
+ - [b15a9c4](https://github.com/bootstraponline/page_object_stubs/commit/b15a9c4dacee4b0a7e1b3696fe74709ba3988e79) Enable stubbing of regular methods
8
+ - [aa797d4](https://github.com/bootstraponline/page_object_stubs/commit/aa797d4dfb694f8e454ad821063408431a557ee5) Update dependencies
9
+
10
+
1
11
  #### v1.0.1 2015-06-19
2
12
 
3
13
  - [bb715a0](https://github.com/bootstraponline/page_object_stubs/commit/bb715a0db3bdf9822d566d1b4486deac616a529d) Release 1.0.1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_object_stubs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-19 00:00:00.000000000 Z
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -44,70 +44,70 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.0.7
47
+ version: 1.0.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.0.7
54
+ version: 1.0.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.2.0
61
+ version: 3.3.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.2.0
68
+ version: 3.3.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.9'
75
+ version: 1.10.6
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.9'
82
+ version: 1.10.6
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: 10.4.2
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: 10.4.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: coveralls
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.8.1
103
+ version: 0.8.2
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.8.1
110
+ version: 0.8.2
111
111
  description: PageObject stub generator for RubyMine.
112
112
  email:
113
113
  - code@bootstraponline.com
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  requirements: []
152
152
  rubyforge_project:
153
- rubygems_version: 2.4.6
153
+ rubygems_version: 2.4.8
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: PageObject stub generator for RubyMine