railspp 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 437ff81dcb23189dfa9a0aba36d7f354cc88b52223763e43dc96cb352051376c
4
- data.tar.gz: 4999dc0e3501275b63c67053b089b89014f6a31c48db8b3a5d22d08b251aacbf
3
+ metadata.gz: b407a28c73d30980a7d66982621dcdb85fa5e08a49bf39e7ad98efb33dd4ab46
4
+ data.tar.gz: f2ebc4d1de1011b96f5da1aba75c6b285c0f63b686df3ff57aac63469a672fba
5
5
  SHA512:
6
- metadata.gz: 025e81527e86528ecbab90cc4fce2160288cbe5cb6001fb2eaf6dd98a7bda24de288f9941f4df4a108a17d2d41207cf5254be8ade1a1467c0d9f2884f847cf16
7
- data.tar.gz: 12efabc32329cdf717f2a88fe33dc7a7403edfc618336254a038a4530b3fe3b835e3a71310cc4b27c8d66eb57b0039217547eac1fa777b57d131a631c9756d26
6
+ metadata.gz: 180e7c08b9988dd129576484d6b3e4e8341dd87e2d6e36d955fa94987db5c5e8c3221061c44c4e18e119ff5b05faf920bbfec8da9aca41ca5cd3ba005a957ee9
7
+ data.tar.gz: 241a004800dd76cb0408bf7419b7543fdfb5560a2c3668ab055ae5be9463796a2619b7783e3db94f84125a6910261a349c65a5b1bd2ce55a45964f8ea1be0bdb
@@ -0,0 +1,50 @@
1
+ require_relative '../utils/strings.rb'
2
+
3
+
4
+ class ApiDocsCommand < MoreUtils
5
+ class << self
6
+
7
+ def run(*args)
8
+ lookup = flag_lookup(args)
9
+
10
+ # Add Initializers
11
+ adi_template = get_file_str("#{this_dir}/../templates/api_documentation_initializer.txt")
12
+ write_file("#{root}/config/initializers/api_documentation_js.rb", adi_template)
13
+
14
+ # Add Controllers
15
+ dc_template = get_file_str("#{this_dir}/../templates/documentation_controller.txt")
16
+ write_file("#{root}/app/controllers/documentation_controller.rb", dc_template)
17
+
18
+ # Add Service
19
+ system("mkdir -p #{root}/app/services")
20
+ aps_template = get_file_str("#{this_dir}/../templates/api_documentation_service.txt")
21
+ write_file("#{root}/app/services/api_documentation_service.rb", aps_template)
22
+
23
+ # Add Views
24
+ system("mkdir -p #{root}/app/views/documentation")
25
+ dihtml_template = get_file_str("#{this_dir}/../templates/documentation.index.erb.txt")
26
+ write_file("#{root}/app/views/documentation/index.html.erb", dihtml_template)
27
+
28
+ dlhtml_template = get_file_str("#{this_dir}/../templates/documentation.layout.erb.txt")
29
+ write_file("#{root}/app/views/layouts/documentation.html.erb", dlhtml_template)
30
+
31
+ # Add Routes
32
+ routes_template = get_file_str("#{this_dir}/../templates/routes_documentation.txt")
33
+ routes_file = get_file_str("#{root}/config/routes.rb")
34
+ routes_arr = routes_file.split("\n")
35
+ last_end_line = last_end_index(routes_arr)
36
+ new_routes = routes_arr.slice(0, last_end_line).join("\n") + "\n#{routes_template}\n" + routes_arr.slice(last_end_line, routes_arr.length).join("\n")
37
+ write_file("#{root}/config/routes.rb", new_routes)
38
+
39
+ puts "Added Automatic API documentation to your project."
40
+ end
41
+
42
+ def last_end_index arr
43
+ arr.each_with_index.inject(0) do |acc, (e, i)|
44
+ acc = i if /(namespace)/.match(e) && acc == 0
45
+ acc
46
+ end
47
+ end
48
+
49
+ end
50
+ end
@@ -11,13 +11,7 @@ class InitializeCommand < MoreUtils
11
11
  cors_template = get_file_str("#{this_dir}/../templates/rack_cors_initializer.txt")
12
12
  write_file("#{root}/config/initializers/cors.rb", cors_template)
13
13
 
14
- adi_template = get_file_str("#{this_dir}/../templates/api_documentation_initializer.txt")
15
- write_file("#{root}/config/initializers/api_documentation_js.rb", adi_template)
16
-
17
14
  # Add Controllers
18
- dc_template = get_file_str("#{this_dir}/../templates/documentation_controller.txt")
19
- write_file("#{root}/app/controllers/documentation_controller.rb", dc_template)
20
-
21
15
  gc_template = get_file_str("#{this_dir}/../templates/global_controller.txt")
22
16
  write_file("#{root}/app/controllers/global_controller.rb", gc_template)
23
17
 
@@ -28,22 +22,9 @@ class InitializeCommand < MoreUtils
28
22
  resp_template = get_file_str("#{this_dir}/../templates/response.txt")
29
23
  write_file("#{root}/app/controllers/concerns/response.rb", resp_template)
30
24
 
31
- # Add Service
32
- system("mkdir -p #{root}/app/services")
33
- aps_template = get_file_str("#{this_dir}/../templates/api_documentation_service.txt")
34
- write_file("#{root}/app/services/api_documentation_service.rb", aps_template)
35
-
36
- # Add Views
37
- system("mkdir -p #{root}/app/views/documentation")
38
- dihtml_template = get_file_str("#{this_dir}/../templates/documentation.index.erb.txt")
39
- write_file("#{root}/app/views/documentation/index.html.erb", dihtml_template)
40
-
41
- dlhtml_template = get_file_str("#{this_dir}/../templates/documentation.layout.erb.txt")
42
- write_file("#{root}/app/views/layouts/documentation.html.erb", dlhtml_template)
43
-
44
25
  # Update Routes
