rails_plan 0.0.5 → 0.0.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: e800d9904813591e2c13377191719763fdf89b6924de4483595bab720273e988
4
- data.tar.gz: 0b960db29b50211a2ba51653db3a52869397be95e400482be4c8bd63fd797973
3
+ metadata.gz: c120072574ceab85cebfdf4dbff6ea538f86bfc45cf3e2114515c893c970a19d
4
+ data.tar.gz: 076ac348807b97c738c1ce09c3967128718edb2f80fc88a21ca1a8cc77136d9e
5
5
  SHA512:
6
- metadata.gz: 9d79af72fad1e7db9df46e8a7710dc78600f10aa33e589482c3c00367a8dd92af3496b376f05531874faa3d904855174015987662e569543d4bd742e8a2036c9
7
- data.tar.gz: 790518e6748bc2c3211352c9da990ba234a9c77801edc0f3883405f9e558cac26034524451b0b401fcc574aa38623409b68122555cda247556a79da363b788f7
6
+ metadata.gz: d943627018d8b309973d88edfc7c2835c6ea80088942745c0f17a153e38c7242d01f57b4d37150e8a76fe0c3534aff77d4d3eee08b4ca36029e7fdb707ce9096
7
+ data.tar.gz: 9d8a83dc63e9cad059715f22b18d318fa6ea074fb4c960010a300bd085379ca853b8c08ca497cdcefa31921192a82a1a928511f8681c450925d168dfc7475326
@@ -3,22 +3,16 @@
3
3
  module RailsPlan
4
4
  module Cli
5
5
  class FetchTemplate
6
- API_URL = 'https://railsplan.com/api/v1'
6
+ # API_URL = 'https://railsplan.com/api/v1'
7
+ API_URL = 'http://localhost:3000/api/v1'
7
8
 
8
9
  def call(uid)
9
- response = RestClient.get(API_URL + "/bootstrap_plans/#{uid}") { |res| res }
10
+ response = RestClient.get(API_URL + "/plans/#{uid}") { |res| res }
10
11
 
11
12
  return if response.code != 200
12
13
 
13
14
  JSON.parse(response.body)
14
15
  end
15
-
16
- def gem_version
17
- response = RestClient.get(API_URL + "/bootstrap_plans/gem_current_version")
18
- parsed_response = JSON.parse(response.body)
19
-
20
- parsed_response['version']
21
- end
22
16
  end
23
17
  end
24
18
  end
@@ -3,7 +3,7 @@
3
3
  module RailsPlan
4
4
  module Cli
5
5
  class Processor
6
- COMMANDS = %w[start apply].freeze
6
+ COMMANDS = %w[build].freeze
7
7
 
8
8
  InvalidCommand = Class.new(StandardError)
9
9
  InvalidUid = Class.new(StandardError)
@@ -16,13 +16,9 @@ module RailsPlan
16
16
  def call
17
17
  validate_command
18
18
 
19
- raise InvalidUid, "Bootstrap plan or feature not found for #{@uid}" if json_template.nil?
19
+ raise InvalidUid, "Plan not found for #{@uid}" if json_template.nil?
20
20
 
21
- if @command == 'start'
22
- ::RailsPlan.start(json_template)
23
- elsif @command == 'apply'
24
- ::RailsPlan.apply(json_template)
25
- end
21
+ ::RailsPlan.build(json_template)
26
22
  end
27
23
 
28
24
  private
@@ -34,11 +30,7 @@ module RailsPlan
34
30
  def json_template
35
31
  return @json_template if defined?(@json_template)
36
32
 
37
- @json_template = if @command == 'start'
38
- ::RailsPlan::Cli::FetchTemplate.new.call(@uid)
39
- else
40
- ::RailsPlan::Cli::FetchBranch.new.call(@uid)
41
- end
33
+ @json_template = ::RailsPlan::Cli::FetchTemplate.new.call(@uid)
42
34
  end
43
35
  end
44
36
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPlan
4
- VERSION = '0.0.5'
5
- RAILS_VERSION = '7.1.3.3'
4
+ VERSION = '0.0.7'
6
5
  end
data/lib/rails_plan.rb CHANGED
@@ -3,125 +3,26 @@
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
- require 'rails_plan/cli/fetch_branch'
10
8
  require 'rails_plan/cli/processor'
11
9
  require 'rails_plan/version'
12
- require 'rails_plan/rails_app'
13
- require 'rails_plan/gem_version'
14
10
 
15
11
  module RailsPlan
16
- RailsNotInstalled = Class.new(StandardError)
17
-
18
12
  class << self
