culpa 0.2.2 → 0.4.0

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
- YTNmOTRkMzhlZjlhYTQ5ZmQ0MGNiNjQ0Mjc3MTQyZjhjMDQzNmVlYg==
4
+ ZWQ0MDFlODYyNTlhZGQyNmM5MGE3ZmY4YzI5ZDMzMzdjYmQyZWU5MQ==
5
5
  data.tar.gz: !binary |-
6
- ZWEwODA0NzhiZTdkYjgyOWZkOGJiMmY3NWYzOGFhZGZmMTlhZDg0MA==
6
+ Y2Y0MjYzMmM1NDU5YWE0MzQ3OTk1NWU1OGYyZDFlMTI4MmJiNTJlYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjZkZmJiMzJjZGYyNjkzODYzMmMyZTI2YmY1OWU5MmZiYzBkNDBjOGYwZDE5
10
- ZTk0NWQ3MmMzZTVjMGI1OTUwN2QzY2U4YWNhMmJjZTUxOTJhYTY4MDIwMzU5
11
- MDdkNjAwODhmNzA5NWQ5NzM3YWYyZTQ5NWEyYTIzMzRhYmU4ZjE=
9
+ MGJlZDVjYzU3ZWI4ODYwMWFkOGQzZGQ5OTA1NzI5MWI5Y2NkYzA5OGVjN2Nj
10
+ NTUyOGVkOTI0YTlkZjE4ZWNkMzNjM2Y0MDU0ZDlkNjQ3MjgyYTY2NGUzNzI0
11
+ Y2E0NWIyOTEzYTNkYmYwNWU0NmViZDIyYjIwYTQ5ZGQ2NzcwZGM=
12
12
  data.tar.gz: !binary |-
13
- ZmEwZDQ3ODAwNmMyZDg2Njc2NzA1ZjI5ZGNhYzdhNmY0YWVkMmI1NjdhYTRh
14
- ZGU5ZWRiNzU5MWY1MjUxZmE5ZmNiMGM4MTU5NzNjMTJmMjI4YTM1YjBjNWZl
15
- YjBhNmE4YzNiZDJmYTk1MDhkNTAzMzcxOGFhMzNiYWU5OTE0ODE=
13
+ NmY1NTczMTI2YTBmYWE2NmU5MGY3OWQ1MTdjZGU0YjZmOWE0N2M0ODE0MzFl
14
+ Mjk2ZWE1NjEyNWM5NjdiMjg4ZjBlYjc5MmMzMzRlMjQ4YTEyMjBhNWY4NTE4
15
+ ZmQwZWVkOTZiY2IwYzE4NGNmODdlYTRmODcxMWMyZjdmZWI3NjA=
data/bin/culpa CHANGED
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'culpa'
4
+ require 'pry'
3
5
  require 'fileutils'
6
+ require 'erb'
4
7
 
5
8
  def create_project(project_path)
6
9
  puts "Initializing Culpa project in #{project_path}"
@@ -32,15 +35,20 @@ def create_project(project_path)
32
35
  puts '==> Copying Dockerfile'
33
36
  dockerfile_rackup_path = File.join( File.dirname(__FILE__), '../templates/Dockerfile' )
34
37
  FileUtils.cp dockerfile_rackup_path, "#{project_path}/Dockerfile"
35
- end
36
38
 
37
- def open_console
38
- require 'rubygems'
39
- require 'bundler/setup'
40
- require 'yaml'
41
- require 'culpa'
42
- require 'pry'
43
- binding.pry
39
+ puts '==> Switching to project directory'
40
+ FileUtils.cd project_path
41
+
42
+ puts '==> Execute bundle install'
43
+ puts `bundle install`
44
+
45
+ puts '==> Enabling RSpec in project'
46
+ puts `rspec --init`
47
+
48
+ puts '==> Inject Culpa helpers in spec_helper.rb'
49
+ File.open('spec/spec_helper.rb', 'a+') do |file|
50
+ file.puts("require 'culpa'")
51
+ end
44
52
  end
45
53
 
46
54
  def display_help
