rubyn 0.1.6 → 0.1.7

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
  SHA256:
3
- metadata.gz: 0f569a00574395ca84d1262fe5e1b1e43ae3a9f45cbad8bcd635b5f77bc8f964
4
- data.tar.gz: b649ccb9d369f8d043c7894a2e203aa2de135b5696f0ba3385d58d9cf104595d
3
+ metadata.gz: b608a9d2f94acf82de5f6867e77deb5c718d0181014b90bc2438fb2a77be159c
4
+ data.tar.gz: 60fef63b740da2e1d133123b94baf2fe10a42965b676451265e38c27b7f51d44
5
5
  SHA512:
6
- metadata.gz: fba7fe70671bbd022cee098572ce9afa1fe5e936983321a7ab04dde76ef088014ac5adad49baa5d9cdb3ea3ee0aa107a36ce5f44c91113dfdc8643fac799c3d6
7
- data.tar.gz: d64d44658a121a84810c8c659ecf94b71310b6a5f5d88a6954b5301869f2422a2b968001b1fd8612b664b892426fa8b6d769a5eeb15e61610f4724d7ac63f887
6
+ metadata.gz: e681790e738cb8ef39ff1722ae8693b8491aa63e402b21842501480a1b1e14b41b4717b746362b9d3d847725760b264284d6f6c2ce51a152f5db4eabdb178465
7
+ data.tar.gz: ebf58936f9b3699c192934819cd872fa4f58d5d3e8428bc98b2b3c8bc3f683dbea65a5a192958338911287e3115cef7da3378cc8a73d32c904d78443d6054b0e
@@ -17,7 +17,7 @@ module Rubyn
17
17
  VALID_BRANCH_PATTERN = %r{\A[a-zA-Z0-9\-_/]+\z}
18
18
 
19
19
  def execute(params)
20
- branch_name = params[:branch_name]
20
+ branch_name = params[:branch_name] || params[:name]
21
21
  return error("branch_name is required") unless branch_name && !branch_name.strip.empty?
22
22
 
23
23
  unless branch_name.match?(VALID_BRANCH_PATTERN)
@@ -22,18 +22,21 @@ module Rubyn
22
22
  return error("File not found: #{params[:path]}") unless File.exist?(resolved)
23
23
 
24
24
  content = File.read(resolved)
25
- find = params[:find]
25
+ find = params[:find] || params[:old_text]
26
+ replace = params[:replace] || params[:new_text]
26
27
 
28
+ return error("Missing find/old_text parameter") unless find
29
+ return error("Missing replace/new_text parameter") unless replace
27
30
  return error("Find string not found in file: #{params[:path]}") unless content.include?(find)
28
31
 
29
32
  all_occurrences = params[:all_occurrences] || false
30
33
 
31
34
  if all_occurrences
32
35
  replacements = content.scan(find).length
33
- new_content = content.gsub(find, params[:replace])
36
+ new_content = content.gsub(find, replace)
34
37
  else
35
38
  replacements = 1
36
- new_content = content.sub(find, params[:replace])
39
+ new_content = content.sub(find, replace)
37
40
  end
38
41
 
39
42
  File.write(resolved, new_content)
@@ -18,7 +18,10 @@ module Rubyn
18
18
  command = detect_test_command
19
19
  return error("No test framework detected (no spec/ or test/ directory found)") unless command
20
20
 
21
- command = "#{command} #{params[:path]}" if params[:path] && !params[:path].strip.empty?
21
+ # Accept both gem params (path) and API params (files array)
22
+ test_path = params[:path]
23
+ test_path ||= Array(params[:files]).join(" ") if params[:files]
24
+ command = "#{command} #{test_path}" if test_path && !test_path.strip.empty?
22
25
  command = "#{command} #{params[:options]}" if params[:options] && !params[:options].strip.empty?
23
26
 
24
27
  begin
@@ -16,16 +16,17 @@ module Rubyn
16
16
  MAX_FILE_SIZE = 2_000_000
17
17
 
18
18
  def execute(params)
19
- return error("Missing required parameter: pattern") unless params[:pattern]
19
+ query = params[:pattern] || params[:query]
20
+ return error("Missing required parameter: pattern") unless query
20
21
 
21
22
  begin
22
- regex = Regexp.new(params[:pattern])
23
+ regex = Regexp.new(query)
23
24
  rescue RegexpError => e
24
25
  return error("Invalid regex pattern: #{e.message}")
25
26
  end
26
27
 
27
28
  search_path = params[:path] || "."
28
- file_pattern = params[:file_pattern]
29
+ file_pattern = params[:file_pattern] || params[:include]
29
30
 
30
31
  resolved = resolve_path(search_path)
31
32
  return resolved if resolved.is_a?(Hash) && resolved[:error]
data/lib/rubyn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubyn
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - matthewsuttles