ruby_raider 0.9.5 → 0.9.7

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
  SHA256:
3
- metadata.gz: 279c26bb0d8d1a27d95b0510587e6828e2164c84a334c41b84b57db98f04867c
4
- data.tar.gz: c024426fe0bbb58b912ac6bf07a0867110dc340c4946d4e3eab499e25a38b2ce
3
+ metadata.gz: b3d8b8446c9a14c729920a9ffe1c1452a2cfee0be1f13358ce3444716c0d95f3
4
+ data.tar.gz: 97e9143f2c0206044a1d59dccf4348fa6f65be3ad474db1dab8986295363cd8d
5
5
  SHA512:
6
- metadata.gz: '028fcaca7bd181054203e2d50d54fa2399608725379ffd63e003f2efd43f9b6274fa9a014e7ffb0da28eff2f077b48fb4d4d6ae5c53f3db9f14f1958f4e451e4'
7
- data.tar.gz: 9ef33293321c2f08b1942c2c82d2bc0be57f9245335be00bcefe4d145a5c7abb842e5274ba313e21dec17e756cbf6fc4f9fa7f4d74887e630791a4ae0adbde91
6
+ metadata.gz: 369c1dac85b41e583ad2f436bab89a3e355085f57ec2c0e243639fcc7fda39fc6a6d4845bc768eeaabaf103708d8b5832ecc3e7530df3af13e12ffd63f60e4fe
7
+ data.tar.gz: 2b21dade88f2ccfe1a9e4c18f608544fdf3d88c15377f35bad42ad341a1ae5c8437737b322ec89f0efbfb4c52b5d89ffb029c937e6ec20856d7692198451f97e
data/README.md CHANGED
@@ -10,12 +10,9 @@
10
10
  <br />
11
11
  <div align="center">
12
12
  <a href="https://github.com/RubyRaider/ruby_raider">
13
- <img src="https://rubyraiderdotcom.files.wordpress.com/2022/05/logo_transparent_background-1.png" alt="Logo">
13
+ <img src="https://ruby-raider.com/wp-content/uploads/2022/05/logo-160x160.png?w=890" alt="Logo" style="width:600px;">
14
14
  </a>
15
- <h1 align="center">Ruby Raider</h1>
16
15
  <p align="center">
17
- This is a gem to make setup and start of UI automation projects easier.
18
- <br />
19
16
  <a href="https://github.com/RubyRaider/ruby_raider#getting-started"><strong>Explore the docs »</strong></a>
20
17
  <br />
21
18
  <br />
@@ -85,13 +82,13 @@ Select the ones you will like to work with.
85
82
  If you already know which frameworks you want to use, you can do:
86
83
 
87
84
  ```ruby
88
- raider new [name_of_project] - p framework : [framework] automation : [automation_type] visual : [boolean] axe : [boolean]
85
+ raider new [name_of_project] p framework : [framework] automation : [automation_type]
89
86
  ```
90
87
 
91
88
  An example of the command above would be:
92
89
 
93
90
  ```ruby
94
- raider new test_project -p framework : rspec automation: selenium visual : false axe : true
91
+ raider new test_project p framework : rspec automation: selenium
95
92
  ```
96
93
 
97
94
  Where [frameworks] is a comma separated list of the frameworks you want to use.
@@ -102,7 +99,7 @@ Where [frameworks] is a comma separated list of the frameworks you want to use.
102
99
 
103
100
  ```ruby
104
101
  Commands :
105
- raider generate # Provides access to all the scaffolding commands
102
+ raider generate # Provides access to all the scaffolding commands
106
103
  raider help [COMMAND] # Describe available commands or one specific command
107
104
  raider new [PROJECT_NAME] # Creates a new framework based on settings picked
108
105
  raider utility # Provides access to all the utility commands
@@ -126,15 +123,15 @@ Ruby Raider also supports scaffolding:
126
123
  * To create a new steps definition you do: ```raider g steps [STEPS_NAME]```
127
124
  * To create both a page/spec or a page/feature/steps you do: ```raider g scaffold [SCAFFOLD_NAME]```
128
125
 
129
- It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
126
+ It's possible to add the option --path or p if you want to specify where to create your features, pages, helpers and
130
127
  specs.
131
128
 
132
129
  If you want to set the default path for the creation of your features, helpers and specs:
133
130
 
134
131
  ```ruby
