culpa 0.5.2 → 0.6.0.1
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 +8 -8
- data/bin/culpa +26 -24
- data/lib/culpa.rb +2 -0
- data/lib/rspec_helper.rb +12 -12
- data/templates/Dockerfile +7 -1
- data/templates/Gemfile +1 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjMxNzJiMjhkMzhkZjk1YmZmYmQwMWQyOGU5MDlmYjAwNWRjYzZmNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWZhZjM2OWJmYjMyZDc2N2M5MWY3YzE3NGFlYjliNDdlM2FhMjAxMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWVkYjk0Mzg4YTY4N2UwMzRhMmI5M2UxYWZlMWE1Y2E0OWFhZWVlNzczZGM2
|
10
|
+
NTc3MWRlNTQwZTU4NTVlOTU2OWIxMjg2ZjAzMGQ4Y2UzYzI1ZjgwNzdjNGEy
|
11
|
+
MDNlNWIzZTUzYmZjZWZjMzNlZmNkY2JkNjVhZDQ5NjI4NmU0NjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmQ2YjBhYWFmNmY2NjViMTM3NWUyNTRmZjY1MTQxYzRjNTI3M2Q4NDdiMWU4
|
14
|
+
MzFiMjc1MDRkMTBmZWYxMDMyNzM4MTQzMGRjYjUzNDI0NGU2NmZjNjZiYmU0
|
15
|
+
ZDY2NGEyZjRjYjFkNmI3ZmViZjhjMDA1MmUxZWFjNGE3YmRjMmY=
|
data/bin/culpa
CHANGED
@@ -45,42 +45,46 @@ def create_project(project_path)
|
|
45
45
|
puts `rspec --init`
|
46
46
|
|
47
47
|
puts '==> Inject Culpa helpers in spec_helper.rb'
|
48
|
-
|
49
|
-
|
48
|
+
spec_helper_path = 'spec/spec_helper.rb'
|
49
|
+
spec_helper_path_tmp = spec_helper_path + '.new'
|
50
|
+
File.open(spec_helper_path_tmp, 'w') do |fo|
|
51
|
+
fo.puts "require 'culpa'"
|
52
|
+
fo.puts "require 'culpa/rspec_helper'"
|
53
|
+
File.foreach(spec_helper_path) do |li|
|
54
|
+
fo.puts li
|
55
|
+
fo.puts " config.include CulpaHelpers" if li == "=end\n"
|
56
|
+
end
|
50
57
|
end
|
58
|
+
FileUtils.rm(spec_helper_path)
|
59
|
+
FileUtils.mv(spec_helper_path_tmp, spec_helper_path)
|
51
60
|
end
|
52
61
|
|
53
62
|
def display_help
|
54
|
-
puts
|
63
|
+
puts "Welcome to Culpa ! The MEA framework. Version #{CULPA_VERSION}."
|
55
64
|
puts 'Usage : culpa [command] [args 1..n]'
|
56
65
|
puts 'Commands supported :'
|
57
|
-
puts ' - new [folder] :
|
58
|
-
puts ' - console :
|
66
|
+
puts ' - new [folder] : Creates a new culpa project on the specified folder'
|
67
|
+
puts ' - console : Drops an interactive shell within the running directory'
|
68
|
+
puts ' - server : Starts the web server'
|
69
|
+
puts ' - generate : '
|
70
|
+
puts ' - action [ActionName] [brick_a brick_b ...] : Creates an action'
|
71
|
+
puts ' - spec : Creates a spec'
|
59
72
|
puts ''
|
60
73
|
puts 'This software is distributed under the MIT license, available here : '
|
61
74
|
puts ' - https://raw.githubusercontent.com/HipsterWhale/culpa/master/LICENSE'
|
62
75
|
puts ''
|
63
76
|
end
|
64
77
|
|
65
|
-
def display_brick_chain
|
66
|
-
router_method_name = ARGV[1]
|
67
|
-
brickchain = Culpa::Application.new.generate_brickchain(router_method_name)
|
68
|
-
if brickchain
|
69
|
-
brickchain.each { |brick| puts " -> #{brick}" }
|
70
|
-
else
|
71
|
-
puts "Can't determine the brickchain of #{router_method_name}"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def generate_spec
|
76
|
-
end
|
77
|
-
|
78
78
|
def generate_action
|
79
79
|
erb_template = File.read(File.join(File.dirname(__FILE__), '../templates/generators/action.tmpl'))
|
80
80
|
@name = ARGV[2]
|
81
81
|
@bricks = ARGV.drop(3)
|
82
|
-
|
83
|
-
|
82
|
+
rendered_action = ERB.new(erb_template).result
|
83
|
+
end
|
84
|
+
|
85
|
+
def start_server
|
86
|
+
require 'rack'
|
87
|
+
Rack::Handler.default.run(Culpa::Application.new, Port: 4748)
|
84
88
|
end
|
85
89
|
|
86
90
|
case ARGV[0]
|
@@ -88,12 +92,10 @@ case ARGV[0]
|
|
88
92
|
create_project ARGV[1]
|
89
93
|
when 'console', 'c'
|
90
94
|
binding.pry
|
91
|
-
when '
|
92
|
-
|
95
|
+
when 'server', 's'
|
96
|
+
start_server
|
93
97
|
when 'generate', 'g'
|
94
98
|
case ARGV[1]
|
95
|
-
when 'spec'
|
96
|
-
generate_spec
|
97
99
|
when 'action'
|
98
100
|
generate_action
|
99
101
|
else
|
data/lib/culpa.rb
CHANGED
data/lib/rspec_helper.rb
CHANGED
@@ -20,20 +20,20 @@ module CulpaHelpers
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
actual[:status] == Action::RETURN_CODES[expected]
|
23
|
+
RSpec::Matchers.define :have_status do |expected|
|
24
|
+
match do |actual|
|
25
|
+
actual[:status] == Action::RETURN_CODES[expected]
|
26
|
+
end
|
28
27
|
end
|
29
|
-
end
|
30
28
|
|
31
|
-
RSpec::Matchers.define :have_headers do |expected|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
RSpec::Matchers.define :have_headers do |expected|
|
30
|
+
match do |actual|
|
31
|
+
expected.each do |k,v|
|
32
|
+
return false unless actual[:headers].has_key?(k) and
|
33
|
+
actual[:headers][k] == expected[k]
|
34
|
+
end
|
35
|
+
true
|
36
36
|
end
|
37
|
-
true
|
38
37
|
end
|
38
|
+
|
39
39
|
end
|
data/templates/Dockerfile
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
FROM ruby:2.3
|
2
2
|
MAINTAINER Your Name <your@email.com>
|
3
3
|
|
4
|
+
# Set RACK_ENV to production
|
5
|
+
ENV RACK_ENV production
|
6
|
+
|
4
7
|
# Create app folder
|
5
8
|
RUN mkdir -p /srv/app
|
6
9
|
|
@@ -15,5 +18,8 @@ RUN bundle install
|
|
15
18
|
# Copy all applications files
|
16
19
|
ADD ./ /srv/app
|
17
20
|
|
21
|
+
# Expose culpa port
|
22
|
+
EXPOSE 4748
|
23
|
+
|
18
24
|
# Command to start the application
|
19
|
-
CMD ["
|
25
|
+
CMD ["/usr/local/bundle/bin/culpa", "server"]
|
data/templates/Gemfile
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'culpa', '~> 0.
|
3
|
+
gem 'culpa', '~> 0.6'
|
4
4
|
|
5
5
|
# Use rspec to test your project.
|
6
6
|
gem 'rspec', '~> 3.4'
|
7
7
|
|
8
8
|
# Use puma to serve the application.
|
9
|
-
# Note that when you change the server the Dockerfile CMD might be broken,
|
10
|
-
# please change it accordingly to the server you'll decide to use instead.
|
11
9
|
gem 'puma', '~> 3.4'
|