flok 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/bin/flok +19 -1
- data/flok.gemspec +1 -0
- data/lib/flok.rb +17 -1
- data/lib/flok/version.rb +1 -1
- data/lib/js/kernel/common.js +1 -0
- data/lib/js/kernel/handleCustomEvent.js +3 -3
- data/lib/js/kernel/handleInitEvent.js +3 -3
- data/lib/js/kernel/handleTickEvent.js +1 -1
- data/lib/js/kernel/pipe.js +12 -12
- data/lib/js/kernel/task.js +4 -4
- data/spec/cli_spec.rb +134 -2
- data/spec/merge_source_spec.rb +27 -0
- metadata +18 -3
- data/bin/banner.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5e1200a43eac75a5bdf221ec8653eeaec723f88
|
4
|
+
data.tar.gz: b8b102d8edd66ef040de7ec101a6e30b33be5833
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9139c10262284a1b2358f2b3863c803d739f818b68cdfbbc58830f6368fb086cfd5703ce09823242186f734023b7a443760ec93be490b5117d057bf068532cab
|
7
|
+
data.tar.gz: 34febd5c86fd6bb185f007da137fc4ae648ea98e56ee366c82a8cf16ddd23bbb23539f7e47421cd708fa743f2d3b4d7c415ec775cd1bcb07c479cc7aa4c32b52
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
![flok: The
|
1
|
+
![flok: The eventful application framework](https://raw.githubusercontent.com/sotownsend/flok/master/logo.png)
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/iarrogant.svg)](http://badge.fury.io/rb/flok)
|
4
4
|
[![Build Status](https://travis-ci.org/sotownsend/flok.svg)](https://travis-ci.org/sotownsend/flok)
|
@@ -9,6 +9,24 @@
|
|
9
9
|
|
10
10
|
A work in progress
|
11
11
|
|
12
|
+
# Flok Modules
|
13
|
+
A concept borrowed from [Rails engines](http://guides.rubyonrails.org/engines.html), Flok modules both serve as your project files, all library modules, and gemified instances. That is, a project you create is automatically modular and can be imported in another flok module/project.
|
14
|
+
|
15
|
+
# Compilation
|
16
|
+
Flok does not rely on ruby for the final produced `application.js` file. The output file is pure javascript and written in javascript (not transcoded). Ruby only serves as a compilation assistant.
|
17
|
+
|
18
|
+
# Task
|
19
|
+
The task is the base unit in flok, similar to a rack module except that rack is a stack and flok is a party. Based on concepts borrowed from XNU®, FreeBSD®, and GNU HURD®; tasks are combined in flok to produce behavior by many tasks inter-cooperating. Efficiency has been provided through virtualizing the task communication so that no message passing takes place inside flok and all modules are combined into an efficient monolithic module.
|
20
|
+
|
21
|
+
### Task Facilities
|
22
|
+
Tasks are able to
|
23
|
+
- send and receive events from a global or internal source.
|
24
|
+
- set interval and timeout timers.
|
25
|
+
- store temporary data in it's own heap '$__'
|
26
|
+
|
27
|
+
### Default modules
|
28
|
+
This flok project contains the 'micro-task-kernel', the 'ui', and the 'operations' modules.
|
29
|
+
|
12
30
|
## Requirements
|
13
31
|
|
14
32
|
- Mac OS X 10.9+ (Untested)
|
data/bin/flok
CHANGED
@@ -2,11 +2,29 @@
|
|
2
2
|
|
3
3
|
require 'flok'
|
4
4
|
require 'thor'
|
5
|
+
require 'fileutils'
|
5
6
|
|
6
7
|
class FlokCLI < Thor
|
7
8
|
desc "new <path>", "Create a new flok project and/or module, you may supply an absolute path or relative, the last entry in the path will be the module name and folder name of the project"
|
8
9
|
def new path
|
9
|
-
|
10
|
+
name = File.basename(path)
|
11
|
+
Dir.chdir File.dirname(path) do
|
12
|
+
`bundle gem #{name}`
|
13
|
+
|
14
|
+
Dir.chdir name do
|
15
|
+
Dir.mkdir "app"
|
16
|
+
Dir.mkdir "config"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "build", "Build a flok project, you must be in the root of the project"
|
22
|
+
def build
|
23
|
+
Dir.mkdir("./public") unless File.exists?("./public")
|
24
|
+
FileUtils.touch "./public/application.js"
|
25
|
+
|
26
|
+
kernel_src = Flok::MergeSource.merge_kernel
|
27
|
+
File.write("./public/application.js", kernel_src)
|
10
28
|
end
|
11
29
|
end
|
12
30
|
|
data/flok.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.3"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.2"
|
24
|
+
spec.add_development_dependency "execjs", "~> 2.4.0"
|
24
25
|
spec.add_runtime_dependency "thor", "~> 0.19"
|
25
26
|
spec.executables << 'flok'
|
26
27
|
end
|
data/lib/flok.rb
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
require "flok/version"
|
2
2
|
|
3
3
|
module Flok
|
4
|
-
|
4
|
+
module MergeSource
|
5
|
+
#Merge all the kernel javascript files into one string
|
6
|
+
def self.merge_kernel
|
7
|
+
Dir.chdir(File.dirname(__FILE__)) do
|
8
|
+
Dir.chdir("./js/kernel/") do
|
9
|
+
js_files = Dir["*.js"]
|
10
|
+
out = ""
|
11
|
+
js_files.each do |js|
|
12
|
+
out << File.read(js)
|
13
|
+
out << "\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
return out
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
5
21
|
end
|
data/lib/flok/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Kernel = {}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
//Forward all custom events to all tasks
|
2
|
-
|
3
|
-
var len =
|
2
|
+
Kernel.handleCustomEvent = function(type, event) {
|
3
|
+
var len = Kernel.tasks.length;
|
4
4
|
for (var i = 0; i < len; ++i) {
|
5
|
-
var task =
|
5
|
+
var task = Kernel.tasks[i]
|
6
6
|
task.handle(type, event)
|
7
7
|
}
|
8
8
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
Kernel.hasInit = false
|
2
|
+
Kernel.handleInitEvent = function(event) {
|
3
|
+
Kernel.hasInit = true
|
4
4
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
Kernel.handleTickEvent = function(event){
|
2
2
|
}
|
data/lib/js/kernel/pipe.js
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
|
1
|
+
Kernel.process = function(event) {
|
2
2
|
var type = event.type;
|
3
3
|
//All events need a type
|
4
|
-
if (type === undefined) { throw "
|
4
|
+
if (type === undefined) { throw "Kernel got an event that had no type!"; }
|
5
5
|
|
6
|
-
if (
|
6
|
+
if (Kernel.hasInit === false) {
|
7
7
|
if (type === "init") {
|
8
|
-
|
8
|
+
Kernel.handleInitEvent(event);
|
9
9
|
} else {
|
10
|
-
throw "
|
10
|
+
throw "Kernel got a first event that was not an init, it was " + type
|
11
11
|
}
|
12
12
|
} else {
|
13
13
|
//Is this a special event?
|
14
14
|
if (type === "tick") {
|
15
|
-
|
15
|
+
Kernel.handleTickEvent(event);
|
16
16
|
} else {
|
17
|
-
|
17
|
+
Kernel.handleCustomEvent(type, event);
|
18
18
|
}
|
19
19
|
}
|
20
20
|
|
21
21
|
//Return outbound event queue
|
22
|
-
var queue =
|
23
|
-
|
22
|
+
var queue = Kernel.outboundEventQueue;
|
23
|
+
Kernel.outboundEventQueue = [];
|
24
24
|
return queue;
|
25
25
|
}
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
Kernel.outboundEventQueue = [];
|
28
|
+
Kernel.sendEvent = function(event) {
|
29
|
+
Kernel.outboundEventQueue.push(event);
|
30
30
|
}
|
data/lib/js/kernel/task.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
//Global task list
|
2
|
-
|
2
|
+
Kernel.tasks = [];
|
3
3
|
|
4
|
-
|
4
|
+
Kernel.Task = function(name) {
|
5
5
|
this.name = name;
|
6
|
-
|
6
|
+
Kernel.tasks.push(this);
|
7
7
|
|
8
8
|
this.sendEvent = function(type, info) {
|
9
9
|
info.type = type;
|
10
|
-
|
10
|
+
Kernel.sendEvent(info);
|
11
11
|
}
|
12
12
|
|
13
13
|
var handlers = [];
|
data/spec/cli_spec.rb
CHANGED
@@ -2,8 +2,34 @@ require './lib/flok.rb'
|
|
2
2
|
require 'tempfile'
|
3
3
|
require 'securerandom'
|
4
4
|
|
5
|
+
def ensure_tmp
|
6
|
+
tmp_spec_path = './spec/tmp'
|
7
|
+
Dir.mkdir(tmp_spec_path) unless File.exists?(tmp_spec_path)
|
8
|
+
end
|
9
|
+
|
5
10
|
RSpec.describe "CLI" do
|
6
|
-
it "Creates a new module folder" do
|
11
|
+
it "Creates a new module folder with absolute path" do
|
12
|
+
#Get a temporary file, delete it, but save the path
|
13
|
+
temp = Tempfile.new "flok-temp"
|
14
|
+
path = temp.path
|
15
|
+
temp.close
|
16
|
+
temp.unlink
|
17
|
+
|
18
|
+
`ruby -Ilib ./bin/flok new #{path}`
|
19
|
+
|
20
|
+
expect(Dir.exists? path).to be(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "Creates a new module folder with relative path" do
|
24
|
+
ensure_tmp
|
25
|
+
fn = SecureRandom.hex
|
26
|
+
|
27
|
+
dir = "./spec/tmp/#{fn}"
|
28
|
+
`ruby -Ilib ./bin/flok new #{dir}`
|
29
|
+
expect(File.exists?(dir)).to be(true)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "Creates a new module folder with correct root folders" do
|
7
33
|
#Get a temporary file, delete it, but save the path
|
8
34
|
temp = Tempfile.new "flok-temp"
|
9
35
|
path = temp.path
|
@@ -12,6 +38,112 @@ RSpec.describe "CLI" do
|
|
12
38
|
|
13
39
|
`ruby -Ilib ./bin/flok new #{path}`
|
14
40
|
|
15
|
-
|
41
|
+
folders = %w{app lib config}
|
42
|
+
|
43
|
+
folders.each do |f|
|
44
|
+
p = "#{path}/#{f}"
|
45
|
+
expect(Dir.exists? p).to be(true)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "The new module has all the files and folders of a RubyGem" do
|
50
|
+
#Get a temporary file, delete it, but save the path
|
51
|
+
temp = Tempfile.new "flok-temp"
|
52
|
+
path = temp.path
|
53
|
+
temp.close
|
54
|
+
temp.unlink
|
55
|
+
Dir.mkdir(path)
|
56
|
+
test_gem_path = "#{path}/test_gem"
|
57
|
+
Dir.mkdir(test_gem_path)
|
58
|
+
file_paths = []
|
59
|
+
dir_paths = []
|
60
|
+
name = "#{SecureRandom.hex[0..4]}_module_name"
|
61
|
+
Dir.chdir(test_gem_path) do
|
62
|
+
`bundle gem #{name}`
|
63
|
+
|
64
|
+
Dir.chdir "./#{name}" do
|
65
|
+
Dir["**/*"].each do |f|
|
66
|
+
if File.file?(f)
|
67
|
+
file_paths << f
|
68
|
+
end
|
69
|
+
|
70
|
+
if File.directory?(f)
|
71
|
+
dir_paths << f
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
file_paths.uniq!
|
77
|
+
dir_paths.uniq!
|
78
|
+
end
|
79
|
+
|
80
|
+
`ruby -Ilib ./bin/flok new #{path}/#{name}`
|
81
|
+
Dir.chdir "#{path}/#{name}" do
|
82
|
+
Dir["**/*"].each do |f|
|
83
|
+
if File.file?(f)
|
84
|
+
file_paths = file_paths - [f]
|
85
|
+
end
|
86
|
+
|
87
|
+
if File.directory?(f)
|
88
|
+
dir_paths = dir_paths - [f]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
if file_paths.count+dir_paths.count != 0
|
93
|
+
puts "------------------------------------------------------------------------------"
|
94
|
+
puts "Files not found matching Gemfile: #{file_paths.inspect}" if file_paths.count > 0
|
95
|
+
puts "Directories not found matching Gemfile: #{dir_paths.inspect}" if dir_paths.count > 0
|
96
|
+
puts "------------------------------------------------------------------------------"
|
97
|
+
end
|
98
|
+
|
99
|
+
expect(file_paths.count+dir_paths.count).to be(0)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it "does create a public/application.js when 'build' is run" do
|
104
|
+
#Get a temporary file, delete it, but save the path
|
105
|
+
temp = Tempfile.new "flok-temp"
|
106
|
+
path = temp.path
|
107
|
+
temp.close
|
108
|
+
temp.unlink
|
109
|
+
|
110
|
+
`ruby -Ilib ./bin/flok new #{path}`
|
111
|
+
gem_root_path = File.expand_path(File.dirname(__FILE__))+"/.."
|
112
|
+
Dir.chdir path do
|
113
|
+
`ruby -I#{gem_root_path}/lib #{gem_root_path}/bin/flok build`
|
114
|
+
expect(File.exist?("./public/application.js")).to be(true)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it "does create a public/application.js when 'build' is run that's not empty" do
|
119
|
+
#Get a temporary file, delete it, but save the path
|
120
|
+
temp = Tempfile.new "flok-temp"
|
121
|
+
path = temp.path
|
122
|
+
temp.close
|
123
|
+
temp.unlink
|
124
|
+
|
125
|
+
`ruby -Ilib ./bin/flok new #{path}`
|
126
|
+
gem_root_path = File.expand_path(File.dirname(__FILE__))+"/.."
|
127
|
+
Dir.chdir path do
|
128
|
+
`ruby -I#{gem_root_path}/lib #{gem_root_path}/bin/flok build`
|
129
|
+
expect(File.read("./public/application.js").length).to be > 0
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "creates an application.js that is executable by js" do
|
134
|
+
#Get a temporary file, delete it, but save the path
|
135
|
+
temp = Tempfile.new "flok-temp"
|
136
|
+
path = temp.path
|
137
|
+
temp.close
|
138
|
+
temp.unlink
|
139
|
+
|
140
|
+
`ruby -Ilib ./bin/flok new #{path}`
|
141
|
+
gem_root_path = File.expand_path(File.dirname(__FILE__))+"/.."
|
142
|
+
Dir.chdir path do
|
143
|
+
`ruby -I#{gem_root_path}/lib #{gem_root_path}/bin/flok build`
|
144
|
+
str = File.read("./public/application.js")
|
145
|
+
ExecJS.compile(str)
|
146
|
+
#it does not throw an error
|
147
|
+
end
|
16
148
|
end
|
17
149
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require './lib/flok.rb'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'securerandom'
|
4
|
+
require 'execjs'
|
5
|
+
|
6
|
+
def ensure_tmp
|
7
|
+
tmp_spec_path = './spec/tmp'
|
8
|
+
Dir.mkdir(tmp_spec_path) unless File.exists?(tmp_spec_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.describe "Flok::MergeSourceSpec" do
|
12
|
+
it "when merging the kernel, it returns a string" do
|
13
|
+
str = Flok::MergeSource.merge_kernel
|
14
|
+
expect(str.class).to be(String)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "when merging the kernel, it returns a string with length" do
|
18
|
+
str = Flok::MergeSource.merge_kernel
|
19
|
+
expect(str.length).to be > 0
|
20
|
+
end
|
21
|
+
|
22
|
+
it "when merging the kernel, the kernel files located in ./lib/js/kernel/ do merge and run without js syntax errors" do
|
23
|
+
str = Flok::MergeSource.merge_kernel
|
24
|
+
ExecJS.compile(str)
|
25
|
+
#It does not throw an error
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seo
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: execjs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.4.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.4.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: thor
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,7 +85,6 @@ description: Flok is a cross-platform application framework system that exports
|
|
71
85
|
email:
|
72
86
|
- seotownsend@icloud.com
|
73
87
|
executables:
|
74
|
-
- banner.png
|
75
88
|
- flok
|
76
89
|
extensions: []
|
77
90
|
extra_rdoc_files: []
|
@@ -82,11 +95,11 @@ files:
|
|
82
95
|
- LICENSE
|
83
96
|
- README.md
|
84
97
|
- Rakefile
|
85
|
-
- bin/banner.png
|
86
98
|
- bin/flok
|
87
99
|
- flok.gemspec
|
88
100
|
- lib/flok.rb
|
89
101
|
- lib/flok/version.rb
|
102
|
+
- lib/js/kernel/common.js
|
90
103
|
- lib/js/kernel/handleCustomEvent.js
|
91
104
|
- lib/js/kernel/handleInitEvent.js
|
92
105
|
- lib/js/kernel/handleTickEvent.js
|
@@ -94,6 +107,7 @@ files:
|
|
94
107
|
- lib/js/kernel/task.js
|
95
108
|
- logo.png
|
96
109
|
- spec/cli_spec.rb
|
110
|
+
- spec/merge_source_spec.rb
|
97
111
|
homepage: https://github.com/sotownsend/flok
|
98
112
|
licenses:
|
99
113
|
- MIT
|
@@ -120,4 +134,5 @@ specification_version: 4
|
|
120
134
|
summary: A boring javascript application framework
|
121
135
|
test_files:
|
122
136
|
- spec/cli_spec.rb
|
137
|
+
- spec/merge_source_spec.rb
|
123
138
|
has_rdoc:
|
data/bin/banner.png
DELETED
Binary file
|