atelier 0.0.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 +7 -0
- data/bin/atelier +5 -0
- data/lib/atelier.rb +2 -0
- data/lib/atelier/action.rb +19 -0
- data/lib/atelier/action_dsl.rb +26 -0
- data/lib/atelier/application.rb +44 -0
- data/lib/atelier/library.rb +50 -0
- data/lib/atelier/library_dsl.rb +48 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1d8a3ce7b78792ec86dac93e61ac1bdc40ebcfac
|
4
|
+
data.tar.gz: c47bae44482311c8fb631a667df829963af55b31
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ed68381009626868a748961f6c0cdcb1c248abd6cfa8eb019bd425d4b4133ebb1697f985b34c3c88f9002002cce8b3a89bfa30758c0f4a656697ac1e23052ec
|
7
|
+
data.tar.gz: 8923700716929fe478dc98475fbe1e0283a6bcec4656a0d7780cc620a1b9ef8297d01f160d03d76afa93b63b17e0d4fc0af4c1dab14b97221340c36c53705d25
|
data/bin/atelier
ADDED
data/lib/atelier.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'atelier/action_dsl'
|
2
|
+
|
3
|
+
module Atelier
|
4
|
+
|
5
|
+
class Action
|
6
|
+
|
7
|
+
include ActionDSL
|
8
|
+
|
9
|
+
attr_reader :name, :proc
|
10
|
+
|
11
|
+
def initialize(name, &init_block)
|
12
|
+
@name = name
|
13
|
+
@proc = Proc.new {}
|
14
|
+
instance_eval &init_block
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module Atelier
|
3
|
+
|
4
|
+
module ActionDSL
|
5
|
+
|
6
|
+
def synopsis(*args)
|
7
|
+
@synopsis ||= ''
|
8
|
+
@synopsis = args.join(' ') unless args.empty?
|
9
|
+
@synopsis
|
10
|
+
end
|
11
|
+
|
12
|
+
def description(*args)
|
13
|
+
@description ||= ''
|
14
|
+
@description = args.join("\n") unless args.empty?
|
15
|
+
@description
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def block(&proc)
|
21
|
+
@proc = proc
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
require 'atelier/library'
|
5
|
+
|
6
|
+
module Atelier
|
7
|
+
|
8
|
+
class Application
|
9
|
+
|
10
|
+
include Singleton
|
11
|
+
|
12
|
+
attr_reader :root_library, :logger
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@root_library = nil
|
16
|
+
@logger = Logger.new(STDERR)
|
17
|
+
@logger.level = Logger::WARN
|
18
|
+
|
19
|
+
Kernel.send(:define_method, :library) do |name, &block|
|
20
|
+
Application.instance.load_root_library(name, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def load_root_library(name, &block)
|
25
|
+
@root_library = Library.new(name, &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def send_action(action, *parameters)
|
29
|
+
root_library.send(action, *parameters)
|
30
|
+
rescue Exception => e
|
31
|
+
logger.error e
|
32
|
+
end
|
33
|
+
|
34
|
+
def run(library_file, action, *parameters)
|
35
|
+
load(library_file)
|
36
|
+
|
37
|
+
send_action(action, *parameters)
|
38
|
+
rescue Exception => e
|
39
|
+
logger.error e
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'atelier/library_dsl'
|
2
|
+
|
3
|
+
module Atelier
|
4
|
+
|
5
|
+
class Library
|
6
|
+
|
7
|
+
include LibraryDSL
|
8
|
+
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
def initialize(name, &block)
|
12
|
+
@name = name
|
13
|
+
@title = ''
|
14
|
+
@description = ''
|
15
|
+
@libraries = {}
|
16
|
+
@actions = {
|
17
|
+
libraries: :default,
|
18
|
+
actions: :default,
|
19
|
+
help: :default
|
20
|
+
}
|
21
|
+
instance_eval &block
|
22
|
+
end
|
23
|
+
|
24
|
+
def libraries
|
25
|
+
@libraries.each { |lib_name, lib| puts lib_name }
|
26
|
+
@libraries
|
27
|
+
end
|
28
|
+
|
29
|
+
def actions
|
30
|
+
@actions.each { |action_name, action| puts action_name }
|
31
|
+
@actions
|
32
|
+
end
|
33
|
+
|
34
|
+
def help
|
35
|
+
puts "#{name}: #{title}"
|
36
|
+
|
37
|
+
puts 'default actions:'
|
38
|
+
@actions.each do |action_name, action|
|
39
|
+
puts " - #{name} #{action_name}" if action == :default
|
40
|
+
end
|
41
|
+
|
42
|
+
puts 'actions:'
|
43
|
+
@actions.each do |action_name, action|
|
44
|
+
puts " - #{name} #{action_name} #{action.synopsis}" unless action == :default
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'atelier/Action'
|
2
|
+
|
3
|
+
module Atelier
|
4
|
+
|
5
|
+
module LibraryDSL
|
6
|
+
|
7
|
+
def title(*args)
|
8
|
+
@title ||= ''
|
9
|
+
@title = args.join(' ') unless args.empty?
|
10
|
+
@title
|
11
|
+
end
|
12
|
+
|
13
|
+
def description(*args)
|
14
|
+
@description ||= ''
|
15
|
+
@description = args.join("\n") unless args.empty?
|
16
|
+
@description
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def method(name, &block)
|
22
|
+
(class << self; self; end).send(:define_method, name, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def library(lib_name, &block)
|
26
|
+
@libraries ||= {}
|
27
|
+
library = Library.new(lib_name, &block)
|
28
|
+
@libraries[lib_name] = library
|
29
|
+
method(lib_name) do |*args|
|
30
|
+
if args.empty?
|
31
|
+
library
|
32
|
+
else
|
33
|
+
library.send(*args)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def action(action_name, &block)
|
39
|
+
@actions ||= {}
|
40
|
+
Application.instance.logger.warn "The method '#{action_name}' is overridden by your provided action" if methods.include?(action_name.to_sym)
|
41
|
+
action = Action.new(action_name, &block)
|
42
|
+
@actions[action_name] = action
|
43
|
+
method(action_name, &action.proc)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atelier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas DE BONA
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple ruby task
|
14
|
+
email: thomas.debona@gmail.com
|
15
|
+
executables:
|
16
|
+
- atelier
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/atelier/action.rb
|
21
|
+
- lib/atelier/action_dsl.rb
|
22
|
+
- lib/atelier/application.rb
|
23
|
+
- lib/atelier/library.rb
|
24
|
+
- lib/atelier/library_dsl.rb
|
25
|
+
- lib/atelier.rb
|
26
|
+
- bin/atelier
|
27
|
+
homepage: http://rubygems.org/gems/atelier
|
28
|
+
licenses:
|
29
|
+
- MIT
|
30
|
+
metadata: {}
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 2.0.14
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: Ruby task
|
51
|
+
test_files: []
|