claiss 1.0.10 → 1.1.1

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: 5ef3d4170f9601194f42c8a03c6089aad440bda98a91ebce1b3a8d84a3ae21bd
4
- data.tar.gz: 5386b3b64754fb15f7db09e85c0f6bfd53aa46ad9299ef905b7ad61ca7265d8c
3
+ metadata.gz: 4676e0b9c189aef43c1e7fc47b8335e6b06326a7037b8c5c8bc43d546fec9e03
4
+ data.tar.gz: 1b0aced8f24d95a68a9b3b378d70562020d9c1b0f32be955e5d7b98f291e4fe9
5
5
  SHA512:
6
- metadata.gz: 788da6b6055fda32c443db38ce8cb4fa88057e4ca2f50560814b938adb02bec9b913fb068f1b7ae2afa09e6a8f9607cd52ca4bd91a308422e02ca728c9ce95b0
7
- data.tar.gz: eee327c7ba60ba69ca65ed6672b7ebc886ede89a49cf1085c9bf75d9537b0364abd0401e507a8d33bfec7e8d552ec1d05511014bc71d19b87f7fa344b0697db3
6
+ metadata.gz: daaec06de788e6d5710b17094fcb7948365fdec7099fff35da7a89dfe4aba78bff7ef9b1114836196eddfba7b490bb7d42177248d39778006516b0879c5ef55d
7
+ data.tar.gz: b8f1c356aa5f6d8b1b94bed86c085b8f6035fa1fd324d945c1879a0cd2de29141c36854b1ca4a13cfc89b9b04f6a3b1107373a21ad0b7a496ba3fdb1ad12c61e
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2024 Júlio Papel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # CLAISS AI CLI Application Toolbox
2
+
3
+ CLAISS is a Ruby CLI application & Toolbox to manage CLAISS AI applications and deployments. Please note that some features may not work in all environments. Use with caution!
4
+
5
+ ## Installation
6
+
7
+ Install the gem by running the following command in your terminal:
8
+
9
+ Copy
10
+
11
+ `$ gem install claiss`
12
+
13
+ ## Usage
14
+
15
+ ### Refactor
16
+
17
+ The `refactor` command changes text terms in files within a folder, creating a new "refactored-..." folder with the modified files. Note that this command will change all exact occurrences of the specified terms. For example, "Abc" is treated differently from "AbC " or " ABc" or "abc" or "ABC".
18
+
19
+ Basic usage:
20
+
21
+ Copy
22
+
23
+ `$ claiss refactor ./project/`
24
+
25
+ #### Using a JSON Dictionary
26
+
27
+ You can create a JSON file with a list of terms to refactor. This file should be formatted as a one-level JSON object. The terms are processed in order from top to bottom.
28
+
29
+ Example `myapp.json` file:
30
+
31
+ Copy
32
+
33
+ `{ "system pro": "system b2b", "System Pro": "System B2b", "System": "Laiss", "system": "laiss", "2010 Moevo Silver": "2023 Júlio Papel", "Jared Moevo": "Júlio Papel", "3dtester@gmail.com": "info@mynewsite.pt", "https://somelivesite.com": "https://api.mynewsite.pt", "This is your Rails project.": "Multi Layered Software Services.", "This is your Rails project for your business.": "A Multi Layered Software Services ready to be deployed for any business.", "MIT-LICENSE": "LICENSE", "https://somesite.com": "https://api.mynewsite.pt" }`
34
+
35
+ To use this dictionary file:
36
+
37
+ Copy
38
+
39
+ `$ claiss refactor ./project/ ./myapp.json`
40
+
41
+ ### Fix Ruby Permissions
42
+
43
+ The `fix_ruby_permissions` command adjusts file permissions for a Ruby & Rails project:
44
+
45
+ Copy
46
+
47
+ `$ claiss fix_ruby_permissions ./refactored-1688375056/`
48
+
49
+ **Note:** This command uses `chmod` and may not work correctly on systems that support filename spaces and ignore capitals (like some end-user operating systems). For example, a file called 'MyImage copy.svg' may cause errors. In such cases, manually fix the permissions for problematic files and then re-run the command.
50
+
51
+ ## Upcoming Features
52
+
53
+ We're continually working to improve CLAISS and add new functionalities. Stay tuned for updates!
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/JulioPapel/claiss](https://github.com/JulioPapel/claiss).
58
+
59
+ ## License
60
+
61
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
62
+
63
+ ## Author
64
+
65
+ Júlio Papel
data/exe/claiss CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "dry/cli"
4
- require 'claiss'
5
- Dry::CLI.new(Claiss).call
3
+ require "claiss"
4
+ CLAISS::CLI.call
data/lib/claiss/cli.rb ADDED
@@ -0,0 +1,7 @@
1
+ module CLAISS
2
+ class CLI
3
+ def self.call(*args)
4
+ Dry::CLI.new(CLAISS::Commands).call(*args)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module CLAISS
2
+ module Commands
3
+ extend Dry::CLI::Registry
4
+
5
+ register "version", Version, aliases: ["v", "-v", "--version"]
6
+ register "refactor", Refactor
7
+ register "fix_ruby_permissions", FixRubyPermissions
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module CLAISS
2
+ VERSION = "1.1.1"
3
+ end
data/lib/claiss.rb CHANGED
@@ -1,95 +1,108 @@
1
1
  require "bundler/setup"
2
2
  require "dry/cli"
3
3
  require "fileutils"
4
- require "pathname"
5
- require 'find'
6
4
  require 'json'
7
5
 
8
- module Claiss
9
- extend Dry::CLI::Registry
6
+ module CLAISS
7
+ class Error < StandardError; end
10
8
 
11
9
  class Version < Dry::CLI::Command
12
10
  desc "Print version"
13
11
 
14
12
  def call(*)
15
- spec = Gem::Specification::load("claiss.gemspec")
16
- puts "#{spec.description}"
17
- puts "Version: #{spec.version}"
13
+ puts "CLAISS version #{CLAISS::VERSION}"
18
14
  end
19
15
  end
20
16
 
21
17
  class Refactor < Dry::CLI::Command
22
18
  desc "Refactors terms and files on directories"
23
- argument :path, type: :string, required: true, desc: "Relative path directory"
24
- argument :json_file, type: :string, desc: "Provide a Ruby hash file"
25
-
19
+ argument :path, type: :string, required: true, desc: "Relative path directory"
20
+ argument :json_file, type: :string, desc: "Provide a JSON file with replacement rules"
21
+
26
22
  def call(path:, json_file: nil, **)
27
- dict = {}
28
- search = ""
29
- replace = ""
30
- input = "y"
31
- temp_dir = "/refactored-#{Time.now.to_i.to_s}"
23
+ dict = load_dictionary(json_file)
32
24
  origin_path = File.expand_path(path)
33
- destination_path = File.expand_path("."+ temp_dir)
25
+ destination_path = File.expand_path("./refactored-#{Time.now.to_i}")
26
+
27
+ dict[origin_path] = destination_path
28
+ process_files(origin_path, dict)
29
+
30
+ puts "Done! Your project is in the #{destination_path} folder"
31
+ end
32
+
33
+ private
34
34
 
35
- if !json_file.nil?
36
- jfile = File.read(json_file)
37
- dict = JSON.parse(jfile)
35
+ def load_dictionary(json_file)
36
+ if json_file
37
+ JSON.parse(File.read(json_file))
38
38
  else
39
- while input.downcase == "y" do
40
- puts "Term to search: "
41
- search = STDIN.gets.chomp
42
- puts "Term to replace: "
43
- replace = STDIN.gets.chomp
44
-
45
- dict[search] = replace
46
- puts "\nAdd another? Type Y \nto Start Refactoring press Enter"
47
- input = STDIN.gets.chomp!
48
- end
39
+ interactive_dictionary
49
40
  end
41
+ end
50
42
 
51
- dict = {origin_path => destination_path}.merge(dict)
52
- dict[origin_path] = destination_path
53
- source = File.join(origin_path, "**", "{*,.*}")
54
- Dir.glob(source, File::FNM_DOTMATCH).each do |file_name|
55
- next if File.directory?(file_name)
43
+ def interactive_dictionary
44
+ dict = {}
45
+ loop do
46
+ print "Term to search (or press Enter to finish): "
47
+ search = STDIN.gets.chomp
48
+ break if search.empty?
49
+ print "Term to replace: "
50
+ replace = STDIN.gets.chomp
51
+ dict[search] = replace
52
+ end
53
+ dict
54
+ end
56
55
 
57
- destination = file_name
58
- text = File.read(file_name)
56
+ def process_files(origin_path, dict)
57
+ Dir.glob(File.join(origin_path, "**", "*"), File::FNM_DOTMATCH).each do |file_name|
58
+ next if File.directory?(file_name)
59
+ process_file(file_name, dict)
60
+ end
61
+ end
59
62
 
60
- dict.each do |p, i|
61
- destination.gsub!(p, i)
62
- text.gsub!(p, i)
63
- end
63
+ def process_file(file_name, dict)
64
+ destination = file_name.gsub(dict.keys.first, dict.values.first)
65
+ text = File.read(file_name)
64
66
 
65
- FileUtils.mkdir_p(File.dirname(destination))
66
- File.write(destination, text)
67
- puts "File: #{destination}, OK"
67
+ dict.each do |search, replace|
68
+ destination.gsub!(search, replace)
69
+ text.gsub!(search, replace)
68
70
  end
69
71
 
70
- puts "done! your project is in the #{temp_dir} folder"
72
+ FileUtils.mkdir_p(File.dirname(destination))
73
+ File.write(destination, text)
74
+ puts "File: #{destination}, OK"
71
75
  end
72
76
  end
73
77
 
74
78
  class FixRubyPermissions < Dry::CLI::Command
75
- argument :path, required: true, desc: "The path of your ruby project"
76
-
79
+ desc "Fix permissions for a Ruby project"
80
+ argument :path, required: true, desc: "The path of your Ruby project"
81
+
77
82
  def call(path: nil, **)
78
- if path.nil?
79
- path = File.basename(Dir.getwd)
83
+ path ||= Dir.getwd
84
+ path = File.expand_path(path)
85
+
86
+ Dir.glob(File.join(path, '**', '*'), File::FNM_DOTMATCH) do |item|
87
+ next if item == '.' || item == '..'
88
+ if File.directory?(item)
89
+ File.chmod(0755, item)
90
+ else
91
+ File.chmod(0644, item)
92
+ end
93
+ end
94
+
95
+ executable_files = ['bundle', 'rails', 'rake', 'spring']
96
+ executable_files.each do |file|
97
+ file_path = File.join(path, 'bin', file)
98
+ File.chmod(0755, file_path) if File.exist?(file_path)
80
99
  end
81
-
82
- # Run shell scripts to set permissions.
83
- directories = `chmod 755 $(find #{path} -type d)`
84
- files = `chmod 644 $(find #{path} -type f)`
85
- bundle = `chmod 755 #{path+'/bin/bundle'}`
86
- rails = `chmod 755 #{path+'/bin/rails'}`
87
- rake = `chmod 755 #{path+'/bin/rake'}`
88
- spring = `chmod 755 #{path+'/bin/spring'}`
100
+
101
+ puts "Permissions fixed for #{path}"
89
102
  end
90
103
  end
91
-
92
- register "version", Version, aliases: ["v", "-v", "--version"]
93
- register "refactor", Refactor
94
- register "fix_ruby_permissions", FixRubyPermissions
95
104
  end
105
+
106
+ require_relative "claiss/version"
107
+ require_relative "claiss/commands"
108
+ require_relative "claiss/cli"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Júlio Papel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.0.0
27
- - !ruby/object:Gem::Dependency
28
- name: pathname
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 0.2.1
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 0.2.1
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: fileutils
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,8 +52,8 @@ dependencies:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: 2.6.3
69
- description: CLI application Toolbox to manage Laiss AI applications and deployments.
70
- Some thing may not work on your environment. Use with caution!
55
+ description: CLI application Toolbox to manage CLAISS AI applications and deployments.
56
+ Some features may not work in all environments. Use with caution!
71
57
  email:
72
58
  - julio.papel@gmail.com
73
59
  executables:
@@ -75,13 +61,18 @@ executables:
75
61
  extensions: []
76
62
  extra_rdoc_files: []
77
63
  files:
64
+ - LICENSE
65
+ - README.md
78
66
  - exe/claiss
79
67
  - lib/claiss.rb
80
- - lib/tasks/claiss.rake
68
+ - lib/claiss/cli.rb
69
+ - lib/claiss/commands.rb
70
+ - lib/claiss/version.rb
81
71
  homepage: http://rubygems.org/gems/claiss
82
72
  licenses:
83
73
  - MIT
84
74
  metadata:
75
+ source_code_uri: https://github.com/JulioPapel/claiss.git
85
76
  documentation_uri: https://github.com/JulioPapel/claiss/blob/main/readme.md
86
77
  post_install_message:
87
78
  rdoc_options: []
@@ -98,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
89
  - !ruby/object:Gem::Version
99
90
  version: '0'
100
91
  requirements: []
101
- rubygems_version: 3.5.9
92
+ rubygems_version: 3.1.2
102
93
  signing_key:
103
94
  specification_version: 4
104
- summary: Laiss AI CLI application Toolbox
95
+ summary: CLAISS AI CLI application Toolbox
105
96
  test_files: []
@@ -1,25 +0,0 @@
1
- GEM_NAME = "claiss"
2
- GEM_VERSION = "1.0.0"
3
-
4
- namespace :claiss do
5
- path = "/home/rails/laiss/lib/claiss/"
6
-
7
- task :default => :build
8
-
9
- task :build do
10
- system "gem build " + path + GEM_NAME + ".gemspec"
11
- end
12
-
13
- task :install => :build do
14
- system "gem install " + path + GEM_NAME + "-" + GEM_VERSION + ".gem"
15
- end
16
-
17
- task :publish => :build do
18
- system 'gem push ' + path + GEM_NAME + "-" + GEM_VERSION + ".gem"
19
- end
20
-
21
- task :clean do
22
- system "rm " + path + "*.gem"
23
- end
24
-
25
- end