claiss 1.1.2 → 1.1.4

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +133 -32
  3. data/lib/claiss/version.rb +2 -2
  4. data/lib/claiss.rb +38 -12
  5. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b196fd14a391ce3804f055af6109513aa11d3b9555a31bcd0cdfcd99aebf4e3d
4
- data.tar.gz: 7dd699a7ea98feeb55c974a726ff0d40a8b239d960e21bd3ebc6d994883c29cf
3
+ metadata.gz: 444c32b0586f427d677d4c6adc09d9f0843044e17bdca20bcf9743436b61b925
4
+ data.tar.gz: 40cc9ba8569e33ce34aab0f77d53e56fed7bbae7d5229fb01619d3850b74115a
5
5
  SHA512:
6
- metadata.gz: 3886071f8e207af613f1e9da94e29fc72f6d95e7f3ca3e79e2e9e3f19b72b2f37c59c3375625feed9440329d07387d1fb1dea7cf4f4f1a98a16c8d3ce5307748
7
- data.tar.gz: 44cafb7662557876102c52385966d4712b1cd58448c77bc5228ff60ed18263072682055eb64a438cdd3cce8f59b59fb58f506380f3f7048570d14c6c49651680
6
+ metadata.gz: 9afca82efd4a0a3da21f403d1a2108ef6ef97d742874f9190688f4eec4e51c8bfed4a9a4cdeca469b1f2dc5e5472182f72ecccf94d14466ff7bf79b447414ea8
7
+ data.tar.gz: adf058a7d49f3b966c8e7e21e5670c8017f02e37606a380809f035ce1d49060059c847c03e5559ec43f96bd77dfccfce0fd2900c7707e909132977bf79df5c03
data/README.md CHANGED
@@ -1,71 +1,81 @@
1
1
  # CLAISS CLI Refactor Application Toolbox
2
2
 
