camping 3.0.1 → 3.0.2
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 +4 -4
- data/lib/camping/commands.rb +24 -6
- data/lib/camping/gear/nancy.rb +0 -1
- data/lib/camping/version.rb +1 -1
- data/test/app_generator.rb +43 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aa52530d539466610a0ae7b505a72176f38b2ba12975f776447dcfb4e6d6934
|
4
|
+
data.tar.gz: 31c521e39db07c10472bff1d6e56bec41b55052bf0e40b3a8165e1266873815b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 200a6af8d4e245e7bf1fac8bb5965ec9ec2a049fc2b3965b9129e5fcc296f251de7ec5fd83656bde13dac6e2869692f52dd5d707e5718e84a498da1f742f7d07
|
7
|
+
data.tar.gz: b80af113694c5303ab1c955876dd6e6e0eb78d0324fa2b4d16f9361b8c8114e0af1cfdffd6761d452a22a3ee5c8febc679078ed50978a2d8a1385806d6da208b
|
data/lib/camping/commands.rb
CHANGED
@@ -11,6 +11,25 @@ module Camping
|
|
11
11
|
downcase
|
12
12
|
end
|
13
13
|
|
14
|
+
# transform app_name to camel Case
|
15
|
+
def self.to_camel_case(string)
|
16
|
+
cammelled = ""
|
17
|
+
to_snake_case(string).split("_").each do |seq|
|
18
|
+
cammelled << seq.capitalize
|
19
|
+
end
|
20
|
+
cammelled
|
21
|
+
end
|
22
|
+
|
23
|
+
# Helper method that generates an app name from command line input.
|
24
|
+
def self.app_name_from_input(app_name)
|
25
|
+
app_name = :Camp if app_name == nil
|
26
|
+
app_name = app_name.to_sym if app_name.class == String
|
27
|
+
snake_app_name = to_snake_case(app_name)
|
28
|
+
camel_app_name = to_camel_case(snake_app_name)
|
29
|
+
|
30
|
+
{app_name: camel_app_name.to_sym, snake_name: snake_app_name, camel_name: camel_app_name}
|
31
|
+
end
|
32
|
+
|
14
33
|
RouteCollection = Struct.new(:routes)
|
15
34
|
class RouteCollection
|
16
35
|
# Displays formatted routes from a route collection
|
@@ -350,18 +369,17 @@ RUBY
|
|
350
369
|
end
|
351
370
|
|
352
371
|
def self.new_cmd(app_name=:Camp)
|
353
|
-
app_name = :Camp if app_name == nil
|
354
|
-
app_name = app_name.to_sym if app_name.class == String
|
355
372
|
|
356
|
-
|
373
|
+
# Normalize the app_name
|
374
|
+
Camping::CommandsHelpers.app_name_from_input(app_name) => {app_name:, snake_name:, camel_name:}
|
357
375
|
|
358
376
|
# make a directory then move there.
|
359
377
|
# _original_dir = Dir.pwd
|
360
|
-
Dir.mkdir("#{
|
361
|
-
Dir.chdir("#{
|
378
|
+
Dir.mkdir("#{snake_name}") unless Dir.exist?("#{snake_name}")
|
379
|
+
Dir.chdir("#{snake_name}")
|
362
380
|
|
363
381
|
# generate a new camping app in a directory named after it:
|
364
|
-
Generators::make_camp_file(
|
382
|
+
Generators::make_camp_file(camel_name)
|
365
383
|
Generators::make_gitignore()
|
366
384
|
Generators::make_rakefile()
|
367
385
|
Generators::make_ruby_version()
|
data/lib/camping/gear/nancy.rb
CHANGED
data/lib/camping/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'camping'
|
3
|
+
require 'camping/commands'
|
4
|
+
|
5
|
+
Camping.goes :Generator
|
6
|
+
|
7
|
+
class Generator::Test < TestCase
|
8
|
+
|
9
|
+
def app_name(string)
|
10
|
+
Camping::CommandsHelpers.app_name_from_input string
|
11
|
+
end
|
12
|
+
|
13
|
+
# the app_name_from_input method normalizes the input for the camping new command.
|
14
|
+
# making sure it works right is kinda important.
|
15
|
+
def test_app_name_from_input_method
|
16
|
+
|
17
|
+
# input is expected, a symbol camel cased
|
18
|
+
app_name(:AppApp) => {app_name:, snake_name:, camel_name:}
|
19
|
+
assert_equal :AppApp, app_name, "app_name was unexpected: #{app_name}"
|
20
|
+
assert_equal "app_app", snake_name, "snake_name was unexpected: #{snake_name}"
|
21
|
+
assert_equal "AppApp", camel_name, "camel_name was unexpected: #{camel_name}"
|
22
|
+
|
23
|
+
# input is un expected, a camel cased string
|
24
|
+
app_name("AppApp") => {app_name:, snake_name:, camel_name:}
|
25
|
+
assert_equal :AppApp, app_name, "app_name was unexpected: #{app_name}"
|
26
|
+
assert_equal "app_app", snake_name, "snake_name was unexpected: #{snake_name}"
|
27
|
+
assert_equal "AppApp", camel_name, "camel_name was unexpected: #{camel_name}"
|
28
|
+
|
29
|
+
# input is un unexpected snake cased string
|
30
|
+
app_name("app_app") => {app_name:, snake_name:, camel_name:}
|
31
|
+
assert_equal :AppApp, app_name, "app_name was unexpected: #{app_name}"
|
32
|
+
assert_equal "app_app", snake_name, "snake_name was unexpected: #{snake_name}"
|
33
|
+
assert_equal "AppApp", camel_name, "camel_name was unexpected: #{camel_name}"
|
34
|
+
|
35
|
+
# input is un unexpected snake cased symbol
|
36
|
+
app_name(:app_app) => {app_name:, snake_name:, camel_name:}
|
37
|
+
assert_equal :AppApp, app_name, "app_name was unexpected: #{app_name}"
|
38
|
+
assert_equal "app_app", snake_name, "snake_name was unexpected: #{snake_name}"
|
39
|
+
assert_equal "AppApp", camel_name, "camel_name was unexpected: #{camel_name}"
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- why the lucky stiff
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- test/app_config.rb
|
173
173
|
- test/app_cookies.rb
|
174
174
|
- test/app_file.rb
|
175
|
+
- test/app_generator.rb
|
175
176
|
- test/app_goes_meta.rb
|
176
177
|
- test/app_helpers.rb
|
177
178
|
- test/app_inception.rb
|
@@ -222,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
223
|
- !ruby/object:Gem::Version
|
223
224
|
version: '0'
|
224
225
|
requirements: []
|
225
|
-
rubygems_version: 3.4.
|
226
|
+
rubygems_version: 3.4.12
|
226
227
|
signing_key:
|
227
228
|
specification_version: 4
|
228
229
|
summary: micro mighty websites for anyone
|