rails_plan 0.0.4 → 0.0.5

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: e800d9904813591e2c13377191719763fdf89b6924de4483595bab720273e988
4
+ data.tar.gz: 0b960db29b50211a2ba51653db3a52869397be95e400482be4c8bd63fd797973
5
5
  SHA512:
6
- metadata.gz: 9f3a6ae5c736b3b6345760dbee23be420b360798962bade77fde65d349f45b6c06fa0589c0adc47b0646285d2cb2056b55d76e0eba7a2994b3ee288179079157
7
- data.tar.gz: 6f3d97472e4f309079bde3f40d760e344adfc174f75ea1264caaafe04d4c7ce82d516e2985a254151881cc61411f028951034df83f6245dee274a1fbb5894f8b
6
+ metadata.gz: 9d79af72fad1e7db9df46e8a7710dc78600f10aa33e589482c3c00367a8dd92af3496b376f05531874faa3d904855174015987662e569543d4bd742e8a2036c9
7
+ data.tar.gz: 790518e6748bc2c3211352c9da990ba234a9c77801edc0f3883405f9e558cac26034524451b0b401fcc574aa38623409b68122555cda247556a79da363b788f7
@@ -0,0 +1,17 @@
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
@@ -3,7 +3,6 @@
3
3
  module RailsPlan
4
4
  module Cli
5
5
  class FetchTemplate
6
- COMMANDS = %w[apply].freeze
7
6
  API_URL = 'https://railsplan.com/api/v1'
8
7
 
9
8
  def call(uid)
@@ -3,7 +3,7 @@
3
3
  module RailsPlan
4
4
  module Cli
5
5
  class Processor
6
- COMMANDS = %w[start].freeze
6
+ COMMANDS = %w[start apply].freeze
7
7
 
8
8
  InvalidCommand = Class.new(StandardError)
9
9
  InvalidUid = Class.new(StandardError)
@@ -16,9 +16,13 @@ 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, "Bootstrap plan or feature not found for #{@uid}" if json_template.nil?
20
20
 
21
- ::RailsPlan.start(json_template)
21
+ if @command == 'start'
22
+ ::RailsPlan.start(json_template)
23
+ elsif @command == 'apply'
24
+ ::RailsPlan.apply(json_template)
25
+ end
22
26
  end
23
27
 
24
28
  private
@@ -30,7 +34,11 @@ module RailsPlan
30
34
  def json_template
31
35
  return @json_template if defined?(@json_template)
32
36
 
33
- @json_template = ::RailsPlan::Cli::FetchTemplate.new.call(@uid)
37
+ @json_template = if @command == 'start'
38
+ ::RailsPlan::Cli::FetchTemplate.new.call(@uid)
39
+ else
40
+ ::RailsPlan::Cli::FetchBranch.new.call(@uid)
41
+ end
34
42
  end
35
43
  end
36
44
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPlan
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
5
5
  RAILS_VERSION = '7.1.3.3'
6
6
  end
data/lib/rails_plan.rb CHANGED
@@ -6,6 +6,7 @@ require 'fileutils'
6
6
  require 'thor'
7
7
 
8
8
  require 'rails_plan/cli/fetch_template'
9
+ require 'rails_plan/cli/fetch_branch'
9
10
  require 'rails_plan/cli/processor'
10
11
  require 'rails_plan/version'
11
12
  require 'rails_plan/rails_app'
@@ -18,7 +19,7 @@ module RailsPlan
18
19
  def start(template)
19
20
  ::RailsPlan::GemVersion.validate!
20
21
 
21
- verify_rails_installation
22
+ # verify_rails_installation
22
23
 
23
24
  generate_project(template)
24
25
  generate_files(template['files'])
@@ -37,6 +38,14 @@ module RailsPlan
37
38
  end
38
39
  end
39
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
+
40
49
  private
41
50
 
42
51
  def verify_rails_installation
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.5
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-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -49,6 +49,7 @@ files:
49
49
  - README.md
50
50
  - bin/rplan
51
51
  - lib/rails_plan.rb
52
+ - lib/rails_plan/cli/fetch_branch.rb
52
53
  - lib/rails_plan/cli/fetch_template.rb
53
54
  - lib/rails_plan/cli/processor.rb
54
55
  - lib/rails_plan/gem_version.rb