mushin 0.0.0.pre56 → 0.0.0.pre57

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/mushin +335 -1
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c94d41be53a62c2e96adbf60f8c806b7fb35c28
4
- data.tar.gz: 3597837d49dd4fbd6a74540d66b31e25e2cafe9a
3
+ metadata.gz: 178ce4de9b878461363255692aa2fb9dbf053dd9
4
+ data.tar.gz: 3175c40a52bb6a5ffbd5f1070dda1d55418050a8
5
5
  SHA512:
6
- metadata.gz: b8b355de29117a68d97c0c2846acf98ec93897eda1fd37078da432a357dc4091000c7fbfb8f05259edf1211d3db08b0c3da4bc169cf556713a204ff476a96ce2
7
- data.tar.gz: 5b7fbfa681adff7baeb02c641e63f78f7dc215cc1e6a229e61d113667b237d1ff809d31df340b209dd9b9d6e58858477b75a43c65e9ec9205a0c86381a2db0a3
6
+ metadata.gz: d8231d4c2dea5a78610601700af970d9ee2ae440c678d37f2074439c90b1702a40557251dde0f60dc0c1ea87e114e1972137891f4af40833aefd330216214fc4
7
+ data.tar.gz: acd268475a5a1841ab39ed9d4e10fd216bf13acb9c5f191310bbe79b1bcb3d0f84f876d317608a0a0bd8f116d5febe32bf924d0c34bf288821e58a064d7072f4
data/bin/mushin CHANGED
@@ -1,3 +1,337 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ require 'optparse'
2
4
 
