gameplan 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +16 -0
- data/README.md +3 -0
- data/Rakefile +3 -0
- data/bin/gameplan +7 -0
- data/gameplan.gemspec +22 -0
- data/lib/gameplan/application.rb +55 -0
- data/lib/gameplan/common_state.rb +41 -0
- data/lib/gameplan/describe.rb +11 -0
- data/lib/gameplan/endpoint.rb +9 -0
- data/lib/gameplan/flow.rb +39 -0
- data/lib/gameplan/frontend/public/css/application.css +6 -0
- data/lib/gameplan/frontend/public/css/bootstrap-responsive.css +808 -0
- data/lib/gameplan/frontend/public/css/bootstrap-responsive.min.css +9 -0
- data/lib/gameplan/frontend/public/css/bootstrap.css +4960 -0
- data/lib/gameplan/frontend/public/css/bootstrap.min.css +9 -0
- data/lib/gameplan/frontend/public/img/glyphicons-halflings-white.png +0 -0
- data/lib/gameplan/frontend/public/img/glyphicons-halflings.png +0 -0
- data/lib/gameplan/frontend/public/js/bootstrap.js +1824 -0
- data/lib/gameplan/frontend/public/js/bootstrap.min.js +6 -0
- data/lib/gameplan/frontend/views/app.erb +6 -0
- data/lib/gameplan/frontend/views/home.erb +6 -0
- data/lib/gameplan/frontend/views/layout/application.erb +76 -0
- data/lib/gameplan/frontend/views/state.erb +8 -0
- data/lib/gameplan/fuck_ruby.rb +25 -0
- data/lib/gameplan/pending_state.rb +20 -0
- data/lib/gameplan/site_generator.rb +44 -0
- data/lib/gameplan/state.rb +50 -0
- data/lib/gameplan/transitions.rb +20 -0
- data/lib/gameplan/user.rb +9 -0
- data/lib/gameplan/validation.rb +28 -0
- data/lib/gameplan/version.rb +3 -0
- data/lib/gameplan.rb +140 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/gameplan
ADDED
data/gameplan.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "gameplan/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "gameplan"
|
7
|
+
s.version = Gameplan::VERSION
|
8
|
+
s.authors = ["Josh Hull"]
|
9
|
+
s.email = ["joshbuddy@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Gotta plan your game dog}
|
12
|
+
s.description = %q{Gotta plan your game dog.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "gameplan"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency "rainbow"
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Gameplan
|
2
|
+
class Application
|
3
|
+
include Describe
|
4
|
+
|
5
|
+
attr_reader :states, :name, :pretty_name, :plan, :last_state, :common_states
|
6
|
+
|
7
|
+
def initialize(plan, pretty_name, name, &blk)
|
8
|
+
@plan, @pretty_name, @name, @states, @common_states, @blk = plan, pretty_name, name, {}, {}, blk
|
9
|
+
end
|
10
|
+
|
11
|
+
def compile
|
12
|
+
instance_eval(&@blk)
|
13
|
+
end
|
14
|
+
|
15
|
+
def for_user(*capabilities)
|
16
|
+
@capabilities = capabilities
|
17
|
+
end
|
18
|
+
|
19
|
+
def pending_state(name, desc, &blk)
|
20
|
+
raise "#{name} already exists" if @states[name]
|
21
|
+
@last_state = @states[name] = PendingState.new(self, name, desc)
|
22
|
+
@last_state.compile
|
23
|
+
@last_state
|
24
|
+
end
|
25
|
+
|
26
|
+
def state(name, desc, &blk)
|
27
|
+
raise "#{name} already exists" if @states[name]
|
28
|
+
@last_state = @states[name] = State.new(self, name, desc, &blk)
|
29
|
+
@last_state.compile
|
30
|
+
@last_state
|
31
|
+
end
|
32
|
+
|
33
|
+
def common_state(name, desc, &blk)
|
34
|
+
puts "defining common state..."
|
35
|
+
raise "#{name} already exists" if @common_states[name]
|
36
|
+
@last_state = @common_states[name] = CommonState.new(self, name, desc, &blk)
|
37
|
+
puts "compiling..."
|
38
|
+
@last_state.compile
|
39
|
+
@last_state
|
40
|
+
end
|
41
|
+
|
42
|
+
def validate
|
43
|
+
add_error "For application #{name}, there are no states" if @states.empty?
|
44
|
+
@states.values.each { |state| state.validate }
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_error(str)
|
48
|
+
@plan.add_error(str)
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_warning(str)
|
52
|
+
@plan.add_warning(str)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Gameplan
|
2
|
+
class CommonState
|
3
|
+
include Describe
|
4
|
+
|
5
|
+
attr_reader :endpoints
|
6
|
+
|
7
|
+
def initialize(app, name, pretty_name, &blk)
|
8
|
+
@app = app
|
9
|
+
@name = name
|
10
|
+
@pretty_name = pretty_name
|
11
|
+
@endpoints = []
|
12
|
+
@blk = blk
|
13
|
+
end
|
14
|
+
|
15
|
+
def compile
|
16
|
+
instance_eval(&@blk)
|
17
|
+
end
|
18
|
+
|
19
|
+
def endpoint(state, desc)
|
20
|
+
@endpoints << Endpoint.new(@app, state, desc)
|
21
|
+
end
|
22
|
+
|
23
|
+
def traverse(user, target_state, count, transitions)
|
24
|
+
return if count.zero?
|
25
|
+
transitions.emit if @name == target_state
|
26
|
+
@endpoints.each do |endpoint|
|
27
|
+
transitions.add(@name, endpoint.change_name) do
|
28
|
+
@app.states[endpoint.state_name].traverse(user, target_state, count - 1, transitions)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate
|
34
|
+
add_error "State #{@name} has no endpoints" if @endpoints.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_error(str)
|
38
|
+
@app.add_error(str)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Gameplan
|
2
|
+
class Flow
|
3
|
+
def initialize(plan, name, &blk)
|
4
|
+
@plan = plan
|
5
|
+
@name = name
|
6
|
+
instance_eval(&blk) if blk
|
7
|
+
end
|
8
|
+
|
9
|
+
def apps(*apps)
|
10
|
+
@apps = apps
|
11
|
+
end
|
12
|
+
alias_method :app, :apps
|
13
|
+
|
14
|
+
def from(name)
|
15
|
+
@from = name
|
16
|
+
end
|
17
|
+
|
18
|
+
def to(name)
|
19
|
+
@to = name
|
20
|
+
end
|
21
|
+
|
22
|
+
def steps(count)
|
23
|
+
@step_count = count
|
24
|
+
end
|
25
|
+
|
26
|
+
def traverse(app, user)
|
27
|
+
Enumerator.new do |yielder|
|
28
|
+
@plan.apps.each do |app_name, app|
|
29
|
+
initial_state = app.states[@from]
|
30
|
+
initial_state.traverse(user, @to, @step_count, Transitions.new(yielder))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def traversable?(user)
|
36
|
+
!traverse(user).empty?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|