135
- raider u path [PATH_NAME] - -feature or -f
136
- raider u path [PATH_NAME] - -spec or -s
137
- raider u path [PATH_NAME] - -helper or -h
132
+ raider u path [PATH_NAME] - -feature or f
133
+ raider u path [PATH_NAME] - -spec or s
134
+ raider u path [PATH_NAME] - -helper or h
138
135
  ```
139
136
 
140
137
  If you don't specify an option, path will assume you want to change the default path for pages.
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require_relative '../plugin/plugin'
5
+
6
+ module RubyRaider
7
+ class LoadedCommands < Thor
8
+ end
9
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require_relative '../plugin/plugin'
5
+
6
+ module RubyRaider
7
+ # :reek:FeatureEnvy { enabled: false }
8
+ # :reek:UtilityFunction { enabled: false }
9
+ class PluginCommands < Thor
10
+ desc 'add [NAME]', 'Adds a plugin to your project'
11
+
12
+ def add(plugin_name)
13
+ Plugin.add_plugin(plugin_name)
14
+ end
15
+
16
+ desc 'delete [NAME]', 'Deletes a plugin from your project'
17
+
18
+ def delete(plugin_name)
19
+ Plugin.delete_plugin(plugin_name)
20
+ end
21
+
22
+ desc 'local', 'Lists all the plugin in your project'
23
+
24
+ def local
25
+ pp Plugin.installed_plugins
26
+ end
27
+
28
+ desc 'list', 'Lists all the available plugin'
29
+
30
+ def list
31
+ pp Plugin.available_plugins
32
+ end
33
+ end
34
+ end
@@ -84,11 +84,15 @@ class MenuGenerator
84
84
  end
85
85
 
86
86
  def select_automation_framework(menu)
87
+ automation_options(menu)
88
+ menu.choice :Quit, -> { exit }
89
+ end
90
+
91
+ def automation_options(menu)
87
92
  menu.choice :Selenium, -> { choose_test_framework('selenium') }
88
93
  menu.choice :Appium, -> { choose_test_framework('appium') }
89
94
  menu.choice :Watir, -> { choose_test_framework('watir') }
90
95
  menu.choice :Applitools, -> { choose_test_framework('applitools') }
91
96
  menu.choice :Axe, -> { choose_test_framework('axe') }
92
- menu.choice :Quit, -> { exit }
93
97
  end
94
98
  end
@@ -4,12 +4,9 @@
4
4
  <br />
5
5
  <div align="center">
6
6
  <a href="https://github.com/RubyRaider/ruby_raider">
7
- <img src="https://rubyraiderdotcom.files.wordpress.com/2022/05/logo_transparent_background-1.png" alt="Logo">
7
+ <img src="https://ruby-raider.com/wp-content/uploads/2022/05/logo-160x160.png?w=890" alt="Logo" style="width:600px;">
8
8
  </a>
9
- <h1 align="center">Ruby Raider</h1>
10
9
  <p align="center">
11
- This is a gem to make setup and start of UI automation projects easier.
12
- <br />
13
10
  <a href="https://github.com/RubyRaider/ruby_raider#getting-started"><strong>Explore the docs »</strong></a>
14
11
  <br />
15
12
  <br />
@@ -79,13 +76,13 @@ Select the ones you will like to work with.
79
76
  If you already know which frameworks you want to use, you can do:
80
77
 
81
78
  ```ruby
