mushin 0.25.0 → 0.26.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 +4 -4
- data/exe/generator.rb +168 -0
- data/exe/mushin +45 -51
- data/lib/mushin/builtin/ssd/ssd.rb +50 -0
- data/lib/mushin/{main.rb → domain.rb} +14 -73
- data/lib/mushin/logger.rb +15 -15
- data/lib/mushin/service.rb +18 -0
- data/lib/mushin/store.rb +16 -0
- data/lib/mushin/version.rb +1 -1
- data/lib/mushin.rb +2 -2
- data/mushin.gemspec +1 -1
- data/showcases/gamification_showcase/README.md +9 -0
- data/showcases/gamification_showcase/gameon/lib/gameon/builtin/badges.rb +0 -0
- data/showcases/gamification_showcase/gameon/lib/gameon/version.rb +0 -0
- data/showcases/gamification_showcase/gameon/lib/gameon.rb +9 -0
- data/showcases/gamification_showcase/points/points.rb +1 -0
- data/showcases/gamification_showcase/sample_app/app.rb +0 -0
- data/showcases/gamification_showcase/sample_app/ext/levels/levels.rb +0 -0
- data/{samples → showcases}/sample3.rb +6 -3
- data/showcases/torrents_showcase/README.md +6 -0
- metadata +33 -15
- data/hacks/bot.rb +0 -236
- data/hacks/cqrs/command.rb +0 -123
- data/hacks/cqrs/query.rb +0 -200
- data/hacks/domain.rb +0 -35
- data/hacks/dsl.rb +0 -39
- data/hacks/dsl_builder.rb +0 -29
- data/hacks/es/event.rb +0 -18
- data/hacks/es/event_stream.rb +0 -33
- data/hacks/generator.rb +0 -68
- /data/{samples → showcases}/sample1.rb +0 -0
- /data/{samples → showcases}/sample2.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c6167ee36cd17d487fc4dd6abb1015c986d1719
|
4
|
+
data.tar.gz: 8c7798b1657f6f14da6206747e64c565aaf6c5a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f99f851fbfd9d8e1e505e910c053b3dffe2fe38561e34c205d94bf527eadec27eaa2bb4478cc6b3226bae77f321173163eaee31b3a834898c3898be294578d7c
|
7
|
+
data.tar.gz: 3609fce002464629e6bb57c3a73a326769550075c3111860f693311715d3c0106b13cdf932b7fe4e0987fcecb44e0a0a9a01d0f0bf01fb181054058ff48289db
|
data/exe/generator.rb
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'thor'
|
2
|
+
#require 'thor/group'
|
3
|
+
|
4
|
+
module Mushin
|
5
|
+
class Generator < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
no_commands do
|
9
|
+
def check homepage
|
10
|
+
if homepage.nil? then
|
11
|
+
raise "homepage can't be empty"
|
12
|
+
else
|
13
|
+
if homepage.include? "http://" then
|
14
|
+
return homepage
|
15
|
+
elsif homepage.include? "https://" then
|
16
|
+
return homepage
|
17
|
+
else
|
18
|
+
return "http://" + homepage
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Generate Ext'
|
25
|
+
def generate_ext name: , summary: "", description: "", homepage: "", license: ""
|
26
|
+
if summary.nil? then summary = "a mushin generated framework" end
|
27
|
+
if description.nil? then description = "a mushin generated framework" end
|
28
|
+
if homepage.nil? then homepage = "http://mushin-rb.github.io/" end
|
29
|
+
if license.nil? then license = "MIT" end
|
30
|
+
|
31
|
+
homepage = check(homepage)
|
32
|
+
|
33
|
+
system("bundle gem #{name}")
|
34
|
+
|
35
|
+
file = "#{name.to_s}/lib/#{name.to_s}.rb"
|
36
|
+
@require_gem = <<-FOO
|
37
|
+
require 'mushin'
|
38
|
+
require '#{name}/version'
|
39
|
+
FOO
|
40
|
+
gsub_file file, /^.*\b(version)\b.*$/ do |match|
|
41
|
+
match = @require_gem
|
42
|
+
end
|
43
|
+
|
44
|
+
@content = <<-FOO
|
45
|
+
class Main < Mushin::Ext
|
46
|
+
def initialize app=nil, opts={}, params={}
|
47
|
+
@app = app
|
48
|
+
@opts = opts
|
49
|
+
@params = params
|
50
|
+
end
|
51
|
+
|
52
|
+
def call env
|
53
|
+
env ||= Hash.new
|
54
|
+
# write inbound code
|
55
|
+
if @opts[:cqrs] == :cqrs_query then
|
56
|
+
# write your code here if it is a cqrs query
|
57
|
+
else
|
58
|
+
# write your code here if it is a cqrs command
|
59
|
+
end
|
60
|
+
|
61
|
+
@app.call(env)
|
62
|
+
# write outbound code
|
63
|
+
end
|
64
|
+
end
|
65
|
+
FOO
|
66
|
+
gsub_file file, '# Your code goes here...' do |match|
|
67
|
+
match = @content
|
68
|
+
end
|
69
|
+
|
70
|
+
@gemspec = <<-FOO
|
71
|
+
|
72
|
+
spec.add_dependency 'mushin'
|
73
|
+
end
|
74
|
+
FOO
|
75
|
+
gemspec_file = "#{name.to_s}/#{name.to_s}.gemspec"
|
76
|
+
gsub_file gemspec_file, /\s(\w+)\Z/ do |match|
|
77
|
+
match = @gemspec
|
78
|
+
end
|
79
|
+
|
80
|
+
gsub_file gemspec_file, /%q{TODO: Write a short summary, because Rubygems requires one.}/ do |match|
|
81
|
+
match = "%q{#{summary}}"
|
82
|
+
end
|
83
|
+
|
84
|
+
gsub_file gemspec_file, /%q{TODO: Write a longer description or delete this line.}/ do |match|
|
85
|
+
match = "%q{#{description}}"
|
86
|
+
end
|
87
|
+
|
88
|
+
gsub_file gemspec_file, /"TODO: Put your gem's website or public repo URL here."/ do |match|
|
89
|
+
match = "'#{homepage}'"
|
90
|
+
end
|
91
|
+
|
92
|
+
gsub_file gemspec_file, /"MIT"/ do |match|
|
93
|
+
match = "'#{license}'"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
desc 'Generate DSF'
|
99
|
+
def generate_dsf name: , summary: "", description: "", homepage: "", license: ""
|
100
|
+
|
101
|
+
if summary.nil? then summary = "a mushin generated framework" end
|
102
|
+
if description.nil? then description = "a mushin generated framework" end
|
103
|
+
if homepage.nil? then homepage = "http://mushin-rb.github.io/" end
|
104
|
+
if license.nil? then license = "MIT" end
|
105
|
+
|
106
|
+
homepage = check(homepage)
|
107
|
+
|
108
|
+
system("bundle gem #{name}")
|
109
|
+
|
110
|
+
#remove_file "./#{name}/lib/#{name}.rb"
|
111
|
+
#create_file "./#{name}/lib/#{name}.rb"
|
112
|
+
|
113
|
+
file = "#{name.to_s}/lib/#{name.to_s}.rb"
|
114
|
+
|
115
|
+
@require_gem = <<-FOO
|
116
|
+
require 'mushin'
|
117
|
+
require '#{name}/version'
|
118
|
+
FOO
|
119
|
+
gsub_file file, /^.*\b(version)\b.*$/ do |match|
|
120
|
+
match = @require_gem
|
121
|
+
end
|
122
|
+
|
123
|
+
@content = <<-FOO
|
124
|
+
# Usage:
|
125
|
+
# #{name.capitalize}::Domain.new do
|
126
|
+
# # use your #{name.capitalize} DSL here
|
127
|
+
# end
|
128
|
+
class Domain
|
129
|
+
using Mushin::Domain
|
130
|
+
##
|
131
|
+
## Define your #{name.capitalize} DSL here
|
132
|
+
##
|
133
|
+
end
|
134
|
+
FOO
|
135
|
+
gsub_file file, '# Your code goes here...' do |match|
|
136
|
+
match = @content
|
137
|
+
end
|
138
|
+
|
139
|
+
@gemspec = <<-FOO
|
140
|
+
|
141
|
+
spec.add_dependency 'mushin'
|
142
|
+
end
|
143
|
+
FOO
|
144
|
+
gemspec_file = "#{name.to_s}/#{name.to_s}.gemspec"
|
145
|
+
gsub_file gemspec_file, /\s(\w+)\Z/ do |match|
|
146
|
+
match = @gemspec
|
147
|
+
end
|
148
|
+
|
149
|
+
gsub_file gemspec_file, /%q{TODO: Write a short summary, because Rubygems requires one.}/ do |match|
|
150
|
+
match = "%q{#{summary}}"
|
151
|
+
end
|
152
|
+
|
153
|
+
gsub_file gemspec_file, /%q{TODO: Write a longer description or delete this line.}/ do |match|
|
154
|
+
match = "%q{#{description}}"
|
155
|
+
end
|
156
|
+
|
157
|
+
gsub_file gemspec_file, /"TODO: Put your gem's website or public repo URL here."/ do |match|
|
158
|
+
match = "'#{homepage}'"
|
159
|
+
end
|
160
|
+
|
161
|
+
gsub_file gemspec_file, /"MIT"/ do |match|
|
162
|
+
match = "'#{license}'"
|
163
|
+
end
|
164
|
+
|
165
|
+
empty_directory "./#{name}/lib/#{name}/ext"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
data/exe/mushin
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'thor'
|
4
|
+
require 'thor/group'
|
5
|
+
require_relative './generator'
|
4
6
|
|
5
7
|
module Mushin
|
8
|
+
#TODO check rubygems API if gem name is taken or not, and offer suggestions
|
9
|
+
#TODO ask DSF developer for keywords about mushin gem extenstions they want to include intheir DSF
|
10
|
+
# and search rubygems API for those keywords to find the possible mushin extenstions,
|
11
|
+
# if DSF developer choose them they get included in dsf.gemspec upon generation
|
12
|
+
|
13
|
+
|
6
14
|
class CLI < Thor
|
7
|
-
#include Utter::Tips
|
8
15
|
|
9
16
|
no_commands do
|
10
17
|
def seprator
|
@@ -15,74 +22,61 @@ module Mushin
|
|
15
22
|
|
16
23
|
def done
|
17
24
|
message = set_color " DONE ", :green, :on_white, :bold
|
18
|
-
motive = set_color " You're Awesome!" + " ", :yellow
|
19
|
-
say(message + motive)
|
20
|
-
end
|
21
|
-
|
22
|
-
def mushin_banner
|
23
|
-
message = set_color " Mushin ", :green, :on_white, :bold
|
24
|
-
motive = set_color " 'in the beginner\'s mind there are many possibilities, in the expert\'s there are few.'" + " ", :yellow
|
25
|
+
motive = set_color " You're Awesome! Mushin is opensource & welcomes for contributions!" + " ", :yellow
|
25
26
|
say(message + motive)
|
27
|
+
#message = set_color " NOTE ", :green, :on_white, :bold
|
28
|
+
#say(message + " Mushin is Open for Contributions! Visit http://mushin-rb.github.io ")
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
29
|
-
desc "
|
30
|
-
def
|
31
|
-
|
32
|
+
desc "g", "Generates a DSF via `mushin g dsf` or DSF Ext via `mushin g ext`"
|
33
|
+
def g command, params = {}
|
34
|
+
#NOTE if params is empty then use ineractive mode
|
32
35
|
if params.empty? then
|
33
36
|
case command
|
34
|
-
when "domain"
|
35
|
-
|
36
|
-
seprator
|
37
|
-
|
37
|
+
when "domain", "dsf"
|
38
38
|
info = set_color(" INFO ", :green, :on_white, :bold)
|
39
|
-
message = "
|
40
|
-
domain_type = " choose if your domain is standalone or nested "
|
41
|
-
case domain_type
|
42
|
-
when "standalone"
|
43
|
-
when "nested"
|
44
|
-
else
|
45
|
-
end
|
46
|
-
|
39
|
+
message = " Generating a Mushin Domain-specific Framework Wizard! "
|
47
40
|
puts (info + message)
|
48
41
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
dsf_name = ask(set_color("Mushin Domain-specific Framework Name : ", :bold)).downcase
|
43
|
+
dsf_summary = ask(set_color("Mushin Domain-specific Framework Summary : ", :bold)).downcase
|
44
|
+
dsf_description = ask(set_color("Mushin Domain-specific Framework Description : ", :bold)).downcase
|
45
|
+
dsf_homepage = ask(set_color("Mushin Domain-specific Framework Homepage : ", :bold)).downcase
|
46
|
+
dsf_license = ask(set_color("Mushin Domain-specific Framework License : ", :bold)).downcase
|
54
47
|
|
55
48
|
seprator
|
56
|
-
|
57
|
-
params = {:gem_name => gem_name, :gem_type => gem_type, :gem_context => gem_context, :editor => gem_editor}
|
58
|
-
|
59
|
-
Mushin::Generator.new.gem params
|
60
|
-
|
49
|
+
Mushin::Generator.new.generate_dsf name: dsf_name, summary: dsf_summary, description: dsf_description, homepage: dsf_homepage, license: dsf_license
|
61
50
|
done # Says Done you are awesome!
|
62
51
|
when "extension", "ext"
|
63
|
-
|
52
|
+
info = set_color(" INFO ", :green, :on_white, :bold)
|
53
|
+
message = " Generating a Mushin Extension Wizard! "
|
54
|
+
puts (info + message)
|
64
55
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
56
|
+
ext_name = ask(set_color("Mushin Extension Name : ", :bold)).downcase
|
57
|
+
ext_summary = ask(set_color("Mushin Extension Summary : ", :bold)).downcase
|
58
|
+
ext_description = ask(set_color("Mushin Extension Description : ", :bold)).downcase
|
59
|
+
ext_homepage = ask(set_color("Mushin Extension Homepage : ", :bold)).downcase
|
60
|
+
ext_license = ask(set_color("Mushin Extension License : ", :bold)).downcase
|
69
61
|
|
70
|
-
|
71
|
-
|
72
|
-
#
|
62
|
+
seprator
|
63
|
+
Mushin::Generator.new.generate_ext name: ext_name, summary: ext_summary, description: ext_description, homepage: ext_homepage, license: ext_license
|
64
|
+
done # Says Done you are awesome!
|
73
65
|
else
|
74
|
-
|
75
|
-
end
|
76
|
-
else
|
77
|
-
#if params is not empty then use direct mode (good for piping from other programs)
|
66
|
+
#if params is not empty then use direct mode (good for piping from other programs)
|
67
|
+
end
|
78
68
|
end
|
79
|
-
end
|
80
69
|
|
81
|
-
|
82
|
-
|
83
|
-
`bundle exec rake release`
|
84
|
-
|
70
|
+
# desc "package", "package this DSF as a gem"
|
71
|
+
# def package
|
72
|
+
# `bundle exec rake release`
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
## desc "deploy", ""
|
76
|
+
# def deploy
|
77
|
+
# end
|
85
78
|
|
79
|
+
end
|
86
80
|
end
|
87
81
|
end
|
88
82
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'ssd'
|
2
|
+
|
3
|
+
module SSD
|
4
|
+
module Internal
|
5
|
+
class SomeError < RuntimeError
|
6
|
+
end
|
7
|
+
|
8
|
+
def write path, key, value
|
9
|
+
SSD.write(path, key, value)
|
10
|
+
end
|
11
|
+
|
12
|
+
def read path, key
|
13
|
+
SSD.read(path, key)
|
14
|
+
end
|
15
|
+
|
16
|
+
def dump path, key
|
17
|
+
SSD.dump(path, key)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Main < Mushin::Ext
|
22
|
+
include Internal
|
23
|
+
|
24
|
+
def initialize app=nil, opts={}, params={}
|
25
|
+
@app = app
|
26
|
+
@opts = opts
|
27
|
+
@params = params
|
28
|
+
end
|
29
|
+
|
30
|
+
def call env
|
31
|
+
#NOTE Utter Generated Code: used to provide you an env hash variable
|
32
|
+
env ||= Hash.new #if env.nil?
|
33
|
+
|
34
|
+
$log.debug "#{self} ------ Inbound maniuplation"
|
35
|
+
@app.call(env)
|
36
|
+
|
37
|
+
if @opts[:cqrs] == :cqrs_query then
|
38
|
+
env[:query_results] = SSD.read(@opts[:path], @params[:id])
|
39
|
+
elsif @opts[:cqrs] == :cqrs_command then
|
40
|
+
write @opts[:path], env[:id], env
|
41
|
+
else
|
42
|
+
$log.warn "SSD store was called but not used"
|
43
|
+
end
|
44
|
+
|
45
|
+
$log.debug "#{self} ------ Outbound maniuplation"
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -4,42 +4,23 @@ require 'set'
|
|
4
4
|
#TODO release 1.0rc
|
5
5
|
|
6
6
|
module Mushin
|
7
|
-
#TODO maybe use refinements instead of inheritance for `using Mushin::Ext`
|
8
|
-
class Store < Mushin::Test::Sample::Ext
|
9
|
-
def initialize(ext, opts = {}, params= {})
|
10
|
-
@ext = ext
|
11
|
-
@opts = opts
|
12
|
-
@params = params
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
env ||= Hash.new
|
17
|
-
@ext.call(env)
|
18
|
-
return env
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
7
|
module Domain
|
8
|
+
|
23
9
|
refine Class do
|
24
10
|
#TODO apply advanced centerlized logging automatically via TracePoint, DEBUG log level, to save space of the other logging and make it more standarized style
|
25
11
|
#trace = TracePoint.new(:c_call) do |tp| # p [tp.lineno, tp.defined_class, tp.method_id, tp.event]#end#trace.enable
|
26
12
|
@@dsl_tree = Set.new
|
27
|
-
|
28
13
|
def context keyword, &context_block
|
29
|
-
@context_keyword
|
30
|
-
|
31
|
-
@context_hash = Hash.new
|
14
|
+
@context_keyword = keyword
|
15
|
+
@context_hash = Hash.new
|
32
16
|
@context_hash[@context_keyword] = []
|
33
|
-
|
34
17
|
def construct keyword, &construct_block
|
35
|
-
@construct_keyword
|
36
|
-
@construct_hash
|
37
|
-
@construct_hash[@construct_keyword]
|
18
|
+
@construct_keyword = keyword
|
19
|
+
@construct_hash = Hash.new
|
20
|
+
@construct_hash[@construct_keyword] = []
|
38
21
|
def use ext: nil, opts: nil, params: nil
|
39
|
-
|
40
22
|
$log.debug "use #{ext}, #{opts}, #{params}"
|
41
23
|
@construct_hash[@construct_keyword] << {ext: ext, opts: opts, params: params}
|
42
|
-
|
43
24
|
#NOTE defining Domain instance methods in this class_exec block
|
44
25
|
class_exec do
|
45
26
|
def store data_key: nil, data_value: nil
|
@@ -50,10 +31,8 @@ module Mushin
|
|
50
31
|
return @data
|
51
32
|
end
|
52
33
|
end
|
53
|
-
|
54
34
|
def initialize &domain_block
|
55
|
-
@data = Hash.new
|
56
|
-
|
35
|
+
@data = Hash.new
|
57
36
|
#NOTE CQRS
|
58
37
|
@@dsl_tree.each do |klass_context_set|
|
59
38
|
klass_context_set.each do |klass_context_key, klass_context_value|
|
@@ -63,60 +42,48 @@ module Mushin
|
|
63
42
|
klass_construct_set.each do |klass_construct_key, klass_construct_value|
|
64
43
|
$log.debug "klass_construct_key #{klass_construct_key} | klass_construct_value #{klass_construct_value}"
|
65
44
|
$log.debug "#{@@dsl_tree}"
|
66
|
-
|
67
|
-
# creates an instance method with the name of the klass_construct_key
|
45
|
+
#NOTE creates an instance method with the name of the klass_construct_key
|
68
46
|
self.singleton_class.send :define_method, klass_construct_key do |instance_hash = Hash.new|
|
69
47
|
@stack = Mushin::Stack.new
|
70
|
-
|
71
48
|
klass_construct_value.each do |klass_ext|
|
72
49
|
ext_hash = Hash.new
|
73
50
|
ext_hash[:ext] = klass_ext[:ext]
|
74
51
|
ext_hash[:params] = Hash.new
|
75
52
|
ext_hash[:opts] = Hash.new
|
76
|
-
|
77
53
|
klass_opts_hash = klass_ext[:opts]
|
78
54
|
klass_params_hash = klass_ext[:params]
|
79
55
|
|
80
56
|
#NOTE provides an ext_hash via binding of instance_hash values to klass_hashs(opts & params) keys
|
81
57
|
instance_hash.each do |instance_hash_key, instance_hash_value|
|
82
|
-
ext_hash[:opts][klass_opts_hash.invert[instance_hash_key]] = instance_hash_value unless klass_opts_hash.invert[instance_hash_key].nil?
|
83
|
-
ext_hash[:params][klass_params_hash.invert[instance_hash_key]] = instance_hash_value unless klass_params_hash.invert[instance_hash_key].nil?
|
58
|
+
ext_hash[:opts][klass_opts_hash.invert[instance_hash_key]] = instance_hash_value unless klass_opts_hash.nil? || klass_opts_hash.invert[instance_hash_key].nil?
|
59
|
+
ext_hash[:params][klass_params_hash.invert[instance_hash_key]] = instance_hash_value unless klass_params_hash.nil? || klass_params_hash.invert[instance_hash_key].nil?
|
84
60
|
end
|
85
|
-
|
86
61
|
#NOTE adds the extras from klass_hashs via reverse merge
|
87
|
-
ext_hash[:opts] = klass_opts_hash.merge(ext_hash[:opts])
|
88
|
-
ext_hash[:params] =
|
89
|
-
|
90
|
-
#ext_hash[:opts].merge!(klass_opts_hash)
|
91
|
-
#ext_hash[:params].merge!(klass_params_hash)
|
92
|
-
|
62
|
+
ext_hash[:opts] = klass_opts_hash.merge(ext_hash[:opts]) unless klass_opts_hash.nil?
|
63
|
+
ext_hash[:params] = klass_params_hash.merge(ext_hash[:params]) unless klass_params_hash.nil?
|
93
64
|
$log.debug "insert_before 0 into stack: #{ext_hash[:ext]}, #{ext_hash[:opts]}, #{ext_hash[:params]}"
|
94
65
|
@stack.insert_before 0, ext_hash[:ext], ext_hash[:opts], ext_hash[:params]
|
95
66
|
end
|
96
|
-
|
97
67
|
if klass_context_key == "query" then
|
98
|
-
# CQRS Query
|
68
|
+
#NOTE CQRS Query
|
99
69
|
$log.debug "klass_construct_key #{klass_construct_key} | klass_construct_value #{klass_construct_value}"
|
100
70
|
@stack.insert_before 0, Mushin::Store, {}, {}
|
101
71
|
stack_data = @stack.call
|
102
72
|
store(data_key: klass_construct_key.to_sym, data_value: stack_data)
|
103
73
|
else
|
104
|
-
# CQRS Command
|
74
|
+
#NOTE CQRS Command
|
105
75
|
@stack.call
|
106
76
|
end
|
107
77
|
end
|
108
78
|
end
|
109
79
|
end
|
110
|
-
|
111
80
|
instance_eval &context_block
|
112
|
-
|
113
81
|
klass_context_set[klass_context_key].each do |klass_construct_hash|
|
114
82
|
klass_construct_hash.keys.each do |method_key|
|
115
83
|
instance_eval("undef :#{method_key}")
|
116
84
|
end
|
117
85
|
$log.debug "construct_key #{klass_context_key} is undef-ed"
|
118
86
|
end
|
119
|
-
|
120
87
|
end
|
121
88
|
end
|
122
89
|
end
|
@@ -132,29 +99,3 @@ module Mushin
|
|
132
99
|
end
|
133
100
|
end
|
134
101
|
end
|
135
|
-
|
136
|
-
=begin
|
137
|
-
#$log.info "klass_ext_key: #{klass_ext_key}, klass_ext_value: #{klass_ext_value}, instance_hash: #{instance_hash}"
|
138
|
-
#
|
139
|
-
[klass_opts_hash, klass_params_hash].each do |klass_hash|
|
140
|
-
instance_hash.each do |instance_hash_key, instance_hash_value|
|
141
|
-
ext_hash[klass_hash.invert[instance_hash_key]] = instance_hash_value unless klass_hash.invert[instance_hash_key].nil?
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
[klass_ext[:params], klass_ext[:opts]].each do |klass_ext_hash|
|
146
|
-
klass_ext_hash.each do |klass_ext_key, klass_ext_value|
|
147
|
-
# this is an important log, figure it out to solve this!
|
148
|
-
$log.info "klass_ext_key: #{klass_ext_key}, klass_ext_value: #{klass_ext_value}, instance_hash: #{instance_hash}"
|
149
|
-
|
150
|
-
ext_instance_data.each do |data_key, data_value|
|
151
|
-
if data_key.to_sym == klass_ext_value then
|
152
|
-
$log.debug data_value
|
153
|
-
#ext[:params][ext_key] = data_value
|
154
|
-
instance_ext_hash[:params][klass_ext_key.to_sym] = data_value
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end unless klass_ext[:opts].nil? || klass_ext[:params].nil?
|
159
|
-
=end
|
160
|
-
|
data/lib/mushin/logger.rb
CHANGED
@@ -7,19 +7,19 @@ require 'logger'
|
|
7
7
|
require 'date'
|
8
8
|
|
9
9
|
module Mushin
|
10
|
-
# Colorizes the output of the standard library logger, depending on the logger level:
|
11
|
-
# To adjust the colors, look at Logger::Colors::SCHEMA and Logger::Colors::constants
|
12
|
-
#
|
13
|
-
# LEVELS
|
14
|
-
#========
|
15
|
-
# UNKNOWN: An unknown message that should always be logged.
|
16
|
-
# FATAL: An unhandleable error that results in a program crash.
|
17
|
-
# ERROR: A handleable error condition.
|
18
|
-
# WARN: A warning.
|
19
|
-
# INFO: Generic (useful) information about system operation.
|
20
|
-
# DEBUG: Low-level information for developers.
|
21
|
-
|
22
10
|
class Logger < Logger
|
11
|
+
# Colorizes the output of the standard library logger, depending on the logger level:
|
12
|
+
# To adjust the colors, look at Logger::Colors::SCHEMA and Logger::Colors::constants
|
13
|
+
#
|
14
|
+
# LEVELS
|
15
|
+
#========
|
16
|
+
# UNKNOWN: An unknown message that should always be logged.
|
17
|
+
# FATAL: An unhandleable error that results in a program crash.
|
18
|
+
# ERROR: A handleable error condition.
|
19
|
+
# WARN: A warning.
|
20
|
+
# INFO: Generic (useful) information about system operation.
|
21
|
+
# DEBUG: Low-level information for developers.
|
22
|
+
#class Logger < Logger
|
23
23
|
module Colors
|
24
24
|
NOTHING = '0;0'
|
25
25
|
BLACK = '0;30'
|
@@ -46,7 +46,6 @@ module Mushin
|
|
46
46
|
}
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
49
|
alias format_message_colorless format_message
|
51
50
|
|
52
51
|
def format_message(level, *args)
|
@@ -71,7 +70,8 @@ module Mushin
|
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
74
|
-
|
73
|
+
|
74
|
+
|
75
75
|
def self.logger(shift_age: 'daily',
|
76
76
|
datetime_format: '%Y-%m-%d %H:%M:%S',
|
77
77
|
log_dir: 'log'
|
@@ -84,7 +84,7 @@ module Mushin
|
|
84
84
|
@log = Mushin::Logger.new("| tee " + file.path, shift_age)
|
85
85
|
@log.datetime_format = datetime_format
|
86
86
|
#@log.progname = 'eventstream'
|
87
|
-
|
87
|
+
|
88
88
|
#@log.format_message 'DEBUG',
|
89
89
|
|
90
90
|
@log.info "Mushin Log Levels: DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Mushin
|
4
|
+
module Service
|
5
|
+
refine Class do
|
6
|
+
# Default Provider
|
7
|
+
provider = "https://api.hackspree.com"
|
8
|
+
#response = HTTParty.get('http://api.stackexchange.com/2.2/questions?site=stackoverflow')
|
9
|
+
|
10
|
+
# https://api.hackspree.com as a Domain-as-a-Service provider
|
11
|
+
#TODO ability to configure your DaaS providers via Mushin::Service in the DSF or the Application.
|
12
|
+
#TODO Auth via security token
|
13
|
+
|
14
|
+
# Usage: Domain Frameworks may `use Mushin::Service::GameOn, params: {}, opts: {}`
|
15
|
+
#
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/mushin/store.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Mushin
|
2
|
+
#TODO maybe use refinements instead of inheritance for `using Mushin::Ext`
|
3
|
+
class Store < Mushin::Test::Sample::Ext
|
4
|
+
def initialize(ext, opts = {}, params= {})
|
5
|
+
@ext = ext
|
6
|
+
@opts = opts
|
7
|
+
@params = params
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
env ||= Hash.new
|
12
|
+
@ext.call(env)
|
13
|
+
return env
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/mushin/version.rb
CHANGED
data/lib/mushin.rb
CHANGED
@@ -5,7 +5,8 @@ require_relative "mushin/logger"
|
|
5
5
|
require_relative "mushin/stack"
|
6
6
|
require_relative "mushin/ext"
|
7
7
|
require_relative "mushin/test_helper"
|
8
|
-
require_relative "mushin/
|
8
|
+
require_relative "mushin/store"
|
9
|
+
require_relative "mushin/domain"
|
9
10
|
|
10
11
|
#NOTE maybe later
|
11
12
|
#require_relative "mushin/es/event"
|
@@ -15,7 +16,6 @@ require_relative "mushin/main"
|
|
15
16
|
#require_relative "mushin/bot"
|
16
17
|
|
17
18
|
module Mushin
|
18
|
-
|
19
19
|
$log = Mushin.logger #Logger.new(STDOUT)
|
20
20
|
|
21
21
|
# Set logging level to info
|
data/mushin.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_runtime_dependency "thor" #, "~> 0.3"
|
39
39
|
|
40
40
|
#spec.add_runtime_dependency "sinatra" #, "~> 0.3"
|
41
|
-
|
41
|
+
spec.add_runtime_dependency "ssd" #, "~> 0.3"
|
42
42
|
#spec.add_runtime_dependency "cinch" #, "~> 0.3"
|
43
43
|
|
44
44
|
# favouring ore for gem generation over bundler, as it providers a fine-grained customization
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Gamification
|
2
|
+
=============
|
3
|
+
|
4
|
+
This directory contains:
|
5
|
+
|
6
|
+
- GameOn: a sample mushin domain-specific framework for Gamification
|
7
|
+
- Badges: a sample built-in mushin extenstion for Gamification
|
8
|
+
- Points: a sample standalone mushin extenstion for Gamification
|
9
|
+
- SampleApp: a sample application using GameOn framework
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# standalone mushin extenstion
|
File without changes
|