gameplan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +16 -0
  4. data/README.md +3 -0
  5. data/Rakefile +3 -0
  6. data/bin/gameplan +7 -0
  7. data/gameplan.gemspec +22 -0
  8. data/lib/gameplan/application.rb +55 -0
  9. data/lib/gameplan/common_state.rb +41 -0
  10. data/lib/gameplan/describe.rb +11 -0
  11. data/lib/gameplan/endpoint.rb +9 -0
  12. data/lib/gameplan/flow.rb +39 -0
  13. data/lib/gameplan/frontend/public/css/application.css +6 -0
  14. data/lib/gameplan/frontend/public/css/bootstrap-responsive.css +808 -0
  15. data/lib/gameplan/frontend/public/css/bootstrap-responsive.min.css +9 -0
  16. data/lib/gameplan/frontend/public/css/bootstrap.css +4960 -0
  17. data/lib/gameplan/frontend/public/css/bootstrap.min.css +9 -0
  18. data/lib/gameplan/frontend/public/img/glyphicons-halflings-white.png +0 -0
  19. data/lib/gameplan/frontend/public/img/glyphicons-halflings.png +0 -0
  20. data/lib/gameplan/frontend/public/js/bootstrap.js +1824 -0
  21. data/lib/gameplan/frontend/public/js/bootstrap.min.js +6 -0
  22. data/lib/gameplan/frontend/views/app.erb +6 -0
  23. data/lib/gameplan/frontend/views/home.erb +6 -0
  24. data/lib/gameplan/frontend/views/layout/application.erb +76 -0
  25. data/lib/gameplan/frontend/views/state.erb +8 -0
  26. data/lib/gameplan/fuck_ruby.rb +25 -0
  27. data/lib/gameplan/pending_state.rb +20 -0
  28. data/lib/gameplan/site_generator.rb +44 -0
  29. data/lib/gameplan/state.rb +50 -0
  30. data/lib/gameplan/transitions.rb +20 -0
  31. data/lib/gameplan/user.rb +9 -0
  32. data/lib/gameplan/validation.rb +28 -0
  33. data/lib/gameplan/version.rb +3 -0
  34. data/lib/gameplan.rb +140 -0
  35. metadata +92 -0
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ site
2
+ *.rb
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gameplan (0.0.1)
5
+ rainbow
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ rainbow (1.1.3)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ gameplan!
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Gameplan
2
+
3
+ Create a state machine for your application for planning purposes
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
data/bin/gameplan ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gameplan'
4
+
5
+ GameplanInstance.load(Dir.pwd)
6
+ GameplanInstance.validate_and_report
7
+ GameplanInstance.generate
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,11 @@
1
+ class Gameplan
2
+ module Describe
3
+ def desc(desc)
4
+ @desc = desc
5
+ end
6
+
7
+ def description
8
+ @desc
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class Gameplan
2
+ class Endpoint
3
+ attr_reader :state, :description
4
+
5
+ def initialize(app, state, description)
6
+ @app, @state, @description = app, state, description
7
+ end
8
+ end
9
+ 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
@@ -0,0 +1,6 @@
1
+ .card {
2
+ width: 400px;
3
+ height: 600px;
4
+ padding: 10px;
5
+ border: 1px black solid;
6
+ }