@@ -52,13 +60,46 @@ def display_help
52
60
  puts ''
53
61
  puts 'This software is distributed under the MIT license, available here : '
54
62
  puts ' - https://raw.githubusercontent.com/HipsterWhale/culpa/master/LICENSE'
63
+ puts ''
64
+ end
65
+
66
+ def display_brick_chain
67
+ router_method_name = ARGV[1]
68
+ brickchain = Culpa::Application.new.brick_call_chain(router_method_name)
69
+ if brickchain
70
+ brickchain.each { |brick| puts " -> #{brick}" }
71
+ else
72
+ puts "Can't determine the brickchain of #{router_method_name}"
73
+ end
74
+ end
75
+
76
+ def generate_spec
77
+ end
78
+
79
+ def generate_action
80
+ erb_template = File.read(File.join(File.dirname(__FILE__), '../templates/generators/action.tmpl'))
81
+ @name = ARGV[2]
82
+ @bricks = ARGV.drop(3)
83
+ renderer = ERB.new(erb_template)
84
+ puts renderer.result
55
85
  end
56
86
 
57
87
  case ARGV[0]
58
- when 'new'
88
+ when 'new', 'n'
59
89
  create_project ARGV[1]
60
- when 'console'
61
- open_console
90
+ when 'console', 'c'
91
+ binding.pry
92
+ when 'brickchain', 'bc'
93
+ display_brick_chain
94
+ when 'generate', 'g'
95
+ case ARGV[1]
96
+ when 'spec'
97
+ generate_spec
98
+ when 'action'
99
+ generate_action
100
+ else
101
+ puts 'Unknown generator'
102
+ end
62
103
  else
63
104
  display_help
64
105
  end
data/lib/culpa.rb CHANGED
@@ -8,6 +8,11 @@ require 'file_helpers'
8
8
 
9
9
  ACTIONS_PATH ||= './actions/*.rb'
10
10
  MODELS_PATH ||= './models/*.rb'
11
+ INITIALIZERS_PATH ||= './config/initializers/*.rb'
12
+
13
+ Dir[INITIALIZERS_PATH].each do |file|
14
+ require file
15
+ end
11
16
 
12
17
  module Actions
13
18
  require 'action'
data/lib/envelope.rb CHANGED
@@ -10,6 +10,12 @@ module Culpa
10
10
  end
11
11
  end
12
12
 
13
+ def initialize(attributes = {})
14
+ attributes.each do |name, value|
15
+ instance_variable_set "@#{name}", value
16
+ end
17
+ end
18
+
13
19
  def method_missing(sym, *args)
14
20
  sym = sym.to_s
15
21
  if sym.end_with? '='
data/templates/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.3-alpine
1
+ FROM ruby:2.3
2
2
  MAINTAINER Your Name <your@email.com>
3
3
 
4
4
  # Create app folder
data/templates/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'culpa', '~> 0.2'
3
+ gem 'culpa', '~> 0.3'
4
+
5
+ # Use rspec to test your project.
6
+ gem 'rspec', '~> 3.4'
7
+
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.
4
11
  gem 'puma', '~> 3.4'
@@ -0,0 +1,7 @@
1
+ class <%= @name %>Action < Action
2
+ <% @bricks.each do |brick| %>
3
+ def <%= brick %>
4
+ render status: :not_implemented
5
+ end
6
+ <% end if @bricks %>
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culpa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy SEBAN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-16 00:00:00.000000000 Z
11
+ date: 2016-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -38,7 +38,21 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.10'
41
- description: Culpa is a try of following MEA principles.
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ description: Culpa is a framework following MEA principles. Learn more on https://github.com/HipsterWhale/culpa.
42
56
  email: jeremy@seban.eu
43
57
  executables:
44
58
  - culpa
@@ -54,6 +68,7 @@ files:
54
68
  - templates/Dockerfile
55
69
  - templates/Gemfile
56
70
  - templates/config.ru
71
+ - templates/generators/action.tmpl
57
72
  homepage: https://github.com/HipsterWhale/culpa
58
73
  licenses:
59
74
  - MIT