camping 3.0.0 → 3.0.2

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: '052823190781b546bd66ebc9b1e2a164f865d9ad458bb22d81ce44b283644765'
4
- data.tar.gz: 4508bee443828152aaa80195e8444a69dcce31fd4d29327b1cab0fa33956d263
3
+ metadata.gz: 6aa52530d539466610a0ae7b505a72176f38b2ba12975f776447dcfb4e6d6934
4
+ data.tar.gz: 31c521e39db07c10472bff1d6e56bec41b55052bf0e40b3a8165e1266873815b
5
5
  SHA512:
6
- metadata.gz: 8601001442164208e68d09f7d3f03f966c9a421bb4ad0e6b52358557732e785ec8ee838e3a951f07f1b6d021197bdcc5eb7b395ae8eba5f328fa589324cbad10
7
- data.tar.gz: 061ff21f2a306316d99dfc601a3581f940bffdda253904ffbbe60a283fa43a3c7f876ddb3ef3e4d19ab96006437af9575056e52dbfa663ec262c948854d01213
6
+ metadata.gz: 200a6af8d4e245e7bf1fac8bb5965ec9ec2a049fc2b3965b9129e5fcc296f251de7ec5fd83656bde13dac6e2869692f52dd5d707e5718e84a498da1f742f7d07
7
+ data.tar.gz: b80af113694c5303ab1c955876dd6e6e0eb78d0324fa2b4d16f9361b8c8114e0af1cfdffd6761d452a22a3ee5c8febc679078ed50978a2d8a1385806d6da208b
@@ -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
@@ -174,7 +193,7 @@ module #{app_name}
174
193
  end
175
194
 
176
195
  def index
177
- h2 'Let\'s go Camping'
196
+ h2 "Let's go Camping"
178
197
  end
179
198
 
180
199
  end
@@ -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
- snake_app_name = Camping::CommandsHelpers.to_snake_case(app_name)
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("#{snake_app_name}") unless Dir.exist?("#{snake_app_name}")
361
- Dir.chdir("#{snake_app_name}")
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(app_name)
382
+ Generators::make_camp_file(camel_name)
365
383
  Generators::make_gitignore()
366
384
  Generators::make_rakefile()
367
385
  Generators::make_ruby_version()
@@ -15,7 +15,6 @@ module Gear
15
15
 
16
16
  class << self
17
17
 
18
-
19
18
  # normalizes the routes provided to the controller, then returns some variables
20
19
  # used in make_camping_route
21
20
  def normalize_routes(routes)
@@ -1,5 +1,5 @@
1
1
  module Camping
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.2"
3
3
  def self.version
4
4
  VERSION
5
5
  end
@@ -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.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - why the lucky stiff
@@ -104,20 +104,6 @@ dependencies:
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: 1.0.3
107
- - !ruby/object:Gem::Dependency
108
- name: listen
109
- requirement: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: '3.8'
114
- type: :runtime
115
- prerelease: false
116
- version_requirements: !ruby/object:Gem::Requirement
117
- requirements:
118
- - - "~>"
119
- - !ruby/object:Gem::Version
120
- version: '3.8'
121
107
  description:
122
108
  email: why@ruby-lang.org
123
109
  executables:
@@ -186,6 +172,7 @@ files:
186
172
  - test/app_config.rb
187
173
  - test/app_cookies.rb
188
174
  - test/app_file.rb
175
+ - test/app_generator.rb
189
176
  - test/app_goes_meta.rb
190
177
  - test/app_helpers.rb
191
178
  - test/app_inception.rb
@@ -236,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
223
  - !ruby/object:Gem::Version
237
224
  version: '0'
238
225
  requirements: []
239
- rubygems_version: 3.4.10
226
+ rubygems_version: 3.4.12
240
227
  signing_key:
241
228
  specification_version: 4
242
229
  summary: micro mighty websites for anyone