swag 0.1.3 → 0.1.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
  SHA1:
3
- metadata.gz: 76867ad92e5bbe1f401428fc7fe9d269fc6f3163
4
- data.tar.gz: a0c20ffe2fa3de2e6c3207bcf66462dc255b6e8f
3
+ metadata.gz: 077a5dda48161479471423784a17bb99dc24317d
4
+ data.tar.gz: fe0751c8e7716bb37df5858da1f94e043dabeb40
5
5
  SHA512:
6
- metadata.gz: 8c24ac0d39c3802f723875f3cc3cb6152e31d1004f302b6ab7ab831004c1cb9b4293312bb2b39e27eed347a1291816fd8a659211780b5f2b452d16e22a58d7f8
7
- data.tar.gz: 4ca04c7d089935ee5e34fb86f1f013305ab5f99c89777cb373608f5556915fe5ef0a7faa804419fb742945ef87840497b01ab2487bb0ed9e43abecb074d60a67
6
+ metadata.gz: a0314a072fa5ba8d50e74672d0120ba9ef1093fb4ae49a84e7e3a0c7828257b549c7ec2dcffa7200ee82bc3c49e27e6a2a0a1b1d073817a0fa199ff01b021455
7
+ data.tar.gz: c899dda7f021015230297235e7c3cca06fc7d50f5dfdbe1fac697b7ee9daeecea918ecaebb1efed8fef6569be6bd64123de7b650b6bac66f4e5925e8f0f8504f
@@ -0,0 +1 @@
1
+ $SWAG_VERSION = '0.1.5'
@@ -1,4 +1,5 @@
1
- require_relative 'SwagHelper.rb'
1
+ require_relative 'swag_helper.rb'
2
+ require_relative 'global_vars.rb'
2
3
 
3
4
  class Swag
4
5
 
@@ -49,9 +50,9 @@ class Swag
49
50
  @show = false
50
51
  c.each_line do |line|
51
52
  if line.include? "def index"
52
- @helper.doIndex(controllerName, doc)
53
+ @helper.doIndex(nameSliced, controllerName, doc)
53
54
  elsif line.include? "def create"
54
- @helper.doCreate(controllerName, doc)
55
+ @helper.doCreate(nameSliced, controllerName, doc)
55
56
  elsif line.include? "def show"
56
57
  @show = true
57
58
  end
@@ -64,14 +65,15 @@ class Swag
64
65
 
65
66
  # lists controller paths by reading app/controllers directory
66
67
  def self.writePaths
67
- puts "Writing paths."
68
+ puts "Writing paths."
68
69
  begin
69
70
  # creates directory for swag to use
70
71
  Dir.mkdir("swagGem") unless File.exists?("swagGem")
71
-
72
72
  doc = File.open("swagGem/api.yml", 'w')
73
- doc << "info: Generated with Swag.\n"
74
- doc << "paths:\n"
73
+
74
+ # sets up doc w/ config info
75
+ @helper.checkConfig(doc)
76
+
75
77
  Dir.foreach("app/controllers") do |c|
76
78
  unless (c == "." || c == ".." || c == "concerns" ||
77
79
  c == "application_controller.rb")
@@ -0,0 +1,62 @@
1
+ require_relative 'global_vars.rb'
2
+
3
+ class SwagHelper
4
+
5
+ def initialize
6
+ end
7
+
8
+ def readConfig(doc)
9
+ File.open("swagGem/config.yml", 'r') do |c|
10
+ c.each_line do |line|
11
+ doc << "#{line}"
12
+ end # end each line block
13
+ end # close File block
14
+ end
15
+
16
+ def writeConfig
17
+ config = File.open("swagGem/config.yml", 'w')
18
+ config << "swag: #{$SWAG_VERSION}\n"
19
+ config << "info:\n"
20
+ config << " version:\n"
21
+ config << " title: #{File.basename(Dir.getwd)}\n"
22
+ config << " description: a Rails app.\n"
23
+ config << " author:\n"
24
+ config << " name:\n"
25
+ config << " contact:\n"
26
+ config << " license:\n"
27
+ config << "paths:\n"
28
+ config.close
29
+ end
30
+
31
+ # checks config info
32
+ def checkConfig(doc)
33
+ # open config file (if it exists)
34
+ # read line-by-line
35
+ # write relevant information to doc
36
+ if File.exists?("swagGem/config.yml")
37
+ readConfig(doc)
38
+ else
39
+ writeConfig
40
+ readConfig(doc)
41
+ end
42
+ end
43
+
44
+ # prints index info to open YAML File 'doc'
45
+ def doIndex(nameSliced, controllerName, doc)
46
+ puts "#{controllerName} contains index"
47
+ doc << " get:\n"
48
+ doc << " description: returns an index for this resource.\n"
49
+ end
50
+
51
+ def doCreate(nameSliced, controllerName, doc)
52
+ puts "#{controllerName} contains new"
53
+ doc << " post:\n"
54
+ singular = controllerName.slice(0..(nameSliced.index('s') -1))
55
+ doc << " description: creates a new instance of this resource.\n"
56
+ end
57
+
58
+ def doShow(nameSliced, controllerName, doc)
59
+ puts "#{controllerName} contains show"
60
+ doc << " /#{nameSliced}/:id\n"
61
+ end
62
+ end # end class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Miller
@@ -20,8 +20,9 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - bin/swag
23
- - lib/Swag.rb
24
- - lib/SwagHelper.rb
23
+ - lib/global_vars.rb
24
+ - lib/swag.rb
25
+ - lib/swag_helper.rb
25
26
  homepage: http://rubygems.org/gems/swag
26
27
  licenses:
27
28
  - BSD-3-Clause
data/lib/SwagHelper.rb DELETED
@@ -1,32 +0,0 @@
1
- class SwagHelper
2
-
3
- def initialize
4
- end
5
-
6
- # writes config info to YAML doc
7
- def doConfig(doc)
8
- # open config file (make one if it doesn't exist)
9
- # read line-by-line
10
- # write relevant information to doc
11
- doc << "info: Generated with Swag.\n"
12
- doc << "paths:\n"
13
- end
14
-
15
- # prints index info to open YAML File 'doc'
16
- def doIndex(controllerName, doc)
17
- puts "#{controllerName} contains index"
18
- doc << " get:\n"
19
- doc << " description:\n"
20
- end
21
-
22
- def doCreate(controllerName, doc)
23
- puts "#{controllerName} contains new"
24
- doc << " post:\n"
25
- doc << " description:\n"
26
- end
27
-
28
- def doShow(nameSliced, controllerName, doc)
29
- puts "#{controllerName} contains show"
30
- doc << " /#{nameSliced}/:id\n"
31
- end
32
- end # end class