45
26
  unless lookup.has_key?(:"skip-routes")
46
- routes_template = get_file_str("#{this_dir}/../templates/routes_documentation.txt")
27
+ routes_template = get_file_str("#{this_dir}/../templates/routes_namespace.txt")
47
28
  routes_file = get_file_str("#{root}/config/routes.rb")
48
29
  routes_arr = routes_file.split("\n")
49
30
  last_end_line = last_end_index(routes_arr)
@@ -13,13 +13,6 @@ class UpdateVersionCommand < MoreUtils
13
13
  gc_template = get_file_str("#{this_dir}/../templates/response.txt")
14
14
  write_file("#{root}/app/controllers/concerns/response.rb", gc_template)
15
15
 
16
- # dc_template = get_file_str("#{this_dir}/../templates/documentation_controller.txt")
17
- # write_file("#{root}/app/controllers/documentation_controller.rb", dc_template)
18
-
19
- # Add Service
20
- # aps_template = get_file_str("#{this_dir}/../templates/api_documentation_service.txt")
21
- # write_file("#{root}/app/services/api_documentation_service.rb", aps_template)
22
-
23
16
  puts "Updated your code base for Rails Plus Plus version: #{gem_version}"
24
17
  end
25
18
 
@@ -0,0 +1,16 @@
1
+ require_relative '../utils/strings.rb'
2
+
3
+
4
+ class ApiDocsHelpCommand < MoreUtils
5
+ class << self
6
+
7
+ def run(*args)
8
+ puts "No Options available
9
+
10
+ Update your version of rails plus plus in your code base:
11
+ 'railspp api_docs'
12
+ "
13
+ end
14
+
15
+ end
16
+ end
@@ -1,7 +1,9 @@
1
1
  require_relative './commands/initialize.rb'
2
+ require_relative './commands/api_docs.rb'
2
3
  require_relative './commands/model.rb'
3
4
  require_relative './commands/make_test.rb'
4
5
  require_relative './commands/update_version.rb'
6
+ require_relative './help/api_docs.rb'
5
7
  require_relative './help/documentation.rb'
6
8
  require_relative './help/initialize.rb'
7
9
  require_relative './help/model.rb'
@@ -49,6 +51,8 @@ class RailsPlusPlus < MoreUtils
49
51
  make_test: MakeTestCommand,
50
52
  uv: UpdateVersionCommand,
51
53
  update_version: UpdateVersionCommand,
54
+ ad: ApiDocsCommand,
55
+ api_docs: ApiDocsCommand,
52
56
  }
53
57
  end
54
58
 
@@ -63,6 +67,8 @@ class RailsPlusPlus < MoreUtils
63
67
  make_test: MakeTestHelpCommand,
64
68
  uv: UpdateVersionHelpCommand,
65
69
  update_version: UpdateVersionHelpCommand,
70
+ ad: ApiDocsHelpCommand,
71
+ api_docs: ApiDocsHelpCommand,
66
72
  }
67
73
  end
68
74
 
@@ -75,6 +81,8 @@ class RailsPlusPlus < MoreUtils
75
81
  '- model => Generate your CRUD model, controller, and migration',
76
82
  '- mt => Generate a unit test in minitest',
77
83
  '- make_test => Generate a unit test in minitest',
84
+ '- ad => Initialize your api documentation',
85
+ '- api_docs => Initialize your api documentation',
78
86
  '- uv => Update your version of Rails Plus Plus in your code base',
79
87
  '- update_version => Update your version of Rails Plus Plus in your code base',
80
88
  ]
@@ -0,0 +1,8 @@
1
+ namespace :api, except: [:new, :edit] do
2
+ # Add API Routes here
3
+
4
+ # For API version 1
5
+ namespace :v1 do
6
+
7
+ end
8
+ end
@@ -1,10 +1 @@
1
- resources :documentation, only: :index
2
-
3
- namespace :api, except: [:new, :edit] do
4
- # Add API Routes here
5
-
6
- # For API version 1
7
- namespace :v1 do
8
-
9
- end
10
- end
1
+ resources :documentation, only: :index
@@ -1,10 +1,8 @@
1
- resources :documentation, only: :index
2
-
3
- namespace :api do
1
+ namespace :api, except: [:new, :edit] do
4
2
  # Add API Routes here
5
3
 
6
4
  # For API version 1
7
5
  namespace :v1 do
8
6
 
9
7
  end
10
- end
8
+ end
@@ -21,7 +21,7 @@ class MoreUtils
21
21
  class << self
22
22
 
23
23
  def gem_version
24
- "0.3.3"
24
+ "0.3.4"
25
25
  end
26
26
 
27
27
  def get_file_str path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railspp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Layne Faler
@@ -61,10 +61,12 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - README.md
63
63
  - bin/railspp
64
+ - lib/commands/api_docs.rb
64
65
  - lib/commands/initialize.rb
65
66
  - lib/commands/make_test.rb
66
67
  - lib/commands/model.rb
67
68
  - lib/commands/update_version.rb
69
+ - lib/help/api_docs.rb
68
70
  - lib/help/documentation.rb
69
71
  - lib/help/initialize.rb
70
72
  - lib/help/make_test.rb
@@ -82,6 +84,7 @@ files:
82
84
  - lib/templates/mini_test_controller.txt
83
85
  - lib/templates/rack_cors_initializer.txt
84
86
  - lib/templates/response.txt
87
+ - lib/templates/routes.txt
85
88
  - lib/templates/routes_documentation.txt
86
89
  - lib/templates/routes_namespace.txt
87
90
  - lib/utils/strings.rb