3
+ [English](#english) | [Português](#português)
4
+
5
+ # English
6
+
3
7
  **CLAISS** is a Ruby-based CLI application and toolbox designed to manage CLAISS Refactored applications and deployments. Please note that some features may have limited compatibility depending on the environment. Use with caution!
4
8
 
5
9
  ## Installation
6
10
 
7
11
  Install the CLAISS gem by running the following command in your terminal:
8
12
 
9
- ```sh
13
+ ´´´sh
10
14
  $ gem install claiss
11
- ```
15
+ ´´´
12
16
 
13
17
  ## Usage
14
18
 
19
+ ### Version
20
+
21
+ To check the CLAISS version:
22
+
23
+ ´´´sh
24
+ $ claiss version
25
+ ´´´
26
+
27
+ or use the shortcuts:
28
+
29
+ ´´´sh
30
+ $ claiss v
31
+ $ claiss -v
32
+ $ claiss --version
33
+ ´´´
34
+
15
35
  ### Refactor
16
36
 
17
- The `refactor` command allows you to rename and replace text terms within files and filenames in a specified directory. This command will refactor all exact occurrences of specified terms, including filenames. For example, "Abc" is treated differently from "AbC", "ABc", or "abc".
37
+ The `refactor` command allows you to rename and replace text terms within files and filenames in a specified directory. This command will refactor all exact occurrences of specified terms, including filenames.
18
38
 
19
39
  **Note:** The `refactor` command ignores the `.git/` and `node_modules/` directories to avoid modifying critical or third-party files.
20
40
 
21
41
  Basic usage:
22
42
 
23
- ```sh
24
- $ claiss refactor ./project/ ./my_changes.json
25
- ```
43
+ ´´´sh
44
+ $ claiss refactor <project_path> <json_file>
45
+ ´´´
46
+
47
+ Example:
48
+
49
+ ´´´sh
50
+ $ claiss refactor llama_index laiss_labs.json
51
+ ´´´
26
52
 
27
53
  #### Using a JSON Dictionary
28
54
 
29
- You can create a JSON file that specifies the terms you want to refactor. This JSON file should be structured as a simple key-value pair object, where each key is the term to be replaced and the value is the replacement term. The terms are processed in the order they appear in the file.
55
+ You can create a JSON file that specifies the terms you want to refactor. This JSON file should be structured as a simple key-value pair object, where each key is the term to be replaced and the value is the replacement term.
30
56
 
31
- Example `my_changes.json`:
57
+ Example `laiss_labs.json`:
32
58
 
33
- ```json
59
+ ´´´json
34
60
  {
35
61
  "system pro": "system b2b",
36
62
  "System Pro": "System B2b",
37
63
  "System": "Laiss",
38
- "system": "laiss",
39
- "2010 Moevo Silver": "2023 Júlio Papel",
40
- "Jared Moevo": "Júlio Papel",
41
- "3dtester@gmail.com": "info@mynewsite.pt",
42
- "https://somelivesite.com": "https://api.mynewsite.pt",
43
- "This is your Rails project.": "Multi Layered Software Services.",
44
- "This is your Rails project for your business.": "A Multi Layered Software Services ready to be deployed for any business.",
45
- "MIT-LICENSE": "LICENSE",
46
- "https://somesite.com": "https://api.mynewsite.pt"
64
+ "system": "laiss"
47
65
  }
48
- ```
49
-
50
- To apply the changes using the dictionary file:
51
-
52
- ```sh
53
- $ claiss refactor ./project/ ./my_changes.json
54
- ```
66
+ ´´´
55
67
 
56
68
  **Important:** After refactoring, any empty directories left behind will be automatically removed to keep your project structure clean.
57
69
 
58
70
  ### Fix Ruby Permissions
59
71
 
60
- The `fix_ruby_permissions` command adjusts file permissions for a Ruby or Rails project. It ensures that directories have the correct execute permissions and that files retain their appropriate read/write/execute permissions.
72
+ The `fix_ruby_permissions` command adjusts file permissions for a Ruby or Rails project.
61
73
 
62
- ```sh
63
- $ claiss fix_ruby_permissions ./project/
64
- ```
74
+ ´´´sh
75
+ $ claiss fix_ruby_permissions <project_path>
76
+ ´´´
65
77
 
66
- **Note:** This command uses `chmod` and may encounter issues on systems that do not distinguish between uppercase and lowercase filenames or support spaces in filenames (e.g., certain end-user operating systems). If you encounter errors, particularly with filenames like `MyImage copy.svg`, manually fix those file permissions and re-run the command.
67
-
68
- ## Upcoming Features
78
+ ## Future Features
69
79
 
70
80
  We are continuously working to improve CLAISS and add new functionalities. Stay tuned for updates!
71
81
 
@@ -80,3 +90,94 @@ This gem is available as open source under the terms of the [MIT License](https:
80
90
  ## Author
81
91
 
82
92
  Júlio Papel
93
+
94
+ ---
95
+
96
+ # Português
97
+
98
+ **CLAISS** é uma aplicação CLI e caixa de ferramentas em Ruby projetada para gerenciar aplicações e implantações CLAISS Refactored. Por favor, note que algumas funcionalidades podem ter compatibilidade limitada dependendo do ambiente. Use com cuidado!
99
+
100
+ ## Instalação
101
+
102
+ Instale a gem CLAISS executando o seguinte comando no seu terminal:
103
+
104
+ ´´´sh
105
+ $ gem install claiss
106
+ ´´´
107
+
108
+ ## Uso
109
+
110
+ ### Versão
111
+
112
+ Para verificar a versão do CLAISS:
113
+
114
+ ´´´sh
115
+ $ claiss version
116
+ ´´´
117
+
118
+ ou use os atalhos:
119
+
120
+ ´´´sh
121
+ $ claiss v
122
+ $ claiss -v
123
+ $ claiss --version
124
+ ´´´
125
+
126
+ ### Refactor
127
+
128
+ O comando `refactor` permite que você renomeie e substitua termos de texto dentro de arquivos e nomes de arquivos em um diretório especificado. Este comando irá refatorar todas as ocorrências exatas dos termos especificados, incluindo nomes de arquivos.
129
+
130
+ **Nota:** O comando `refactor` ignora os diretórios `.git/` e `node_modules/` para evitar modificar arquivos críticos ou de terceiros.
131
+
132
+ Uso básico:
133
+
134
+ ´´´sh
135
+ $ claiss refactor <caminho_do_projeto> <arquivo_json>
136
+ ´´´
137
+
138
+ Exemplo:
139
+
140
+ ´´´sh
141
+ $ claiss refactor llama_index laiss_labs.json
142
+ ´´´
143
+
144
+ #### Usando um Dicionário JSON
145
+
146
+ Você pode criar um arquivo JSON que especifica os termos que deseja refatorar. Este arquivo JSON deve ser estruturado como um objeto de pares chave-valor simples, onde cada chave é o termo a ser substituído e o valor é o termo de substituição.
147
+
148
+ Exemplo `laiss_labs.json`:
149
+
150
+ ´´´json
151
+ {
152
+ "system pro": "system b2b",
153
+ "System Pro": "System B2b",
154
+ "System": "Laiss",
155
+ "system": "laiss"
156
+ }
157
+ ´´´
158
+
159
+ **Importante:** Após a refatoração, quaisquer diretórios vazios deixados para trás serão automaticamente removidos para manter a estrutura do seu projeto limpa.
160
+
161
+ ### Fix Ruby Permissions
162
+
163
+ O comando `fix_ruby_permissions` ajusta as permissões de arquivos para um projeto Ruby ou Rails.
164
+
165
+ ´´´sh
166
+ $ claiss fix_ruby_permissions <caminho_do_projeto>
167
+ ´´´
168
+
169
+ ## Recursos Futuros
170
+
171
+ Estamos continuamente trabalhando para melhorar o CLAISS e adicionar novas funcionalidades. Fique atento para atualizações!
172
+
173
+ ## Contribuindo
174
+
175
+ Relatórios de bugs e pull requests são bem-vindos no GitHub em [https://github.com/JulioPapel/claiss](https://github.com/JulioPapel/claiss).
176
+
177
+ ## Licença
178
+
179
+ Esta gem está disponível como código aberto sob os termos da [Licença MIT](https://opensource.org/licenses/MIT).
180
+
181
+ ## Autor
182
+
183
+ Júlio Papel
@@ -1,3 +1,3 @@
1
1
  module CLAISS
2
- VERSION = "1.1.2"
3
- end
2
+ VERSION = "1.1.4"
3
+ end
data/lib/claiss.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bundler/setup"
2
2
  require "dry/cli"
3
3
  require "fileutils"
4
- require 'json'
4
+ require "json"
5
5
 
6
6
  module CLAISS
7
7
  class Error < StandardError; end
@@ -33,7 +33,30 @@ module CLAISS
33
33
 
34
34
  def load_dictionary(json_file)
35
35
  if json_file
36
- JSON.parse(File.read(json_file))
36
+ # Procura o arquivo no diretório atual e no ~/.claiss
37
+ possible_paths = [
38
+ json_file,
39
+ File.expand_path(json_file),
40
+ File.expand_path("~/.claiss/#{json_file}"),
41
+ ]
42
+
43
+ found_file = possible_paths.find { |path| File.exist?(path) }
44
+
45
+ if found_file
46
+ begin
47
+ dict = JSON.parse(File.read(found_file))
48
+ puts "Oba! Encontrei o arquivo em: #{found_file}"
49
+ return dict
50
+ rescue JSON::ParserError => e
51
+ puts "Ops! O arquivo JSON não está no formato correto. Erro: #{e.message}"
52
+ end
53
+ else
54
+ puts "Hmm, não consegui encontrar o arquivo. Procurei nesses lugares:"
55
+ possible_paths.each { |path| puts " - #{path}" }
56
+ end
57
+
58
+ puts "Vamos usar o dicionário interativo em vez disso, tá bom?"
59
+ interactive_dictionary
37
60
  else
38
61
  interactive_dictionary
39
62
  end
@@ -90,18 +113,22 @@ module CLAISS
90
113
  end
91
114
 
92
115
  def remove_empty_directories(origin_path)
93
- Dir.glob(File.join(origin_path, '**', '*'), File::FNM_DOTMATCH).reverse_each do |dir_name|
116
+ Dir.glob(File.join(origin_path, "**", "*"), File::FNM_DOTMATCH).reverse_each do |dir_name|
94
117
  next unless File.directory?(dir_name)
95
- next if dir_name.include?(".git/") || dir_name.include?("node_modules/") # Ignore .git and node_modules folders
118
+ next if dir_name.include?(".git/") || dir_name.include?("node_modules/") # Ignorar pastas .git e node_modules
119
+ next if dir_name == "." || dir_name == ".." # Ignorar diretórios especiais . e ..
96
120
  if (Dir.entries(dir_name) - %w[. ..]).empty?
97
- Dir.rmdir(dir_name)
98
- puts "Removed empty directory: #{dir_name}"
121
+ begin
122
+ Dir.rmdir(dir_name)
123
+ puts "Diretório vazio removido: #{dir_name}"
124
+ rescue Errno::ENOTEMPTY, Errno::EINVAL => e
125
+ puts "Não foi possível remover o diretório: #{dir_name}. Erro: #{e.message}"
126
+ end
99
127
  end
100
128
  end
101
129
  end
102
130
  end
103
131
 
104
-
105
132
  class FixRubyPermissions < Dry::CLI::Command
106
133
  desc "Fix permissions for a Ruby project"
107
134
  argument :path, required: true, desc: "The path of your Ruby project"
@@ -110,8 +137,8 @@ module CLAISS
110
137
  path ||= Dir.getwd
111
138
  path = File.expand_path(path)
112
139
 
113
- Dir.glob(File.join(path, '**', '*'), File::FNM_DOTMATCH) do |item|
114
- next if item == '.' || item == '..'
140
+ Dir.glob(File.join(path, "**", "*"), File::FNM_DOTMATCH) do |item|
141
+ next if item == "." || item == ".."
115
142
  next if item.include?("node_modules/") # Ignore node_modules folder
116
143
  if File.directory?(item)
117
144
  File.chmod(0755, item)
@@ -120,9 +147,9 @@ module CLAISS
120
147
  end
121
148
  end
122
149
 
123
- executable_files = ['bundle', 'rails', 'rake', 'spring']
150
+ executable_files = ["bundle", "rails", "rake", "spring"]
124
151
  executable_files.each do |file|
125
- file_path = File.join(path, 'bin', file)
152
+ file_path = File.join(path, "bin", file)
126
153
  File.chmod(0755, file_path) if File.exist?(file_path)
127
154
  end
128
155
 
@@ -145,7 +172,6 @@ module CLAISS
145
172
  end
146
173
  end
147
174
  end
148
-
149
175
  end
150
176
 
151
177
  require_relative "claiss/version"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Júlio Papel
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-08-09 00:00:00.000000000 Z
10
+ date: 2025-02-08 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: dry-cli
@@ -74,7 +73,6 @@ licenses:
74
73
  metadata:
75
74
  source_code_uri: https://github.com/JulioPapel/claiss.git
76
75
  documentation_uri: https://github.com/JulioPapel/claiss/blob/main/readme.md
77
- post_install_message:
78
76
  rdoc_options: []
79
77
  require_paths:
80
78
  - lib
@@ -89,8 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
87
  - !ruby/object:Gem::Version
90
88
  version: '0'
91
89
  requirements: []
92
- rubygems_version: 3.5.3
93
- signing_key:
90
+ rubygems_version: 3.6.3
94
91
  specification_version: 4
95
92
  summary: CLAISS AI CLI application Toolbox
96
93
  test_files: []