verify_it 0.2.0 → 0.4.0.beta
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 +4 -4
- data/CHANGELOG.md +26 -0
- data/README.md +260 -261
- data/app/controllers/verify_it/application_controller.rb +9 -0
- data/app/controllers/verify_it/verifications_controller.rb +71 -0
- data/config/locales/en.yml +16 -0
- data/config/routes.rb +6 -0
- data/lib/generators/verify_it/install/install_generator.rb +46 -0
- data/lib/{verify_it/templates/migration.rb.erb → generators/verify_it/install/templates/create_verify_it_tables.rb} +1 -3
- data/lib/{verify_it → generators/verify_it/install}/templates/initializer.rb.erb +20 -6
- data/lib/verify_it/code_generator.rb +3 -3
- data/lib/verify_it/code_hasher.rb +25 -0
- data/lib/verify_it/configuration.rb +17 -1
- data/lib/verify_it/engine.rb +19 -0
- data/lib/verify_it/storage/database_storage.rb +7 -6
- data/lib/verify_it/storage/memory_storage.rb +3 -3
- data/lib/verify_it/storage/models/attempt.rb +2 -2
- data/lib/verify_it/storage/models/code.rb +2 -2
- data/lib/verify_it/storage/models/identifier_change.rb +2 -2
- data/lib/verify_it/verifiable.rb +1 -3
- data/lib/verify_it/verifier.rb +171 -121
- data/lib/verify_it/version.rb +1 -1
- data/lib/verify_it.rb +4 -1
- data/verify_it-0.1.0.gem +0 -0
- data/verify_it-0.1.1.gem +0 -0
- data/verify_it-0.2.0.gem +0 -0
- data/verify_it-0.3.0.gem +0 -0
- metadata +57 -36
- data/exe/verify_it +0 -7
- data/lib/verify_it/cli.rb +0 -141
- data/lib/verify_it/railtie.rb +0 -14
data/lib/verify_it/cli.rb
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "fileutils"
|
|
4
|
-
require "erb"
|
|
5
|
-
require_relative "../verify_it" unless defined?(VerifyIt::VERSION)
|
|
6
|
-
|
|
7
|
-
module VerifyIt
|
|
8
|
-
class CLI
|
|
9
|
-
def self.start(args)
|
|
10
|
-
new(args).run
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def initialize(args)
|
|
14
|
-
@args = args
|
|
15
|
-
@command = args[0]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def run
|
|
19
|
-
case @command
|
|
20
|
-
when "install"
|
|
21
|
-
install
|
|
22
|
-
when "version", "-v", "--version"
|
|
23
|
-
puts "VerifyIt #{VerifyIt::VERSION}"
|
|
24
|
-
when "help", "-h", "--help", nil
|
|
25
|
-
show_help
|
|
26
|
-
else
|
|
27
|
-
puts "Unknown command: #{@command}"
|
|
28
|
-
show_help
|
|
29
|
-
exit 1
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def install
|
|
36
|
-
puts "VerifyIt Installer"
|
|
37
|
-
puts "=" * 50
|
|
38
|
-
puts
|
|
39
|
-
|
|
40
|
-
load_rails_environment
|
|
41
|
-
check_rails_environment
|
|
42
|
-
|
|
43
|
-
storage_type = prompt_storage_type
|
|
44
|
-
generate_initializer(storage_type)
|
|
45
|
-
generate_migration if storage_type == "database"
|
|
46
|
-
|
|
47
|
-
puts
|
|
48
|
-
puts "✓ Installation complete!"
|
|
49
|
-
puts
|
|
50
|
-
puts "Next steps:"
|
|
51
|
-
puts " 1. Review the generated initializer"
|
|
52
|
-
if storage_type == "database"
|
|
53
|
-
puts " 2. Run: rails db:migrate"
|
|
54
|
-
puts " 3. Configure your delivery method in the initializer"
|
|
55
|
-
else
|
|
56
|
-
puts " 2. Configure your delivery method in the initializer"
|
|
57
|
-
puts " 3. Start using VerifyIt in your models!"
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def load_rails_environment
|
|
62
|
-
env_file = File.join(Dir.pwd, "config", "environment.rb")
|
|
63
|
-
require env_file if File.exist?(env_file)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def check_rails_environment
|
|
67
|
-
unless defined?(Rails)
|
|
68
|
-
puts "Error: Rails environment not detected."
|
|
69
|
-
puts "Please run this command from your Rails application root."
|
|
70
|
-
exit 1
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def prompt_storage_type
|
|
75
|
-
puts "Select storage backend:"
|
|
76
|
-
puts " 1) Memory (for development/testing)"
|
|
77
|
-
puts " 2) Redis (recommended for production)"
|
|
78
|
-
puts " 3) Database (uses ActiveRecord)"
|
|
79
|
-
puts
|
|
80
|
-
|
|
81
|
-
loop do
|
|
82
|
-
print "Enter choice (1-3): "
|
|
83
|
-
choice = $stdin.gets.chomp
|
|
84
|
-
|
|
85
|
-
case choice
|
|
86
|
-
when "1"
|
|
87
|
-
return "memory"
|
|
88
|
-
when "2"
|
|
89
|
-
return "redis"
|
|
90
|
-
when "3"
|
|
91
|
-
return "database"
|
|
92
|
-
else
|
|
93
|
-
puts "Invalid choice. Please enter 1, 2, or 3."
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def generate_initializer(storage_type)
|
|
99
|
-
template_path = File.expand_path("../templates/initializer.rb.erb", __FILE__)
|
|
100
|
-
output_path = Rails.root.join("config", "initializers", "verify_it.rb")
|
|
101
|
-
|
|
102
|
-
if File.exist?(output_path)
|
|
103
|
-
print "Initializer already exists. Overwrite? (y/n): "
|
|
104
|
-
return unless $stdin.gets.chomp.downcase == "y"
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
template = ERB.new(File.read(template_path))
|
|
108
|
-
content = template.result(binding)
|
|
109
|
-
|
|
110
|
-
FileUtils.mkdir_p(File.dirname(output_path))
|
|
111
|
-
File.write(output_path, content)
|
|
112
|
-
|
|
113
|
-
puts "✓ Created initializer: config/initializers/verify_it.rb"
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def generate_migration
|
|
117
|
-
timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S")
|
|
118
|
-
template_path = File.expand_path("../templates/migration.rb.erb", __FILE__)
|
|
119
|
-
output_path = Rails.root.join("db", "migrate", "#{timestamp}_create_verify_it_tables.rb")
|
|
120
|
-
|
|
121
|
-
template = ERB.new(File.read(template_path))
|
|
122
|
-
content = template.result(binding)
|
|
123
|
-
|
|
124
|
-
FileUtils.mkdir_p(File.dirname(output_path))
|
|
125
|
-
File.write(output_path, content)
|
|
126
|
-
|
|
127
|
-
puts "✓ Created migration: db/migrate/#{timestamp}_create_verify_it_tables.rb"
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def show_help
|
|
131
|
-
puts "VerifyIt - Verification system for Ruby applications"
|
|
132
|
-
puts
|
|
133
|
-
puts "Usage:"
|
|
134
|
-
puts " verify_it install Generate initializer and optional migration"
|
|
135
|
-
puts " verify_it version Show version number"
|
|
136
|
-
puts " verify_it help Show this help message"
|
|
137
|
-
puts
|
|
138
|
-
puts "For more information, visit: https://github.com/JeremasPosta/verify_it"
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
data/lib/verify_it/railtie.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rails/railtie"
|
|
4
|
-
|
|
5
|
-
module VerifyIt
|
|
6
|
-
class Railtie < Rails::Railtie
|
|
7
|
-
initializer "verify_it.active_record" do
|
|
8
|
-
ActiveSupport.on_load(:active_record) do
|
|
9
|
-
require_relative "verifiable"
|
|
10
|
-
include VerifyIt::Verifiable
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|