82
- raider new [name_of_project] - p framework : [framework] automation : [automation_type] visual : [boolean] axe : [boolean]
79
+ raider new [name_of_project] p framework : [framework] automation : [automation_type]
83
80
  ```
84
81
 
85
82
  An example of the command above would be:
86
83
 
87
84
  ```ruby
88
- raider new test_project -p framework : rspec automation: selenium visual : false axe : true
85
+ raider new test_project p framework : rspec automation: selenium
89
86
  ```
90
87
 
91
88
  Where [frameworks] is a comma separated list of the frameworks you want to use.
@@ -120,15 +117,15 @@ Ruby Raider also supports scaffolding:
120
117
  * To create a new steps definition you do: ```raider g steps [STEPS_NAME]```
121
118
  * To create both a page/spec or a page/feature/steps you do: ```raider g scaffold [SCAFFOLD_NAME]```
122
119
 
123
- It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
120
+ It's possible to add the option --path or p if you want to specify where to create your features, pages, helpers and
124
121
  specs.
125
122
 
126
123
  If you want to set the default path for the creation of your features, helpers and specs:
127
124
 
128
125
  ```ruby
129
- raider u path [PATH_NAME] - -feature or -f
130
- raider u path [PATH_NAME] - -spec or -s
131
- raider u path [PATH_NAME] - -helper or -h
126
+ raider u path [PATH_NAME] - -feature or f
127
+ raider u path [PATH_NAME] - -spec or s
128
+ raider u path [PATH_NAME] - -helper or h
132
129
  ```
133
130
 
134
131
  If you don't specify an option, path will assume you want to change the default path for pages.
@@ -139,4 +136,4 @@ To initialise Appium server run this command:
139
136
 
140
137
  ```ruby
141
138
  raider u start_appium
