rails_plan 0.0.4 → 0.0.6

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: 2514de50b22779a293ad4455071eb682e829d7343658ec508b6042617fca276b
4
- data.tar.gz: b7ba5905351dfcb7341c356c51f2fbf6e82957dcba3d2aee165a78db05ef8933
3
+ metadata.gz: 969195f7b64b0ef75ccf58680888c53b11ba90802ed85c73b67e00069b6595c0
4
+ data.tar.gz: 5e14518c6e60047d2c0c301d825b0be45c227e8f2eafe21fb5d5320f918c18e4
5
5
  SHA512:
6
- metadata.gz: 9f3a6ae5c736b3b6345760dbee23be420b360798962bade77fde65d349f45b6c06fa0589c0adc47b0646285d2cb2056b55d76e0eba7a2994b3ee288179079157
7
- data.tar.gz: 6f3d97472e4f309079bde3f40d760e344adfc174f75ea1264caaafe04d4c7ce82d516e2985a254151881cc61411f028951034df83f6245dee274a1fbb5894f8b
6
+ metadata.gz: d1f65c034266e92e2e21e44a54aa36698fb066312fd65ee895c522194abba62228e3657c57660d0798375b6d7d5964098188b7992b13e792319a154d76d6599e
7
+ data.tar.gz: 8f809791401f24dbb6df1f9b42fc82ed320c8311bddc7f3b045c3cfc52b8e71caa70d3aa9b23996c2a889c01395d0523208618ac88549d365e0ec519d7879de6
@@ -3,23 +3,16 @@
3
3
  module RailsPlan
4
4
  module Cli
5
5
  class FetchTemplate
6
- COMMANDS = %w[apply].freeze
7
- API_URL = 'https://railsplan.com/api/v1'
6
+ # API_URL = 'https://railsplan.com/api/v1'
7
+ API_URL = 'http://localhost:3000/api/v1'
8
8
 
9
9
  def call(uid)
10
- response = RestClient.get(API_URL + "/bootstrap_plans/#{uid}") { |res| res }
10
+ response = RestClient.get(API_URL + "/plans/#{uid}") { |res| res }
11
11
 
12
12
  return if response.code != 200
13
13
 
14
14
  JSON.parse(response.body)
15
15
  end
16
-
17
- def gem_version
18
- response = RestClient.get(API_URL + "/bootstrap_plans/gem_current_version")
19
- parsed_response = JSON.parse(response.body)
20
-
21
- parsed_response['version']
22
- end
23
16
  end
24
17
  end
25
18
  end
@@ -3,7 +3,7 @@
3
3
  module RailsPlan
4
4
  module Cli
5
5
  class Processor
6
- COMMANDS = %w[start].freeze
6
+ COMMANDS = %w[build].freeze
7
7
 
8
8
  InvalidCommand = Class.new(StandardError)
9
9
  InvalidUid = Class.new(StandardError)
@@ -16,9 +16,9 @@ module RailsPlan
16
16
  def call
17
17
  validate_command
18
18
 
19
- raise InvalidUid, "Bootstrap plan not found for #{@uid}" if json_template.nil?
19
+ raise InvalidUid, "Plan not found for #{@uid}" if json_template.nil?
20
20
 
21
- ::RailsPlan.start(json_template)
21
+ ::RailsPlan.build(json_template)
22
22
  end
23
23
 
24
24
  private
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPlan
4
- VERSION = '0.0.4'
5
- RAILS_VERSION = '7.1.3.3'
4
+ VERSION = '0.0.6'
6
5
  end
data/lib/rails_plan.rb CHANGED
@@ -3,116 +3,24 @@
3
3
  require 'rest-client'
4
4
  require 'json'
5
5
  require 'fileutils'
6
- require 'thor'
7
6
 
8
7
  require 'rails_plan/cli/fetch_template'
9
8
  require 'rails_plan/cli/processor'
10
9
  require 'rails_plan/version'
11
- require 'rails_plan/rails_app'
12
- require 'rails_plan/gem_version'
13
10
 
14
11
  module RailsPlan
15
- RailsNotInstalled = Class.new(StandardError)
16
-
17
12
  class << self