19
- def start(template)
20
- ::RailsPlan::GemVersion.validate!
21
-
22
- # verify_rails_installation
23
-
24
- generate_project(template)
25
- generate_files(template['files'])
26
- run_commands(template['before_commands'])
27
- clone_files(template['clones'])
28
- inject_code(template['inject_code'])
29
- append_code(template['append_code'])
30
- update_files(template['gsub'])
31
-
32
- template['steps'].each do |step|
33
- puts step['title'] if step['title']
34
- run_commands(step['before_commands'])
35
- generate_files(step['files'])
36
- prepend_to_file(step['prepend_code'])
37
- run_commands(step['after_commands'])
38
- end
39
- end
40
-
41
- def apply(template)
42
- puts template['title']
43
- run_commands(template['before_commands'])
44
- generate_files(template['files'])
45
- prepend_to_file(template['prepend_code'])
46
- run_commands(template['after_commands'])
47
- end
48
-
49
- private
50
-
51
- def verify_rails_installation
52
- return if system("gem list ^rails$ --version #{RailsPlan::RAILS_VERSION} -i")
53
-
54
- raise RailsNotInstalled, "Please install Rails #{RailsPlan::RAILS_VERSION} and retry"
55
- end
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)
56
17
 
57
- def generate_project(template)
58
- system template['installation_command']
59
-
60
- Dir.chdir(template['name'])
61
- end
62
-
63
- def generate_files(files)
64
18
  files.each do |file|
65
- puts "-> \e[1;32;49mCreate\e[0m #{file['file_path']}"
66
- 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'])
67
21
  FileUtils.mkdir_p(File.dirname(file_path))
68
22
  File.write(file_path, file['content'])
69
23
  end
70
- end
71
-
72
- def run_commands(commands)
73
- commands.each do |command|
74
- puts "-> \e[1;32;49mRun\e[0m #{command}"
75
- system command
76
- end
77
- end
78
-
79
- def inject_code(injections)
80
- return if injections.nil? || injections.empty?
81
24
 
82
- thor_app = ::RailsPlan::RailsApp.new
83
-
84
- injections.each do |injection|
85
- thor_app.inject_into_class(injection['file_path'], injection['class_name'], injection['content'])
86
- end
87
- end
88
-
89
- def prepend_to_file(injections)
90
- return if injections.nil? || injections.empty?
91
-
92
- thor_app = ::RailsPlan::RailsApp.new
93
-
94
- injections.each do |injection|
95
- thor_app.insert_into_file(injection['file_path'], injection['content'], after: injection['after'])
96
- end
97
- end
98
-
99
- def append_code(appends)
100
- return if appends.nil? || appends.empty?
101
-
102
- thor_app = ::RailsPlan::RailsApp.new
103
-
104
- appends.each do |append|
105
- thor_app.append_to_file(append['file_path'], append['content'])
106
- end
107
- end
108
-
109
- def update_files(updates)
110
- return if updates.nil? || updates.empty?
111
-
112
- thor_app = ::RailsPlan::RailsApp.new
113
-
114
- updates.each do |update|
115
- thor_app.gsub_file(update['file_path'], update['pattern'], update['value'])
116
- end
117
- end
118
-
119
- def clone_files(files)
120
- return if files.nil? || files.empty?
121
-
122
- files.each do |file|
123
- FileUtils.cp(file['from'], file['to'])
124
- end
25
+ FileUtils.chmod_R("u+x", './bin')
125
26
  end
126
27
  end
127
28
  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.5
4
+ version: 0.0.7
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-07-09 00:00:00.000000000 Z
11
+ date: 2024-08-13 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
@@ -49,11 +35,8 @@ files:
49
35
  - README.md
50
36
  - bin/rplan
51
37
  - lib/rails_plan.rb
52
- - lib/rails_plan/cli/fetch_branch.rb
53
38
  - lib/rails_plan/cli/fetch_template.rb
54
39
  - lib/rails_plan/cli/processor.rb
55
- - lib/rails_plan/gem_version.rb
56
- - lib/rails_plan/rails_app.rb
57
40
  - lib/rails_plan/version.rb
58
41
  homepage: https://railsplan.com
59
42
  licenses:
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RailsPlan
4
- module Cli
5
- class FetchBranch
6
- API_URL = 'https://railsplan.com/api/v1'
7
-
8
- def call(uid)
9
- response = RestClient.get(API_URL + "/branches/#{uid}") { |res| res }
10
-
11
- return if response.code != 200
12
-
13
- JSON.parse(response.body)
14
- end
15
- end
16
- end
17
- end
@@ -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