gembase 0.5.2 → 0.5.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/main.rb +58 -71
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6162f13c419f3668dc222f1c140e4b0d77c92b2510209f9b367c36f5479bf3dc
4
- data.tar.gz: a2f94a615514edd090ec5a636ca8d896ebfe8cb7ec7ae0875545857be9fe257b
3
+ metadata.gz: 4b2075c49a96fb7cfb47f1b1dcc0ce4990426d34899dbe5a6fb4e26bb3d89624
4
+ data.tar.gz: 7fe0747e86e9a39a03ad3aaf437ff26eeccac21fbbb5965759bc5caa2f54c6ea
5
5
  SHA512:
6
- metadata.gz: 97f1064ed4aebc48e195e791c6e790b97c8b211997cc4efc573fd3af8705bdf4e7925dbfcccba997b7df1b3c008f95d863fdb69f541e843abfa5ab8f4ff31362
7
- data.tar.gz: '080daf2ba39dddde40fc0f2faa6c109e594fa720e008c677871efa0ad2565b28b73f9cc8440d25890dd866b8e045b3d41720df16ebec959340c60b50c5a524d5'
6
+ metadata.gz: d318c786331cbfa72a0126dad32ae42197a62358ed1caaeee2ea7351ce41df3df366831f3ad67f7b5a2c45b2da05df8b0c94534875fa7b83ea56fda76892de52
7
+ data.tar.gz: e664207015a063c5d81c4721baf506e5ed737ebd579ab5baa8470f97dc7d9d112d7492ad8b8961c8df16b85b444fd6288fff5bf7ad07848bba16eadfbc2a80db
data/lib/main.rb CHANGED
@@ -2,28 +2,25 @@
2
2
  # NTBBloodbath | Gembase - Ruby DataBase
3
3
 
4
4
  require 'yaml'
5
+ require 'fileutils'
5
6
 
6
7
  # @author NTBBloodbath
7
8
  module Gembase
8
9
 
9
- # @!method create_db(name) {https://asciinema.org/a/l8CbUREGwZScWN2XJXv2lsTHt}
10
- # Create a new DataBase file with the given name
11
- # @param name [String] the name for your DataBase file
10
+ # Create a new DataBase file with the given name.
11
+ # name must be an String.
12
12
  #
13
- # @example Create a DB called example
14
- # create_db("example") #=> "example.rudb"
13
+ # create_db("example") #=> "example.rudb"
15
14
  def Gembase.create_db(name)
16
15
  raise "name must be an String" until name.is_a?(String)
17
16
  FileUtils.touch("#{name}.rudb")
18
17
  end
19
18
 
20
- # @!method create_category(db, category) {https://asciinema.org/a/Chz5eeUJdjFl8I07Lq4hY4X8y}
21
- # Create a new Category inside our DataBase
22
- # @param db [String] the name of your DataBase file
23
- # @param category [String] the name of your category
19
+ # Create a new Category inside our DataBase
20
+ # db must be an String.
21
+ # category must be an String.
24
22
  #
25
- # @example Creating the users category
26
- # create_category("example", "users")
23
+ # create_category("example", "foo")
27
24
  def Gembase.create_category(db, category)
28
25
  raise "db must be an String" until db.is_a?(String)
29
26
  raise "category must be an String" until category.is_a?(String)
@@ -37,16 +34,12 @@ module Gembase
37
34
  end
38
35
  end
39
36
 
40
- # @!method nested_category(db, parent_category, nested_category)
41
- # Create a new nested category
42
- # @param db [String] the nme of your DataBase file
43
- # @param parent_category [String] the name of your parent category
44
- # @param nested_category [String] the name of the nested category
37
+ # Create a new nested category
38
+ # db must be an String.
39
+ # parent_category must be an String.
40
+ # nested_category must be an String.
45
41
  #
46
- # @example Creating a premium nested category
47
- # nested_category("example", "users", "premium")
48
- #
49
- # @since 0.5.0
42
+ # nested_category("example", "foo", "bar")
50
43
  def Gembase.nested_category(db, parent_category, nested_category)
