mushin 0.1.0 → 0.2.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0e88288b1562a69301bdd27ce84b1ebbf34669d
4
- data.tar.gz: 6223db5afb53ab8a6dc8cd2b32e94a5739166685
3
+ metadata.gz: 23e3c79e4ed8304e6e27e3b29073604aa3e58290
4
+ data.tar.gz: 4c61d824c7d4e1877eb39bb4b0aeec0eda9a6faa
5
5
  SHA512:
6
- metadata.gz: 88d3ef94d3cd205f21764a498729d8b8f21e87a8308ff34e55e0b77af00f5a470a93927232a6eee564a2a5b1844c80e5af9d82481a26db992b6b6d6c3577bbf7
7
- data.tar.gz: ac7e906db31d0be0c154dd26d90638195cf76727470c4167bc777f81aff26c75534d11eee3874eeb1cfcc401e78dd90802d8bfb28eee912ecaa0599797c5bc7f
6
+ metadata.gz: 9d229890262a4ea1cb220319299beb18c23a10f05c08f587da1abb8dcbc46117360923f8e7f1fd867f0b6b197c8d3f4f2cafe074837093fe467a9824e2b09577
7
+ data.tar.gz: 0ce71e1931452f3ac0ac3922179dc5b63ab2efed0cf4e20e1a10bd1d768b96850736f9fbef6a2d52b6a2426f9e7601ef2f5c893e6d1f6f8246b618a82e51ad81
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /mygem
11
+ *.swp
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- ruby "2.3.1"
3
2
 
3
+ # Specify your gem's dependencies in mushin.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,96 +1,41 @@
1
- What is Mushin
2
- ===============
3
- Mushin is a Domain-specific Framework Generator
1
+ # Mushin
4
2
 
5
- How to use Mushin
6
- =================
7
- Directly via
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mushin`. To experiment with that code, run `bin/console` for an interactive prompt.
8
4
 
9
- Mushin::Stack.new do
10
- use DomainSpecificExtA, opts, params
11
- use DomainSpecificExtB, opts, params
12
- use DomainSpecificExtC, opts, params
13
- end
5
+ TODO: Delete this and the text above, and describe your gem
14
6
 
15
- Indirectly via generating a domain-specific framework and using it instead to generate domain-specific Extentions.
7
+ ## Installation
16
8
 
17
- Generate the framework via
18
- ```
19
- mushin roll domainframeworkXYZ
20
- ```
21
- then after installing the framework gem in your system, generate extentions via
22
- ```
23
- domainframeworkXYZ ext extentionXYZ
24
- ```
25
- ```ruby
26
- DomainframeworkXYZ::Stack.new do
27
- use extentionXYZ1, opts, params
28
- use extentionXYZ2, opts, params
29
- use extentionXYZ3, opts, params
30
- end
31
- ```
9
+ Add this line to your application's Gemfile:
32
10
 
33
- Domain-specfic Extentions duck types to the following interface:
34
11
  ```ruby
