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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDFjODlhNWQyYmVlMGRjYTU4MjM4Mzc4ZjhkZWY2YzI5NGE2ZjYzOQ==
4
+ YjMxNzJiMjhkMzhkZjk1YmZmYmQwMWQyOGU5MDlmYjAwNWRjYzZmNA==
5
5
  data.tar.gz: !binary |-
6
- YThiMTZhNDI0YzNkMDg2MTA2YTE5NTk2MzQzNDVjOTgwNWYxYjNlNQ==
6
+ MWZhZjM2OWJmYjMyZDc2N2M5MWY3YzE3NGFlYjliNDdlM2FhMjAxMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjEzNTUxY2ZjYWE3Yzk5OTE1NTUyMzQxOTk2OTZjZDNlY2VlMGQ4ZTVmMmVh
10
- MmFlY2Q1MmFiMTAzY2ExZDc3ZjA2ODY2YzMxNmVkZDlhNTg3MDZhZGVkNTc2
11
- ZjBlMTBlOWQzZDg4N2NlZmJlMjAwODEzNWI0MjI4Yjk3YzEyOTk=
9
+ OWVkYjk0Mzg4YTY4N2UwMzRhMmI5M2UxYWZlMWE1Y2E0OWFhZWVlNzczZGM2
10
+ NTc3MWRlNTQwZTU4NTVlOTU2OWIxMjg2ZjAzMGQ4Y2UzYzI1ZjgwNzdjNGEy
11
+ MDNlNWIzZTUzYmZjZWZjMzNlZmNkY2JkNjVhZDQ5NjI4NmU0NjM=
12
12
  data.tar.gz: !binary |-
13
- MWE4NDAwYTY3MGQzMWYxMDUxYzgyMDhlYzRkMjZjZTAxZTdhZDQ2ZDk4NTY4
14
- ZTFhNDI1ZDQ3ZjBlZGZkNjZmYzM2MTVhODhjNDM2NTI3MGQ3NTNjNDUyNzQz
15
- NzhhZTRmN2NkZDNmYzllNmU2NGQ4ZGRmMWQ1Y2UxOTIwNzg0MWY=
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
- File.open('spec/spec_helper.rb', 'a+') do |file|
49
- file.puts("require 'culpa'")
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 'Welcome to Culpa ! The MEA framework.'
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] : Create a new culpa project on the specified folder'
58
- puts ' - console : Drop an interactive shell within the running directory'
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
- renderer = ERB.new(erb_template)
83
- puts renderer.result
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 'brickchain', 'bc'
92
- display_brick_chain
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
@@ -7,6 +7,8 @@ require 'envelope'
7
7
  require 'path_parser'
8
8
  require 'file_helpers'
9
9
 
10
+ CULPA_VERSION='0.6.0.1'
11
+
10
12
  ACTIONS_PATH ||= './actions/*.rb'
11
13
  MODELS_PATH ||= './models/*.rb'
12
14
  INITIALIZERS_PATH ||= './config/initializers/*.rb'
data/lib/rspec_helper.rb CHANGED
@@ -20,20 +20,20 @@ module CulpaHelpers
20
20
  end
21
21
  end
22
22
 
23
- end
24
-
25
- RSpec::Matchers.define :have_status do |expected|
26
- match do |actual|
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
- match do |actual|
33
- expected.each do |k,v|
34
- return false unless actual[:headers].has_key?(k) and
35
- actual[:headers][k] == expected[k]
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 ["puma"]
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.5'
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'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culpa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy SEBAN