3
- print 'mushin is coming'
5
+ subtext = <<HELP
6
+ _ _
7
+ | | (_)
8
+ _ __ ___ _ _ ___| |__ _ _ __
9
+ | '_ ` _ \| | | / __| '_ \| | '_ \
10
+ | | | | | | |_| \__ \ | | | | | | |
11
+ |_| |_| |_|\__,_|___/_| |_|_|_| |_|
12
+
13
+
14
+ Commonly used command are:
15
+ config : generats mushin config.rb i.e. rubygems & github authentications
16
+ roll : roll your own framework
17
+
18
+ HELP
19
+
20
+ global = OptionParser.new do |opts|
21
+ opts.banner = "Usage: mushin [command] [options]"
22
+ opts.separator ""
23
+ opts.separator subtext
24
+ end
25
+ global.order!
26
+ command = ARGV.shift
27
+ if command == 'roll'
28
+ module Mushin
29
+ class << self
30
+ @@configs = {}
31
+ def []= key, value
32
+ @@configs[key.to_sym] = value
33
+ end
34
+
35
+ def [] key
36
+ @@configs[key.to_sym]
37
+ end
38
+ end
39
+ end
40
+ require_relative './config'
41
+
42
+ #@framework = Mushin[:framework]
43
+ @framework = ARGV[0]
44
+ p "Framework: #{@framework}"
45
+ @author = 'baddude'
46
+
47
+ # Framework Gem
48
+ if File.directory?("#{@framework.downcase}")
49
+ FileUtils.remove_dir (Dir::pwd + "/#{@framework.downcase}")
50
+ end
51
+
52
+ Dir.mkdir(Dir::pwd + "/#{@framework.downcase}")
53
+ Dir.mkdir(Dir::pwd + "/#{@framework.downcase}/bin")
54
+ Dir.mkdir(Dir::pwd + "/#{@framework.downcase}/lib")
55
+ Dir.mkdir(Dir::pwd + "/#{@framework.downcase}/lib/#{@framework.downcase}")
56
+ Dir.mkdir(Dir::pwd + "/#{@framework.downcase}/spec")
57
+
58
+
59
+ df = File.new("#{@framework.downcase}/bin/#{@framework.downcase}", "w")
60
+ df.puts <<-eos
61
+ #!/usr/bin/env ruby
62
+
63
+ require 'fileutils'
64
+ @name = "Points".capitalize
65
+ @middleware = '#{@framework.downcase}-' + @name.downcase
66
+
67
+ # Generates a #{@framework} Middleware Gem
68
+ #
69
+ if File.directory?(@middleware.downcase)
70
+ FileUtils.remove_dir (Dir::pwd + "/" + @middleware.downcase)
71
+ end
72
+ Dir.mkdir(Dir::pwd + "/" + @middleware.downcase)
73
+ Dir.mkdir(Dir::pwd + "/" + @middleware.downcase + "/lib")
74
+ Dir.mkdir(Dir::pwd + "/" + @middleware.downcase + "/lib/" + @middleware.downcase)
75
+
76
+ df = File.new(@middleware.downcase + "/" + @middleware.downcase + ".gemspec", "w")
77
+ df.puts <<-gf
78
+ # coding: utf-8
79
+ lib = File.expand_path('../lib', __FILE__)
80
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
81
+
82
+ Gem::Specification.new do |spec|
83
+ spec.name = "\#{@middleware}"
84
+ spec.version = "0.0.0.pre1"
85
+ spec.authors = ["#{@author}"]
86
+ spec.email = ["#{@email}"]
87
+ spec.summary = "#{@ds_summary}"
88
+ spec.description = "#{@ds_desc}"
89
+ spec.homepage = "#{@ds_website}"
90
+ spec.license = "#{@license}"
91
+
92
+ spec.files = Dir.glob("{lib}/**/*")
93
+ spec.require_paths = ["lib"]
94
+ end
95
+ gf
96
+ df.close
97
+ df = File.new(@middleware.downcase + "/lib/" + @middleware.downcase + ".rb", "w")
98
+ df.puts("require " + "'" + @middleware + "/base" + "'")
99
+ df.close
100
+
101
+ df = File.new(@middleware.downcase + "/lib/" + @middleware.downcase + "/base.rb", "w")
102
+
103
+ df.puts("#{@framework}::Env.register do")
104
+ df.puts(" #TODO add needed code to #{@framework} Env")
105
+ df.puts("end")
106
+
107
+ df.puts("module #{@framework}")
108
+ df.puts(" class \#{@name}")
109
+ df.puts(" include #{@framework}::Middleware ")
110
+ df.puts(" def initialize(app, opts={},params={})")
111
+ df.puts(" @app = app")
112
+ df.puts(" @opts = opts ")
113
+ df.puts(" @params = params")
114
+ df.puts(" end")
115
+ df.puts(" def call(env)")
116
+ df.puts(" #TODO add code here to be executed before calling the next middleware")
117
+ df.puts(" @app.call(env) # run the next middleware")
118
+ df.puts(" #TODO add code here to be executed after calling the next middleware ")
119
+ df.puts(" end")
120
+ df.puts(" end")
121
+ df.puts("end")
122
+ df.close
123
+ eos
124
+ df.close
125
+
126
+ df = File.new("#{@framework.downcase}/lib/#{@framework.downcase}.rb", "w")
127
+ df.puts("require '#{@framework.downcase}/base'")
128
+ df.close
129
+
130
+ df = File.new("#{@framework.downcase}/lib/#{@framework.downcase}/base.rb", "w")
131
+ df.puts <<-eos
132
+ module #{@framework}
133
+ module Middleware
134
+ include Mushin::Domain::Middleware
135
+ end
136
+ module DSL
137
+ include Mushin::DSL
138
+ def self.find activity_context, activity_statment
139
+ Mushin::DSL.middlewares = []
140
+ Mushin::DSL.contexts.each do |current_context|
141
+ if activity_context == current_context.title
142
+ current_context.statments.each do |statment|
143
+ if activity_statment == statment.title
144
+ statment.activations.each do |middleware|
145
+ Mushin::DSL.middlewares << middleware
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
151
+ Mushin::DSL.middlewares
152
+ end
153
+ end
154
+ module Engine
155
+ extend Mushin::Engine
156
+ class << self
157
+ def run domain_context, activity
158
+ @stack = Mushin::Middleware::Builder.new do
159
+ (#{@framework}::DSL.find domain_context, activity).each do |middleware|
160
+ p "#{@framework} Logging: use " + middleware.name.to_s + " " + middleware.opts.to_s + " " + middleware.params.to_s
161
+ use middleware.name, middleware.opts, middleware.params
162
+ end
163
+ end
164
+ @setup_middlewares.each do |setup_middleware|
165
+ @stack.insert_before 0, setup_middleware
166
+ end
167
+ @stack.call
168
+ end
169
+ end
170
+ end
171
+ class Env
172
+ extend Mushin::Env
173
+
174
+ class << self
175
+ attr_accessor :id
176
+
177
+ def get id
178
+ #{@framework}::Persistence::DS.load id.to_s + #{@framework.downcase}
179
+ end
180
+
181
+ def set id, &block
182
+ @id = id.to_s + #{@framework.downcase}
183
+ def on domain_context, &block
184
+ @domain_context = domain_context
185
+ @activities = []
186
+ def activity statment
187
+ @activities += [statment]
188
+ end
189
+ instance_eval(&block)
190
+ end
191
+ instance_eval(&block)
192
+
193
+ Dir["./#{@framework.downcase}/*"].each {|file| load file }
194
+
195
+ #{@framework}::Engine.setup [Object.const_get('#{@framework}::Persistence::DS')]
196
+ @activities.each do |activity|
197
+ #{@framework}::Engine.run @domain_context, activity
198
+ end
199
+ return #{@framework}::Persistence::DS.load @id
200
+ end
201
+ end
202
+ end
203
+ end
204
+ eos
205
+ df.close
206
+
207
+ df = File.new("#{@framework.downcase}/#{@framework.downcase}.gemspec", "w")
208
+ df.puts <<-eos
209
+ # coding: utf-8
210
+ lib = File.expand_path('../lib', __FILE__)
211
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
212
+
213
+ Gem::Specification.new do |spec|
214
+ spec.name = "#{@framework.downcase}"
215
+ spec.version = "0.0.0.pre1"
216
+ spec.authors = ["#{@author}"]
217
+ spec.email = ["#{@email}"]
218
+ spec.summary = "#{@summary}"
219
+ spec.description = "#{@desc}"
220
+ spec.homepage = "#{@website}"
221
+ spec.license = "#{@license}"
222
+
223
+ spec.files = Dir.glob("{lib}/**/*")
224
+ spec.require_paths = ["lib"]
225
+ end
226
+ eos
227
+ df.close
228
+
229
+ # Framework Peristance Gem
230
+ @ds = @framework.downcase + '-redis'
231
+ if File.directory?("#{@ds.downcase}")
232
+ FileUtils.remove_dir (Dir::pwd + "/#{@ds.downcase}")
233
+ end
234
+ Dir.mkdir(Dir::pwd + "/#{@ds.downcase}")
235
+ Dir.mkdir(Dir::pwd + "/#{@ds.downcase}/lib")
236
+ Dir.mkdir(Dir::pwd + "/#{@ds.downcase}/lib/#{@ds.downcase}")
237
+ Dir.mkdir(Dir::pwd + "/#{@ds.downcase}/spec")
238
+
239
+ df = File.new("#{@ds.downcase}/lib/#{@ds.downcase}.rb", "w")
240
+ df.puts("require '#{@ds}/base'")
241
+ df.close
242
+
243
+ df = File.new("#{@ds.downcase}/lib/#{@ds.downcase}/base.rb", "w")
244
+ df.puts <<-eos
245
+ require "redis"
246
+
247
+ module #{@framework}
248
+ module Persistence
249
+ class DS
250
+
251
+ #{@framework}::Env.register do
252
+ attr_accessor :id
253
+ end
254
+
255
+ @@redis = Redis.new
256
+
257
+ def initialize app
258
+ @app = app
259
+ @id = #{@framework}::Env.id
260
+ end
261
+
262
+ def call(env)
263
+ p "#{@framework}::Persistence::DS instance id = " + @id.to_s
264
+ if exists? @id
265
+ env[:#{@framework.downcase}] = DS.load @id
266
+ p 'resotred' + env[:#{@framework.downcase}].to_s
267
+ else
268
+ p 'new obj from #{@framework}::Env class'
269
+ env[:#{@framework.downcase}] = #{@framework}::Env.new
270
+ env[:#{@framework.downcase}].id = @id
271
+ p "env[:#{@framework.downcase}].id equals " + env[:#{@framework.downcase}].id.to_s
272
+ end
273
+ @app.call(env)
274
+ DS.store env[:#{@framework.downcase}]
275
+ p "stored " + env[:#{@framework.downcase}].to_s
276
+ end
277
+
278
+ def DS.store obj
279
+ begin
280
+ @#{@framework.downcase}_env = Marshal.dump obj
281
+ @@redis.set(obj.id, @#{@framework.downcase}_env)
282
+ ensure
283
+ p "storing #{@framework} Env " + obj.to_s
284
+ end
285
+ end
286
+ def DS.load id
287
+ return Marshal.load (@@redis.get(id))
288
+ end
289
+
290
+ def exists? id
291
+ if (@@redis.get id) && (Marshal.load @@redis.get id)
292
+ p "#{@framework}::Persistence::DS.exists? true"
293
+ return true
294
+ else
295
+ p "#{@framework}::Persistence::DS.exists? false"
296
+ return false
297
+ end
298
+ end
299
+ end
300
+ end
301
+ end
302
+ eos
303
+ df.close
304
+
305
+ df = File.new("#{@ds.downcase}/#{@ds.downcase}.gemspec", "w")
306
+ df.puts <<-eos
307
+ # coding: utf-8
308
+ lib = File.expand_path('../lib', __FILE__)
309
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
310
+
311
+ Gem::Specification.new do |spec|
312
+ spec.name = "#{@ds.downcase}"
313
+ spec.version = "0.0.0.pre1"
314
+ spec.authors = ["#{@author}"]
315
+ spec.email = ["#{@email}"]
316
+ spec.summary = "#{@ds_summary}"
317
+ spec.description = "#{@ds_desc}"
318
+ spec.homepage = "#{@ds_website}"
319
+ spec.license = "#{@license}"
320
+
321
+ spec.files = Dir.glob("{lib}/**/*")
322
+ spec.require_paths = ["lib"]
323
+ end
324
+ eos
325
+ df.close
326
+
327
+ `gem build #{@framework.downcase}/#{@framework.downcase}.gemspec`
328
+ `gem build #{@ds.downcase}/#{@ds.downcase}.gemspec`
329
+ `gem push #{@framework.downcase}-0.0.0.pre1.gem`
330
+ `rm #{@framework.downcase}`
331
+ `gem push #{@ds.downcase}-0.0.0.pre1.gem`
332
+ `rm #{@ds.downcase}`
333
+ end
334
+
335
+ if command == 'config'
336
+ p "generating mushin's config.rb "
337
+ 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.0.0.pre56
4
+ version: 0.0.0.pre57
5
5
  platform: ruby
6
6
  authors:
7
7
  - theotherstupidguy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-30 00:00:00.000000000 Z
11
+ date: 2014-05-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: In the beginner’s mind there are many possibilities, in the expert’s
14
14
  mind there are few!
@@ -28,7 +28,7 @@ licenses:
28
28
  - MIT
29
29
  metadata: {}
30
30
  post_install_message: |2
31
- ! Mushin is kinda Awesome.
31
+ Mushin is kinda Awesome, please ENJOY!
32
32
  rdoc_options: []
33
33
  require_paths:
34
34
  - lib