51
44
  raise "db must be an String" until db.is_a?(String)
52
45
  raise "parent_category must be an String" until parent_category.is_a?(String)
@@ -58,17 +51,15 @@ module Gembase
58
51
  @save = File.write(@database, @data.to_yaml)
59
52
  end
60
53
 
61
- # @!method add_object(db, category, key, value)
62
- # Create an object inside a category
63
- # @param db [String] the name of your DataBase file
64
- # @param category [String] the name of your category
65
- # @param key [String] the key name of your object
66
- # @param value [String, Integer, Boolean] the value of your key
54
+ # Create an object inside a category
55
+ # db must be an String.
56
+ # category must be an String.
57
+ # key must be an String.
58
+ # value can be String, Integer or Boolean.
67
59
  #
68
- # @example Add object "bloodbath" with value "premium"
69
- # add_object("example", "users", "bloodbath", "premium")
60
+ # add_object("example", "users", "bloodbath", "premium")
70
61
  #
71
- # @deprecated Use {#create_object-class_method} instead.
62
+ # [DEPRECATED] Use create_object Method instead.
72
63
  def Gembase.add_object(db, category, key, value)
73
64
  raise "db must be an String" until db.is_a?(String)
74
65
  raise "category must be an String" until category.is_a?(String)
@@ -80,21 +71,20 @@ module Gembase
80
71
  @data["#{category}"].store("#{key}", "#{value}")
81
72
  end
82
73
 
83
- # @!method create_object(db, key, value, category=nil, subcategory=nil)
84
- # Create an object outside a category
85
- # @param db [String] the name of your DataBase file
86
- # @param key [String] the key name of your object
87
- # @param value [String, Integer, Boolean] the value of your key
88
- # @param category [String] the name of your category
89
- # @param subcategory [String] the name of your subcategory
90
- #
91
- # @example Create object "server" with value "localhost:8080". Without categories.
74
+ # Create an object outside a category
75
+ # db must be an String.
76
+ # key must be an String.
77
+ # value can be String, Integer or Boolean.
78
+ # category must be an String.
79
+ # subcategory must be an String.
80
+ #
81
+ # Create object "server" with value "localhost:8080". Without categories.
92
82
  # create_object("example", "server", "localhost:8080")
93
83
  #
94
- # @example Create object "users-limit" with value 5 in "users" category.
84
+ # Create object "users-limit" with value 5 in "users" category.
95
85
  # create_object("example", "users-limit", 5, "users")
96
86
  #
97
- # @example Create object "bloodbath" with value true in "premium" subcategory.
87
+ # Create object "bloodbath" with value true in "premium" subcategory.
98
88
  # create_object("example", "bloodbath", true, "users", "premium")
99
89
  def Gembase.create_object(db, key, value, category=nil, subcategory=nil)
100
90
  raise "db must be an String" until db.is_a?(String)
@@ -123,27 +113,27 @@ module Gembase
123
113
  end
124
114
 
125
115
  # @!method delete_object(db, key, category=nil, subcategory=nil)
126
- # Delete an object inside/outside a category.
127
- # @param db [String] the name of your DataBase file
128
- # @param key [String] the key name of your object
129
- # @param category [String] the name of your category
130
- # @param subcategory [String] the name of your subcategory
116
+ # Delete an object inside/outside a category and subcategory.
117
+ # db must be an String.
118
+ # key must be an String.
119
+ # category must be an String.
120
+ # subcategory must be an String.
131
121
  #
132
- # @example Deleting object inside a category
122
+ # Deleting object inside a category
133
123
  # delete_object("example", "users-limit", "users")
134
124
  #
135
- # @ example Deleting object inside a subcategory
125
+ # Deleting object inside a subcategory
136
126
  # delete_object("example", "bloodbath", "users", "premium")
137
127
  #
138
- # @example Deleting object outside a category
128
+ # Deleting object outside a category
139
129
  # delete_object("example", "server")
140
130
  #