18
- def start(template)
19
- ::RailsPlan::GemVersion.validate!
20
-
21
- verify_rails_installation
22
-
23
- generate_project(template)
24
- generate_files(template['files'])
25
- run_commands(template['before_commands'])
26
- clone_files(template['clones'])
27
- inject_code(template['inject_code'])
28
- append_code(template['append_code'])
29
- update_files(template['gsub'])
30
-
31
- template['steps'].each do |step|
32
- puts step['title'] if step['title']
33
- run_commands(step['before_commands'])
34
- generate_files(step['files'])
35
- prepend_to_file(step['prepend_code'])
36
- run_commands(step['after_commands'])
37
- end
38
- end
39
-
40
- private
41
-
42
- def verify_rails_installation
43
- return if system("gem list ^rails$ --version #{RailsPlan::RAILS_VERSION} -i")
44
-
45
- raise RailsNotInstalled, "Please install Rails #{RailsPlan::RAILS_VERSION} and retry"
46
- end
47
-
48
- def generate_project(template)
49
- system template['installation_command']
13
+ def build(files)
14
+ dir_name = "rails_plan_app-#{Time.now.strftime('%Y%m%d%H%M%S')}"
15
+ FileUtils.mkdir_p(dir_name)
16
+ Dir.chdir(dir_name)
50
17
 
51
- Dir.chdir(template['name'])
52
- end
53
-
54
- def generate_files(files)
55
18
  files.each do |file|
56
- puts "-> \e[1;32;49mCreate\e[0m #{file['file_path']}"
57
- file_path = File.join(Dir.pwd, file['file_path'])
19
+ puts "-> \e[1;32;49mCreate\e[0m #{file['path']}"
20
+ file_path = File.join(Dir.pwd, file['path'])
58
21
  FileUtils.mkdir_p(File.dirname(file_path))
59
22
  File.write(file_path, file['content'])
60
23
  end
61
24
  end
62
-
63
- def run_commands(commands)
64
- commands.each do |command|
65
- puts "-> \e[1;32;49mRun\e[0m #{command}"
66
- system command
67
- end
68
- end
69
-
70
- def inject_code(injections)
71
- return if injections.nil? || injections.empty?
72
-
73
- thor_app = ::RailsPlan::RailsApp.new
74
-
75
- injections.each do |injection|
76
- thor_app.inject_into_class(injection['file_path'], injection['class_name'], injection['content'])
77
- end
78
- end
79
-
80
- def prepend_to_file(injections)
81
- return if injections.nil? || injections.empty?
82
-
83
- thor_app = ::RailsPlan::RailsApp.new
84
-
85
- injections.each do |injection|
86
- thor_app.insert_into_file(injection['file_path'], injection['content'], after: injection['after'])
87
- end
88
- end
89
-
90
- def append_code(appends)
91
- return if appends.nil? || appends.empty?
92
-
93
- thor_app = ::RailsPlan::RailsApp.new
94
-
95
- appends.each do |append|
96
- thor_app.append_to_file(append['file_path'], append['content'])
97
- end
98
- end
99
-
100
- def update_files(updates)
101
- return if updates.nil? || updates.empty?
102
-
103
- thor_app = ::RailsPlan::RailsApp.new
104
-
105
- updates.each do |update|
106
- thor_app.gsub_file(update['file_path'], update['pattern'], update['value'])
107
- end
108
- end
109
-
110
- def clone_files(files)
111
- return if files.nil? || files.empty?
112
-
113
- files.each do |file|
114
- FileUtils.cp(file['from'], file['to'])
115
- end
116
- end
117
25
  end
118
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_plan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Dąbrowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-15 00:00:00.000000000 Z
11
+ date: 2024-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.1.0
27
- - !ruby/object:Gem::Dependency
28
- name: thor
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
32
- - !ruby/object:Gem::Version
33
- version: 1.3.1
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
40
- version: 1.3.1
41
27
  description: Speed up Rails app planning and development process
42
28
  email:
43
29
  - contact@paweldabrowski.com
@@ -51,8 +37,6 @@ files:
51
37
  - lib/rails_plan.rb
52
38
  - lib/rails_plan/cli/fetch_template.rb
53
39
  - lib/rails_plan/cli/processor.rb
54
- - lib/rails_plan/gem_version.rb
55
- - lib/rails_plan/rails_app.rb
56
40
  - lib/rails_plan/version.rb
57
41
  homepage: https://railsplan.com
58
42
  licenses:
@@ -1,13 +0,0 @@
1
- module RailsPlan
2
- class GemVersion
3
- NotUpdatedGem = Class.new(StandardError)
4
-
5
- def self.validate!
6
- newest_version = RailsPlan::Cli::FetchTemplate.new.gem_version
7
-
8
- return if system("gem list ^rails_plan$ --version #{newest_version} -i")
9
-
10
- raise NotUpdatedGem, "Please update the gem to newest version #{newest_version} and retry"
11
- end
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- module RailsPlan
2
- class RailsApp < Thor
3
- include Thor::Actions
4
-
5
- def self.source_root
6
- File.dirname(__FILE__)
7
- end
8
- end
9
- end