142
- ```
139
+ ```
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require_relative 'plugin_exposer'
5
+
6
+ module RubyRaider
7
+ module Plugin
8
+ class << self
9
+ def add_plugin(plugin_name)
10
+ return pp 'The plugin was not found' unless available?(plugin_name)
11
+ return pp 'The plugin is already installed' if installed?(plugin_name)
12
+
13
+ pp "Adding #{plugin_name}..."
14
+ add_plugin_to_gemfile(plugin_name)
15
+ system('bundle install')
16
+ PluginExposer.expose_commands(plugin_name)
17
+ pp "The plugin #{plugin_name} is added"
18
+ end
19
+
20
+ def delete_plugin(plugin_name)
21
+ return 'The plugin is not installed' unless installed_plugins.include?(plugin_name)
22
+
23
+ pp "Deleting #{plugin_name}..."
24
+ remove_plugin_from_gemfile(plugin_name)
25
+ PluginExposer.remove_command(plugin_name)
26
+ system('bundle install')
27
+ pp "The plugin #{plugin_name} is deleted"
28
+ end
29
+
30
+ def installed_plugins
31
+ parsed_gemfile = File.readlines('Gemfile').map { |line| line.sub('gem ', '').strip.delete("'") }
32
+ parsed_gemfile.select { |line| available_plugins.include?(line) }
33
+ end
34
+
35
+ def available_plugins
36
+ plugins['plugins']
37
+ end
38
+
39
+ def installed?(plugin_name)
40
+ installed_plugins.include?(plugin_name)
41
+ end
42
+
43
+ def available?(plugin_name)
44
+ available_plugins.include?(plugin_name)
45
+ end
46
+
47
+ def camelize(str)
48
+ str.split('_').collect(&:capitalize).join
49
+ end
50
+
51
+ private
52
+
53
+ def add_plugin_to_gemfile(plugin_name)
54
+ File.open('Gemfile', 'a') do |file|
55
+ file.puts "\n# Ruby Raider Plugins\n" unless comment_present?
56
+ file.puts "gem '#{plugin_name}'" unless plugin_present?(plugin_name)
57
+ end
58
+ end
59
+
60
+ def remove_plugin_from_gemfile(plugin_name)
61
+ output_lines = remove_plugins_and_comments(plugin_name)
62
+ update_gemfile(output_lines)
63
+ end
64
+
65
+ def last_plugin?
66
+ installed_plugins.count == 1
67
+ end
68
+
69
+ def plugins
70
+ @plugins ||= YAML.load_file(File.expand_path('plugins.yml'))
71
+ end
72
+
73
+ def read_gemfile
74
+ File.readlines('Gemfile')
75
+ end
76
+
77
+ def comment_present?
78
+ read_gemfile.grep(/Ruby Raider Plugins/).any?
79
+ end
80
+
81
+ def plugin_present?(plugin_name)
82
+ read_gemfile.grep(/#{plugin_name}/).any?
83
+ end
84
+
85
+ def remove_plugins_and_comments(plugin_name)
86
+ read_gemfile.reject do |line|
87
+ line.include?(plugin_name) || line.include?('Ruby Raider Plugins') && last_plugin?
88
+ end
89
+ end
90
+
91
+ # :reek:NestedIterators { enabled: false }
92
+ def update_gemfile(output_lines)
93
+ File.open('Gemfile', 'w') do |file|
94
+ output_lines.each { |line| file.puts line }
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../plugin/plugin'
4
+
5
+ module RubyRaider
6
+ module PluginExposer
7
+ class << self
8
+ FILE_PATH = File.expand_path('../commands/loaded_commands.rb', __dir__)
9
+ # :reek:NestedIterators { enabled: false }
10
+ def expose_commands(plugin_name)
11
+ return pp 'The plugin is already installed' if plugin_present?(plugin_name)
12
+
13
+ commands = read_loaded_commands
14
+
15
+ File.open(FILE_PATH, 'w') do |file|
16
+ commands.each do |line|
17
+ file.puts line
18
+ file.puts require_plugin(plugin_name, line)
19
+ file.puts select_command_formatting(plugin_name, line)
20
+ end
21
+ end
22
+ end
23
+
24
+ def remove_command(plugin_name)
25
+ return pp 'The plugin is not installed' unless plugin_present?(plugin_name)
26
+
27
+ delete_plugin_command(plugin_name)
28
+ end
29
+
30
+ private
31
+
32
+ def any_commands?
33
+ read_loaded_commands.any? { |line| line.include?('subcommand') }
34
+ end
35
+
36
+ def read_loaded_commands
37
+ File.readlines(FILE_PATH)
38
+ end
39
+
40
+ def formatted_command_without_space(plugin_name)
41
+ "desc '#{plugin_name}', 'Provides access to all the commands for #{plugin_name}'\n" \
42
+ "subcommand '#{plugin_name}', #{Plugin.camelize(plugin_name)}::PluginCommands"
43
+ end
44
+
45
+ def formatted_command_with_space(plugin_name)
46
+ "\n#{formatted_command_without_space(plugin_name)}"
47
+ end
48
+
49
+ def plugin_present?(plugin_name)
50
+ read_loaded_commands.grep(/#{plugin_name}/).any?
51
+ end
52
+
53
+ def select_command_formatting(plugin_name, line)
54
+ if line.strip == 'class LoadedCommands < Thor' && !any_commands?
55
+ formatted_command_without_space(plugin_name)
56
+ elsif any_commands?
57
+ formatted_command_with_space(plugin_name)
58
+ end
59
+ end
60
+
61
+ def require_plugin(plugin_name, line)
62
+ "require '#{plugin_name}'" if line.include?("require 'thor'") && !plugin_present?(plugin_name)
63
+ end
64
+
65
+ # :reek:NestedIterators { enabled: false }
66
+ def delete_plugin_command(plugin_name)
67
+ output_lines = read_loaded_commands.reject do |line|
68
+ line.include?(plugin_name) if plugin_present?(plugin_name)
69
+ end
70
+
71
+ File.open(FILE_PATH, 'w') do |file|
72
+ output_lines.each { |line| file.puts line }
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
data/lib/ruby_raider.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../lib/plugin/plugin'
4
+ require_relative '../lib/commands/plugin_commands'
5
+ require_relative '../lib/commands/loaded_commands'
3
6
  require_relative '../lib/commands/scaffolding_commands'
4
7
  require_relative '../lib/commands/utility_commands'
5
8
 
@@ -7,9 +10,19 @@ require_relative '../lib/commands/utility_commands'
7
10
  # :reek:UtilityFunction { enabled: false }
8
11
  module RubyRaider
9
12
  class Raider < Thor
13
+ no_tasks do
14
+ def self.plugin_commands?
15
+ File.readlines(File.expand_path('commands/loaded_commands.rb', __dir__)).any? do |line|
16
+ line.include?('subcommand')
17
+ end
18
+ end
19
+
20
+ def current_version = File.read(File.expand_path('version', __dir__)).strip
21
+ end
22
+
10
23
  desc 'new [PROJECT_NAME]', 'Creates a new framework based on settings picked'
11
24
  option :parameters,
12
- type: :hash, required: false, desc: 'Parameters to avoid using the menu', aliases: '-p'
25
+ type: :hash, required: false, desc: 'Parameters to avoid using the menu', aliases: 'p'
13
26
 
14
27
  def new(project_name)
15
28
  params = options[:parameters]
@@ -22,7 +35,7 @@ module RubyRaider
22
35
  MenuGenerator.new(project_name).generate_choice_menu
23
36
  end
24
37
 
25
- map '-n' => 'new'
38
+ map 'n' => 'new'
26
39
 
27
40
  desc 'version', 'It shows the version of Ruby Raider you are currently using'
28
41
 
@@ -40,8 +53,14 @@ module RubyRaider
40
53
  subcommand 'utility', UtilityCommands
41
54
  map 'u' => 'utility'
42
55
 
43
- no_commands do
44
- def current_version = File.read(File.expand_path('version', __dir__)).strip
56
+ desc 'plugin_manager', 'Provides access to all the commands to manager your plugins'
57
+ subcommand 'plugin_manager', PluginCommands
58
+ map 'pm' => 'plugin_manager'
59
+
60
+ if plugin_commands?
61
+ desc 'plugins', 'loaded plugin commands'
62
+ subcommand 'plugins', LoadedCommands
63
+ map 'ps' => 'plugins'
45
64
  end
46
65
  end
47
66
  end
data/lib/version CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 0.9.7
data/plugins.yml ADDED
@@ -0,0 +1,2 @@
1
+ plugins:
2
+ - great_axe
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_raider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustin Pequeno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-23 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -149,6 +149,8 @@ files:
149
149
  - README.md
150
150
  - Rakefile
151
151
  - bin/raider
152
+ - lib/commands/loaded_commands.rb
153
+ - lib/commands/plugin_commands.rb
152
154
  - lib/commands/scaffolding_commands.rb
153
155
  - lib/commands/utility_commands.rb
154
156
  - lib/generators/actions/actions_generator.rb
@@ -221,6 +223,8 @@ files:
221
223
  - lib/generators/templates/helpers/spec_helper.tt
222
224
  - lib/generators/templates/helpers/visual_helper.tt
223
225
  - lib/generators/templates/helpers/visual_spec_helper.tt
226
+ - lib/plugin/plugin.rb
227
+ - lib/plugin/plugin_exposer.rb
224
228
  - lib/ruby_raider.rb
225
229
  - lib/scaffolding/scaffolding.rb
226
230
  - lib/scaffolding/templates/feature.tt
@@ -231,6 +235,7 @@ files:
231
235
  - lib/utilities/logger.rb
232
236
  - lib/utilities/utilities.rb
233
237
  - lib/version
238
+ - plugins.yml
234
239
  - ruby_raider.gemspec
235
240
  - spec/integration/commands/scaffolding_commands_spec.rb
236
241
  - spec/integration/commands/utility_commands_spec.rb