141
- # @note Category is an optional parameter. Use this only when you want to delete an object inside a category.
131
+ # Note: Category and subcategory are an optional parameters. Use them only when you want to delete an object inside a category or subcategory.
142
132
  def Gembase.delete_object(db, key, category=nil, subcategory=nil)
143
133
  raise "db must be an String" until db.is_a?(String)
144
134
  raise "key must be an String" until key.is_a?(String)
145
135
 
146
- if category.to_s.length == 0 # If there's no category argument declared.
136
+ if category.to_s.length == 0
147
137
  @database
148
138
  @data
149
139
  @data.delete("#{key}")
@@ -151,7 +141,7 @@ module Gembase
151
141
  f.write(@data.to_yaml)
152
142
  end
153
143
  else
154
- if subcategory.to_s.length == 0 # If there's no subcategory argument declared.
144
+ if subcategory.to_s.length == 0
155
145
  raise "category must be an String" until category.is_a?(String)
156
146
  @database
157
147
  @data
@@ -171,24 +161,23 @@ module Gembase
171
161
  end
172
162
  end
173
163
 
174
- # @!method change_object(db, key, new_value, category=nil, subcategory=nil)
175
- # Change the value of an existing object
176
- # @param db [String] the name of your DataBase file
177
- # @param key [String] the key name of your object
178
- # @param new_value [String,Integer, Boolean] the new value of your key
179
- # @param category [String] the name of your category
180
- # @param subcategory [String] the name of your subcategory
164
+ # Change the value of an existing object
165
+ # db must be an String.
166
+ # key must be an String.
167
+ # new_value can be String, Integer or Boolean.
168
+ # category must be an String.
169
+ # subcategory must be an String.
181
170
  #
182
- # @example Change key server value from localhost:8080 to example_host.com outside categories
171
+ # Change key server value from localhost:8080 to example_host.com outside categories
183
172
  # change_object("example", "server", "example_host.com")
184
173
  #
185
- # @example Change key users-limit value from 5 to 10 into users category
174
+ # Change key users-limit value from 5 to 10 into users category
186
175
  # change_object("example", "users-limit", "10", "users")
187
176
  #
188
- # @example Change key bloodbath value from true to false into premium subcategory
177
+ # Change key bloodbath value from true to false into premium subcategory
189
178
  # change_object("example", "bloodbath", false, "users", "category")
190
179
  #
191
- # @since 0.5.0
180
+ # Note: Category and subcategory are an optional parameters. Use them only when you want to modify an object inside a category or subcategory.
192
181
  def Gembase.change_object(db, key, new_value, category=nil, subcategory=nil)
193
182
  raise "db must be an String" until db.is_a?(String)
194
183
  raise "key must be an String" until key.is_a?(String)
@@ -215,14 +204,13 @@ module Gembase
215
204
  end
216
205
  end
217
206
 
218
- # @!method parse(db)
219
- # Parse the DataBase structure to modify it
220
- # @param db [String] the name of your DataBase file
207
+ # Parse the Database structure to modify it
208
+ # db must be an String.
221
209
  #
222
- # @example Parsing the DB called "example"
210
+ # Parsing the DB called "example"
223
211
  # parse("example")
224
212
  #
225
- # @note You can use these two methods (parse and generate) instead of YAML vanilla methods (load and to_yaml).
213
+ # Note: You can use these two methods (parse and generate) instead of YAML vanilla methods (load and to_yaml).
226
214
  def Gembase.parse(db)
227
215
  raise "db must be an String" until db.is_a?(String)
228
216
 
@@ -230,11 +218,10 @@ module Gembase
230
218
  @data
231
219
  end
232
220
 
233
- # @!method regenerate(db)
234
- # Regenerate the DataBase stucture to YAML structure
235
- # @param db [String] the name of your DataBase file
221
+ # Regenerate the Database stucture to YAML structure
222
+ # db must be an String.
236
223
  #
237
- # @example Regenerating the DB called "example"
224
+ # Regenerating the DB called "example"
238
225
  # regenerate("example")
239
226
  def Gembase.regenerate(db)
240
227
  raise "db must be an String" until db.is_a?(String)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gembase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - NTB Bloodbath