35
- class ExtensionXYZ
36
- def initialize(app); end
37
- def call(env); end
38
- end
12
+ gem 'mushin'
39
13
  ```
40
14
 
41
- ######################################################################
42
- Mushin Books uses declarative DSL for describing what an expert want to do.
43
- https://www.netguru.co/blog/imperative-vs-declarative
44
-
45
-
46
- Mushin previously had crazy bugs as due to mutable objects, this is tend to be
47
- avoided in the current implementation.
15
+ And then execute:
48
16
 
49
- === What is Mushin?
50
- Mushin is a specification interface between your ruby application and domain-specific frameworks.
51
- It provides generation capabilities to kick start developing your own domain-specific framework based on the interface, thats the Mushin way.
52
- Following the Mushin way, new developers can easily start using your new domain-specific framework in their applications. as they expect it to behave similarlar to other mushin-based frameworks.
17
+ $ bundle
53
18
 
54
- Mushin is a spec describing how an application should implement a domian-specifc rules and actions, similar in the sense that rack is a spec describing how webservers and webframeworks should implement a webrequest and webresponse, following this anology a webrequest the equvilant to a mushin rule, and a webresponse the equivlant of mushin response. and mushin rules engine is similar to rails routecontroller, except that mushin rules engine may activate a number of actions for each rule invoked.
19
+ Or install it yourself as:
55
20
 
56
- === Mushin Goal
57
- Mushin goal is to be in service for preventing every ruby application from complecting different domain knolwedge, in the sense that via following the mushin way, each domain knoweldge is mature in isolation with its own middlewares, in the realm of its own domain-specific framework.
21
+ $ gem install mushin
58
22
 
59
- === What Mushin do?
60
- Mushin do to a ruby application and domain-specific frameworks, what rack does to webservers and webframeworks. Except that rack doesn't offer code generation capabilities for webframework developers. Note: in a general sense a webframework is a domains-specific framework for the 'web' domain, see TheMetal project for the future of rack and how the ruby community been trying to further enahnce rack.
23
+ ## Usage
61
24
 
62
- === Mushin TDD
25
+ TODO: Write usage instructions here
63
26
 
64
- === Writing Mushin Middleware
65
- It is a good practice to isolate the middleware from the logic, in the sense that that the logic code inside the call method of your middleware should only be concrned with descion flow and passing variables to your logic methods that typically will reside on its own classes.
27
+ ## Development
66
28
 
67
- ===== Example writing a Redis DataStore Middleware
68
- - first we start by writing the specs for our middleware which is typical and can be gernated in the future via mushin
69
- mushin_middleware_spec.rb
70
- - then we move own to write the actual middleware
71
- ##### this is a mushin middlware
72
- class redis
73
- def app(env)
74
- end
75
- def call(env)
76
- # here add your if, case statmetents
77
- end
78
- end
79
- - then we write the spec for our logic class that contain the methods for our logic
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
80
30
 
81
- - and finally we write the actually logic class that make the spec pass
82
- ##### this is a logic file for the middleware of mushin
83
- class RedisDS
84
- ##### here each function is used and tested in as a spec in isolation
85
- end
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
86
32
 
87
- === Mushin testing
33
+ ## Contributing
88
34
 
89
- ##### TODO Mushin::MockRequest, similar to rack's stack let(:request) { Rack::MockRequest.new(stack) }
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mushin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
90
36
 
91
37
 
92
- === Mushin Generation capabilities
93
- each new version of mushin contains a blue print of the domain-speicifc framework, it copies those files into a destenation directory and then uses grep to replace various code snippet
38
+ ## License
94
39
 
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
95
41
 
96
- === Virtual Currency Domain Framework, that includes middlewares for different client apis and gems to work with virtualcurrencies
data/Rakefile CHANGED
@@ -1,79 +1,10 @@
1
- require "rake"
2
- require 'rake/testtask'
3
- #require 'logger'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
4
3
 
5
- #$logger = Logger.new(STDOUT)
6
-
7
- task 'clear_screen' do
8
- `clear`
9
- end
10
-
11
- Rake::TestTask.new 'env_spec' do |t|
12
- #libs = ["lib/env.rb"]
13
- #t.warning = true
14
- #t.verbose = true
15
- t.test_files = FileList['spec/env_spec.rb']
16
- end
17
-
18
-
19
- Rake::TestTask.new 'engine_spec' => ['clear_screen'] do |t|
20
- libs = ["lib/engine.rb"]
21
- #t.warning = true
22
- #t.verbose = true
23
- t.test_files = FileList['spec/engine_spec.rb']
24
- end
25
-
26
- =begin
27
- Rake::TestTask.new 'ds_spec' => ['clear_screen'] do |t|
28
- libs = ["lib/ds/ds.rb"]
29
- t.warning = true
30
- t.verbose = true
31
- t.test_files = FileList['spec/ds/ds_spec.rb']
32
- end
33
-
34
- Rake::TestTask.new 'redis_spec' => ['clear_screen'] do |t|
35
- libs = ["lib/ds/redis.rb"]
36
- #t.warning = true
37
- #t.verbose = true
38
- t.test_files = FileList['spec/ds/redis_spec.rb']
39
- end
40
- # task :default => :complete_test
41
- # compelte test depends on flushin db then expecting a certain space upcoming events run the test
42
-
43
- #task 'db:flush' do
44
- # `redis-cli flushall`
45
- # $logger.info("Redis got a flushall")
46
- #end
47
- desc 'Complete clean test, should depend on other stuff'
48
- task :complete do
49
- #ENV['Somevariable'] = 'true'
50
- Rake::Task['db:info'].execute
51
- Rake::Task['db:flush'].invoke
52
- Rake::Task['test'].invoke
53
- end
54
-
55
- task 'db:monitor' do
56
- `redis-cli monitor`
57
- end
58
-
59
- task 'db:info' do
60
- `redis-cli INFO`
61
- end
62
- =end
63
- =begin
64
- Rake::TestTask.new 'test' => ['db:flush'] do
65
- libs = ["lib"]
66
- warning = true
67
- verbose = true
68
- test_files = FileList['spec/*_spec.rb']
69
- end
70
- =end
71
- =begin
72
- Rake::TestTask.new 'test' => ['clear_screen', 'db:flush'] do |t|
73
- t.libs = ["lib"]
74
- t.warning = true
75
- t.verbose = true
76
- t.test_files = FileList['spec/*_spec.rb']
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
77
8
  end
78
- =end
79
9
 
10
+ task :default => :test
data/about.md ADDED
@@ -0,0 +1,108 @@
1
+ #TODO
2
+ mushin itselef needs to be remade as a bundler generated gem to be able to run `bundle exec rake release` and similar, must use --exec too for adding mushin executables.
3
+
4
+ What is Mushin
5
+ ===============
6
+ Mushin is a Domain-specific Framework Generator
7
+
8
+ What Mushin does?
9
+ =================
10
+ Mushin generates:
11
+ 1) domain gems
12
+ 2) domain extenstion gems
13
+
14
+ resource: bundle exec rake release
15
+ resource: bundle gem --help
16
+
17
+ How to use Mushin
18
+ =================
19
+ Directly via
20
+
21
+ Mushin::Stack.new do
22
+ use DomainSpecificExtA, opts, params
23
+ use DomainSpecificExtB, opts, params
24
+ use DomainSpecificExtC, opts, params
25
+ end
26
+
27
+ Indirectly via generating a domain-specific framework and using it instead to generate domain-specific Extentions.
28
+
29
+ Generate the framework via
30
+ ```
31
+ mushin roll domainframeworkXYZ
32
+ ```
33
+ then after installing the framework gem in your system, generate extentions via
34
+ ```
35
+ domainframeworkXYZ ext extentionXYZ
36
+ ```
37
+ ```ruby
38
+ DomainframeworkXYZ::Stack.new do
39
+ use extentionXYZ1, opts, params
40
+ use extentionXYZ2, opts, params
41
+ use extentionXYZ3, opts, params
42
+ end
43
+ ```
44
+
45
+ Domain-specfic Extentions duck types to the following interface:
46
+ ```ruby
47
+ class ExtensionXYZ
48
+ def initialize(app); end
49
+ def call(env); end
50
+ end
51
+ ```
52
+
53
+ ######################################################################
54
+ Mushin Books uses declarative DSL for describing what an expert want to do.
55
+ https://www.netguru.co/blog/imperative-vs-declarative
56
+
57
+
58
+ Mushin previously had crazy bugs as due to mutable objects, this is tend to be
59
+ avoided in the current implementation.
60
+
61
+ === What is Mushin?
62
+ Mushin is a specification interface between your ruby application and domain-specific frameworks.
63
+ It provides generation capabilities to kick start developing your own domain-specific framework based on the interface, thats the Mushin way.
64
+ Following the Mushin way, new developers can easily start using your new domain-specific framework in their applications. as they expect it to behave similarlar to other mushin-based frameworks.
65
+
66
+ Mushin is a spec describing how an application should implement a domian-specifc rules and actions, similar in the sense that rack is a spec describing how webservers and webframeworks should implement a webrequest and webresponse, following this anology a webrequest the equvilant to a mushin rule, and a webresponse the equivlant of mushin response. and mushin rules engine is similar to rails routecontroller, except that mushin rules engine may activate a number of actions for each rule invoked.
67
+
68
+ === Mushin Goal
69
+ Mushin goal is to be in service for preventing every ruby application from complecting different domain knolwedge, in the sense that via following the mushin way, each domain knoweldge is mature in isolation with its own middlewares, in the realm of its own domain-specific framework.
70
+
71
+ === What Mushin do?
72
+ Mushin do to a ruby application and domain-specific frameworks, what rack does to webservers and webframeworks. Except that rack doesn't offer code generation capabilities for webframework developers. Note: in a general sense a webframework is a domains-specific framework for the 'web' domain, see TheMetal project for the future of rack and how the ruby community been trying to further enahnce rack.
73
+
74
+ === Mushin TDD
75
+
76
+ === Writing Mushin Middleware
77
+ It is a good practice to isolate the middleware from the logic, in the sense that that the logic code inside the call method of your middleware should only be concrned with descion flow and passing variables to your logic methods that typically will reside on its own classes.
78
+
79
+ ===== Example writing a Redis DataStore Middleware
80
+ - first we start by writing the specs for our middleware which is typical and can be gernated in the future via mushin
81
+ mushin_middleware_spec.rb
82
+ - then we move own to write the actual middleware
83
+ ##### this is a mushin middlware
84
+ class redis
85
+ def app(env)
86
+ end
87
+ def call(env)
88
+ # here add your if, case statmetents
89
+ end
90
+ end
91
+ - then we write the spec for our logic class that contain the methods for our logic
92
+
93
+ - and finally we write the actually logic class that make the spec pass
94
+ ##### this is a logic file for the middleware of mushin
95
+ class RedisDS
96
+ ##### here each function is used and tested in as a spec in isolation
97
+ end
98
+
99
+ === Mushin testing
100
+
101
+ ##### TODO Mushin::MockRequest, similar to rack's stack let(:request) { Rack::MockRequest.new(stack) }
102
+
103
+
104
+ === Mushin Generation capabilities
105
+ each new version of mushin contains a blue print of the domain-speicifc framework, it copies those files into a destenation directory and then uses grep to replace various code snippet
106
+
107
+
108
+ === Virtual Currency Domain Framework, that includes middlewares for different client apis and gems to work with virtualcurrencies
data/exe/mushin ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "mushin"
4
+
5
+ module Mushin
6
+ class CLI < Thor
7
+ #include Utter::Tips
8
+
9
+ no_commands do
10
+ def seprator
11
+ puts(" ")
12
+ puts("-------------------------------------------------------------------------------")
13
+ puts(" ")
14
+ end
15
+
16
+ def done
17
+ 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
+ say(message + motive)
26
+ end
27
+ end
28
+
29
+ desc "new", "Generate new a domain-specific framework \ domain extenstion"
30
+ def new command, params = {}
31
+ mushin_banner
32
+ if params.empty? then
33
+ case command
34
+ when "domain"
35
+
36
+ seprator
37
+
38
+ info = set_color(" INFO ", :green, :on_white, :bold)
39
+ message = " choose if your domain is standalone or nested "
40
+ puts (info + message)
41
+
42
+ #domain_name = ask(set_color("Domain Name, e.g. 'gamification': ", :bold))
43
+ gem_name = ask(set_color(" Enter a domain gem name: ", :bold))
44
+ gem_type = "domain"
45
+ gem_context = ask(set_color(" domain gem context? 'project' or 'standalone' ", :bold))
46
+ gem_editor = nil #ask(set_color(" gemspec editor? 'vim', 'emacs', etc. ", :bold))
47
+
48
+ seprator
49
+
50
+ params = {:gem_name => gem_name, :gem_type => gem_type, :gem_context => gem_context, :editor => gem_editor}
51
+
52
+ Mushin::Generator.new.gem params
53
+
54
+ done # Says Done you are awesome!
55
+ when "extension", "ext"
56
+ seprator
57
+
58
+ #TODO should search rubygems for for the given keywords and suggest a relevant Domain-specific Framework to use
59
+ #domain_framework_name = ask(set_color("Domain-specific Framework name, e.g. 'GameOn': ", :bold))
60
+ #domain_keywords = ask(set_color("Domain keywords, e.g. 'gamification': ", :bold))
61
+ ext_name = ask(set_color("Extension Name, e.g. 'badges': ",:bold))
62
+
63
+ p params = {:ext_name => ext_name}
64
+ #generator = Utter::Generators::Ext.new
65
+ #generator.create_ext params
66
+ else
67
+ p "not known"
68
+ end
69
+ else
70
+ #if params is not empty then use direct mode (good for piping from other programs)
71
+ end
72
+ end
73
+
74
+ desc "package", "Pacakges a domain\domain-extension as a gem and releases it to a gem server"
75
+ def package
76
+ `bundle exec rake release`
77
+ end
78
+
79
+ end
80
+ end
81
+
82
+ Mushin::CLI.start
@@ -0,0 +1,68 @@
1
+ require 'thor'
2
+
3
+ module Mushin
4
+ class Generator < Thor::Group
5
+ include Thor::Actions
6
+
7
+ def gem params
8
+ @params = params
9
+
10
+ #params = {:gem_name => gem_name, :gem_type => gem_type, :gem_context => gem_context, :editor => @editor}
11
+
12
+ @name = @params[:gem_name]
13
+ @type = @params[:gem_type]
14
+ @context = @params[:gem_context]
15
+ @editor = @params[:gem_editor]
16
+ #{:name => @name, :type =>type, :context => @context, :editor => @editor}
17
+
18
+ #clean the previous gem if it exists?
19
+ system("rm -rf #{@name}")
20
+
21
+ case @type
22
+ when "domain"
23
+ if @context == "project"
24
+ p "creating a domain inside a project"
25
+ #system "bundle gem #{@name.downcase} --test minitest --coc --edit=#{@editor}"
26
+ system "bundle gem #{@name.downcase} --test minitest --mit --exe --coc"
27
+ minitest_spec
28
+ system "mv #{@name.downcase} domain"
29
+ @name = "domain"
30
+ system "mkdir #{@name.downcase}/ext"
31
+ #system "#{@editor} #{@name.downcase}/#{@name.downcase}.gemspec"
32
+ #system "cd #{@name.downcase} && bundle install"
33
+ elsif @context == "standalone"
34
+ p "creating a standalone domain"
35
+ system "bundle gem #{@name.downcase} --test minitest --coc --edit=#{@editor}"
36
+ system "cd #{@name.downcase} && bundle install"
37
+ else
38
+ p "context value must either be project or standalone"
39
+ end
40
+ when "ext"
41
+ p "ext............"
42
+ end
43
+ end
44
+
45
+ def minitest_spec
46
+ system("cd #{@name} && mv test spec && mv spec/#{@name.downcase}_test.rb spec/#{@name.downcase}_spec.rb && mv spec/test_helper.rb spec/spec_helper.rb")
47
+
48
+ #p "change directory test to spec"
49
+ #system("cd #{@name} && mv test spec")
50
+
51
+ #p "change file name from test/#{@name.downcase}_test.rb to spec/#{@name.downcase}_spec.rb"
52
+ #system("cd #{@name} && mv spec/#{@name.downcase}_test.rb spec/#{@name.downcase}_spec.rb")
53
+
54
+ #p "change file name from test/test_helper.rb to spec/spec_helper.rb"
55
+ #system("cd #{@name} && mv spec/test_helper.rb spec/spec_helper.rb")
56
+
57
+ append_to_file "#{@name}/spec/spec_helper.rb" do
58
+ "require 'minitest/autorun'"
59
+ "require 'minitest/spec'"
60
+ "require 'minitest/pride'"
61
+ end
62
+
63
+ #system("cd #{@name} && mv test spec")
64
+ #require_relative "./../spec_helper"
65
+ end
66
+ end
67
+ end
68
+
@@ -0,0 +1,3 @@
1
+ module Mushin
2
+ VERSION = "0.2.0"
3
+ end
data/lib/mushin.rb CHANGED
@@ -1,14 +1,11 @@
1
- #require_relative './internals/env'
2
- #require_relative './internals/engine'
3
- #require_relative './internals/book'
4
-
1
+ require_relative "mushin/version"
2
+ require_relative "mushin/generator"
5
3
  require 'middleware'
6
4
  require 'logger'
7
- $logger = Logger.new(STDOUT)
8
5
 
6
+ $logger = Logger.new(STDOUT)
9
7
 
10
8
  module Mushin
11
- VERSION = "0.1.0"
12
9
  class Stack < Middleware::Builder
13
10
  def initialize &block
14
11
  # let's use `super` to instance_eval inside Middleware::Builder scope
data/mushin.gemspec CHANGED
@@ -1,9 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
- p lib
4
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require_relative "lib/mushin"
4
+ require 'mushin/version'
7
5
 
8
6
  Gem::Specification.new do |spec|
9
7
  spec.name = "mushin"
@@ -11,8 +9,8 @@ Gem::Specification.new do |spec|
11
9
  spec.authors = ["zotherstupidguy"]
12
10
  spec.email = ["zotherstupidguy@gmail.com"]
13
11
 
14
- spec.summary = %q{Mushin is a Domain-specific Frameworks Generator.}
15
- spec.description = %q{Mushin is a Domain-specific Frameworks Generator}
12
+ spec.summary = %q{mushin is a domain-specific framwork generator}
13
+ spec.description = %q{mushin allows you to generate domain-specific frameworks and domain extenstions.}
16
14
  spec.homepage = "http://mushin-rb.github.io/"
17
15
  spec.license = "MIT"
18
16
 
@@ -36,5 +34,8 @@ Gem::Specification.new do |spec|
36
34
  spec.add_development_dependency "ibsciss-middleware", "~> 0.3"
37
35
  spec.add_runtime_dependency "ibsciss-middleware", "~> 0.3"
38
36
 
37
+ spec.add_development_dependency "thor" #, "~> 0.3"
38
+ spec.add_runtime_dependency "thor" #, "~> 0.3"
39
+
39
40
  #TODO http://guides.rubygems.org/security/
40
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mushin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zotherstupidguy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-02 00:00:00.000000000 Z
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,29 +80,56 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.3'
83
- description: Mushin is a Domain-specific Frameworks Generator
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: mushin allows you to generate domain-specific frameworks and domain extenstions.
84
112
  email:
85
113
  - zotherstupidguy@gmail.com
86
- executables: []
114
+ executables:
115
+ - mushin
87
116
  extensions: []
88
117
  extra_rdoc_files: []
89
118
  files:
119
+ - ".gitignore"
120
+ - ".travis.yml"
90
121
  - CODE_OF_CONDUCT.md
91
122
  - Gemfile
92
- - Gemfile.lock
93
123
  - LICENSE.txt
94
124
  - README.md
95
125
  - Rakefile
126
+ - about.md
96
127
  - bin/console
97
128
  - bin/setup
98
- - lib/internals/book.rb
99
- - lib/internals/ds/ds.rb
100
- - lib/internals/ds/redis.rb
101
- - lib/internals/ds/secure_ds.rb
102
- - lib/internals/engine.rb
103
- - lib/internals/env.rb
104
- - lib/internals/wongi.rb
129
+ - exe/mushin
105
130
  - lib/mushin.rb
131
+ - lib/mushin/generator.rb
132
+ - lib/mushin/version.rb
106
133
  - mushin.gemspec
107
134
  homepage: http://mushin-rb.github.io/
108
135
  licenses:
@@ -127,5 +154,5 @@ rubyforge_project:
127
154
  rubygems_version: 2.6.7
128
155
  signing_key:
129
156
  specification_version: 4
130
- summary: Mushin is a Domain-specific Frameworks Generator.
157
+ summary: mushin is a domain-specific framwork generator
131
158
  test_files: []
data/Gemfile.lock DELETED
@@ -1,28 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mushin (0.1.0)
5
- ibsciss-middleware (~> 0.3)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ibsciss-middleware (0.4.1)
11
- minitest (5.8.2)
12
- rake (10.4.2)
13
-
14
- PLATFORMS
15
- ruby
16
-
17
- DEPENDENCIES
18
- bundler (~> 1.12)
19
- ibsciss-middleware (~> 0.3)
20
- minitest (~> 5.0)
21
- mushin!
22
- rake (~> 10.0)
23
-
24
- RUBY VERSION
25
- ruby 2.3.1p112
26
-
27
- BUNDLED WITH
28
- 1.12.5
@@ -1,47 +0,0 @@
1
- require 'logger'
2
- $logger = Logger.new(STDOUT)
3
-
4
- module Mushin
5
- module Book
6
- def rule &block
7
- @rule = {}
8
- @rule[:conditions] = []
9
- @rule[:actions] = []
10
- def condition c
11
- @rule[:conditions] << c
12
- $l.info "condition #{c} is added"
13
- end
14
- def action a
15
- @rule[:actions] << a
16
- $l.info "action #{a} is added"
17
- end
18
- yield
19
- $logger.info "this rule is #{@rule}"
20
- Mushin::Engine.add_rule @rule
21
- end
22
- end
23
- end
24
-
25
- module MyCookBook
26
- extend Mushin::Book
27
-
28
- rule do
29
- condition [:subject_a, :predicate_a, :object_a]
30
- condition :b_condition
31
- condition :c_condition
32
-
33
- action :a_action
34
- action :b_action
35
- action :c_action
36
- end
37
-
38
- rule do
39
- condition :d_condition
40
- condition :e_condition
41
- condition :f_condition
42
-
43
- action :d_action
44
- action :e_action
45
- action :f_action
46
- end
47
- end
@@ -1,31 +0,0 @@
1
- require_relative './redis'
2
-
3
- module Mushin
4
- module Persistence
5
- class DS
6
-
7
- def initialize(app, opts={}, params={})
8
- @app = app
9
- @opts = opts
10
- @params = params
11
- @redis_ds = Mushin::Persistence::RedisDS.new
12
- end
13
-
14
- def call(env)
15
- @id = env[:id]
16
- if @redis_ds.exists? @id
17
- env[:id] = @redis_ds.get(@id)[:id]
18
- env[:data] = @redis_ds.get(@id)[:data]
19
- $logger.info("domain env object exists in the database")
20
- else
21
- @redis_ds.set(@id, env[:data])
22
- $logger.info("domain env object DOESNOT exist in the database")
23
- end
24
- @app.call(env) # calls up the stack
25
- @redis_ds.set(@id, env)
26
- env
27
- end
28
-
29
- end
30
- end
31
- end
@@ -1,31 +0,0 @@
1
- require "redis"
2
-
3
- module Mushin
4
- module Persistence
5
- class RedisDS
6
- attr_accessor :id, :value_obj
7
- def initialize(opts={}, params={})
8
- #@id = params[:id]
9
- #@value_obj = params[:value_obj]
10
- @redis = Redis.new #opts to take a different redis server
11
- end
12
-
13
- def set(id = @id, value_obj = @value_obj)
14
- @redis.set(id, Marshal.dump(value_obj))
15
- end
16
-
17
- def get(id = @id)
18
- Marshal.load(@redis.get(id))
19
- #@redis.get(id)
20
- end
21
-
22
- def exists?(id)
23
- if @redis.get(id).nil? then
24
- return false
25
- else
26
- return true
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,101 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "openssl"
3
- require 'digest/sha2'
4
- require 'base64'
5
-
6
- # We use the AES 256 bit cipher-block chaining symetric encryption
7
- alg = "AES-256-CBC"
8
-
9
- # We want a 256 bit key symetric key based on some passphrase
10
- digest = Digest::SHA256.new
11
- digest.update("fouad is cool symetric key")
12
- key = digest.digest
13
- # We could also have just created a random key
14
- # key = OpenSSL::Cipher::Cipher.new(alg).random_key
15
-
16
- # For security as part of the encryption algorithm, we create a random
17
- # initialization vector.
18
- iv = OpenSSL::Cipher::Cipher.new(alg).random_iv
19
- #iv = OpenSSL::Cipher::Cipher.new(alg).key = "dfsdfasfsafasfaffouad"
20
- #p OpenSSL::Cipher::Cipher.new(alg).methods
21
-
22
- # Example, we debug output our key in various formats
23
- puts "Our key: #{key}"
24
-
25
- # Base64 the key
26
- key64 = [key].pack('m')
27
- puts "Our key base 64: #{key64}"
28
-
29
- # Base64 decode the key
30
- raise 'Key Error' if(key.nil? or key.size != 32)
31
- puts "Our key retrieved from base64: #{key64.unpack('m')[0]}"
32
-
33
- # Now we do the actual setup of the cipher
34
- aes = OpenSSL::Cipher::Cipher.new(alg)
35
- aes.encrypt
36
- aes.key = key
37
- aes.iv = iv
38
-
39
- =begin
40
- # Now we go ahead and encrypt our plain text.
41
- cipher = aes.update("This is line 1\n")
42
- cipher << aes.update("This is some other string without linebreak.")
43
- cipher << aes.update("This follows immediately after period.")
44
- cipher << aes.update("Same with this final sentence")
45
- cipher << aes.final
46
- =end
47
- class Env
48
- def initialize(str)
49
- @str = str
50
- end
51
- def say_hello
52
- @str
53
- end
54
- end
55
-
56
- #o = Env.new("hello\n")
57
- #data = Marshal.dump(o)
58
- #obj = Marshal.load(data)
59
- #obj.say_hello #=> "hello\n"
60
-
61
- o = Env.new("hello\n")
62
- #cipher = Marshal.dump(Env.new("hello"))
63
- #cipher = Marshal.dump(o)
64
- cipher = "fouad"
65
-
66
- puts "Our Encrypted data in base64"
67
- cipher64 = [cipher].pack('m')
68
- puts cipher64
69
-
70
- decode_cipher = OpenSSL::Cipher::Cipher.new(alg)
71
- decode_cipher.decrypt
72
- decode_cipher.key = key
73
- decode_cipher.iv = iv
74
- plain = decode_cipher.update(cipher64.unpack('m')[0])
75
- p plain
76
- #p decode_cipher.final
77
- #plain << decode_cipher.final
78
- #puts "Decrypted Text"
79
- #puts plain
80
- #p plain
81
- obj = Marshal.load(plain)
82
- p obj.say_hello #=> "hello\n"
83
-
84
-
85
- =begin
86
- '
87
- # aes encode a file into another file.
88
- File.open("foo.enc","w") do |enc|
89
- File.open("foo") do |f|
90
- loop do
91
- r = f.read(4096)
92
- break unless r
93
- cipher = aes.update(r)
94
- enc << cipher
95
- end
96
- end
97
-
98
- enc << aes.final
99
- end
100
- '
101
- =end
@@ -1,44 +0,0 @@
1
- module Mushin
2
- class Engine
3
-
4
- @@book_rules = []
5
-
6
- def self.add_rule rule
7
- @@book_rules << rule
8
- end
9
-
10
- def self.get_rules
11
- # load or require_relative certain ruby books, done to be least invasive
12
- @@book_rules
13
- end
14
-
15
- def initialize env, book
16
- @env_id = env[:id]
17
- @env_rules = env[:rules]
18
- @book_rules = book[:rules]
19
- match
20
- end
21
-
22
- def match
23
- @@book_rules.each do |rule|
24
- if rule[:conditions] == "my provided conditions" then
25
- # apply rule[:actions]
26
- end
27
- end
28
- @book_rules[@env_rules.to_sym]
29
- end
30
-
31
- #def self.set_rules
32
- # loads or require certain ruby books
33
- # book ||= {:rules => {:some_data => "some rules(conditions and actions)", :x => "dfdf", :y => "dfdf"}}
34
- # Book.new("location of the book file") will return an array or hash of the rules
35
- #end
36
-
37
- def self.run env
38
- env[:book_rules] = get_rules
39
- new(env, @@rules)
40
- end
41
- end
42
- end
43
-
44
- #Mushin::Engine.run({:id => "myid", :rules => "some_data"})
data/lib/internals/env.rb DELETED
@@ -1,98 +0,0 @@
1
- module Mushin
2
- class Env
3
-
4
- attr_accessor :id, :rule , :env
5
-
6
- def initialize id, &block
7
- @env = {}
8
- @env[:rules] = []
9
- @id = id
10
- @env[:id] = @id
11
- instance_eval &block if block_given?
12
- end
13
-
14
- def rule(conditions = [])
15
- @env[:rules] << conditions
16
- end
17
-
18
- def self.set id, &block
19
- domain_instance = Mushin::Env.new id, &block
20
- Mushin::Engine.run domain_instance
21
- end
22
-
23
- # run engine, give the env to the engine,
24
- # engine will return the env_instance after it hit all the middlewares including the database middleware.
25
- # because domain_instance.env[:rules] is empty as there is no block; the Engine stack will only be of one middleware
26
- # , the Mushin::Presistance::DS middleware
27
- # Mushin::Engine.run domain_instance
28
- def self.get id
29
- domain_instance = Mushin::Env.new id
30
- Mushin::Engine.run domain_instance
31
- end
32
-
33
- end
34
- end
35
-
36
- =begin
37
- def self.set id
38
- self.new id
39
- #Mushin::Persistence::RedisDS.new.set @id
40
- end
41
- def self.get id
42
- self.new id
43
- #Mushin::Persistence::RedisDS.new.get @id
44
- end
45
- =end
46
- =begin
47
- # Each Domain Framework got its own Env object in the application space.
48
- # In this manner the application can easily set and get enviroment objects
49
- #
50
- module Mushin
51
- class Env
52
-
53
- attr_accessor :id, :current_context_title, :activities
54
-
55
- def initialize
56
- @id = ''
57
- @current_context_title = ''
58
- @activities = []
59
- end
60
-
61
- def set id, &block
62
- @id = id.to_s + 'mushin'
63
- def context current_context_title, &block
64
- @current_context_title = current_context_title
65
- @activities = []
66
- def activity current_activity_title
67
- @activities << current_activity_title
68
- end
69
- instance_eval(&block)
70
- end
71
- instance_eval(&block)
72
- #@activities.uniq.each do |current_activity_title|
73
- @activities.each do |current_activity_title|
74
- #GameOn::Engine.run @id, @current_context_title, current_activity_title
75
- $logger.info("Domain Framework Engine.run: #{@id}, #{@current_context_title}, #{current_activity_title}")
76
- end
77
- @activities = [] # reset the activities
78
- return Mushin::Persistence::DS.load @id
79
- end
80
-
81
- def get id
82
- @id = id.to_s + 'mushin'
83
- #TODO make a git issue for some encryption method based on a configurable app key
84
- Mushin::Persistence::DS.load @id
85
- end
86
-
87
- def self.set id, &block
88
- e = Env.new
89
- e.set id, &block
90
- end
91
-
92
- def self.get id
93
- e = Env.new
94
- e.get id
95
- end
96
- end
97
- end
98
- =end
@@ -1,38 +0,0 @@
1
- require 'wongi-engine'
2
-
3
- include Wongi::Engine
4
-
5
- @ds = Network.new
6
-
7
- person = Hash.new
8
- person[:name] = "mohamed"
9
- person[:age] = "31"
10
-
11
-
12
- def all
13
- # puts "Enumerate all:"
14
- #@ds.each do |wme|
15
- # puts wme
16
- #end
17
- end
18
-
19
- #puts "Mismatching pattern:"
20
- #@ds.each :_, "foe", :_ do |wme|
21
- # puts wme
22
- #ekd
23
-
24
- #{:subject=>{:name=>"mohamed", :age=>"31"}, :predicate=>"friend", :object=>"Bob"}
25
- def run subject, predicate, object
26
- @ds << WME.new( subject, predicate, object)
27
-
28
- #puts "Enumerate by pattern:"
29
- @ds.each do |wme|
30
- #ds.each :_, "friend", :_ do |wme|
31
- puts wme
32
- puts wme.to_h #methods
33
- puts "use MushinFrameworkName::MiddlewareName, opts, params #{wme.to_h[:subject]}"
34
- end
35
- end
36
-
37
- run person, "mypredicate", Random.new_seed
38
- run person, "mypredicate", Random.new_seed