gk-application 0.0.2 → 0.0.4
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.
- data/README.md +14 -12
- data/lib/gk-application.rb +18 -18
- data/my_app.rb +8 -8
- metadata +3 -3
data/README.md
CHANGED
@@ -23,18 +23,20 @@ Get started with a new project
|
|
23
23
|
Need a project template? No problem:
|
24
24
|
|
25
25
|
```bash
|
26
|
-
ruby -e 'require "gk-application"' -e 'GK::Application.new.project'
|
26
|
+
ruby -e 'require "rubygems"; require "gk-application"' -e 'GK::Application.new.project'
|
27
27
|
```
|
28
28
|
|
29
29
|
Or using ```irb```:
|
30
30
|
|
31
31
|
```
|
32
32
|
$ irb
|
33
|
-
irb(main):001:0> require '
|
33
|
+
irb(main):001:0> require 'rubygems'
|
34
34
|
=> true
|
35
|
-
irb(main):002:0>
|
35
|
+
irb(main):002:0> require 'gk-application'
|
36
|
+
=> true
|
37
|
+
irb(main):003:0> GK::Application.new.project
|
36
38
|
=> nil
|
37
|
-
irb(main):
|
39
|
+
irb(main):004:0> quit
|
38
40
|
```
|
39
41
|
|
40
42
|
And you'll have a brand-new ```my_app.rb``` ready to go in the current folder!
|
@@ -51,24 +53,24 @@ require 'gk-application'
|
|
51
53
|
my_app = GK::Application.new
|
52
54
|
|
53
55
|
|
54
|
-
my_app.on_starting =
|
56
|
+
my_app.on_starting = proc {
|
55
57
|
puts 'Starting.'
|
56
58
|
my_app.state = :running
|
57
|
-
|
59
|
+
}
|
58
60
|
|
59
|
-
my_app.on_running =
|
61
|
+
my_app.on_running = proc {
|
60
62
|
puts 'Running.'
|
61
63
|
my_app.state = :stopping
|
62
|
-
|
64
|
+
}
|
63
65
|
|
64
|
-
my_app.on_stopping =
|
66
|
+
my_app.on_stopping = proc {
|
65
67
|
puts 'Stopping.'
|
66
68
|
my_app.state = :stopped
|
67
|
-
|
69
|
+
}
|
68
70
|
|
69
|
-
my_app.on_stopped =
|
71
|
+
my_app.on_stopped = proc {
|
70
72
|
puts 'Stopped.'
|
71
|
-
|
73
|
+
}
|
72
74
|
|
73
75
|
|
74
76
|
my_app.state = :starting
|
data/lib/gk-application.rb
CHANGED
@@ -42,16 +42,16 @@ class Application
|
|
42
42
|
end
|
43
43
|
def state=(new_state)
|
44
44
|
case new_state
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
45
|
+
when :starting
|
46
|
+
@on_starting.call
|
47
|
+
when :running
|
48
|
+
@on_running.call
|
49
|
+
when :stopping
|
50
|
+
@on_stopping.call
|
51
|
+
when :stopped
|
52
|
+
@on_stopped.call
|
53
|
+
else
|
54
|
+
raise MSG_INVALID_STATE
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -64,16 +64,16 @@ class Application
|
|
64
64
|
# This is run once every time an Application instance is created
|
65
65
|
def initialize
|
66
66
|
# Initialize event handlers
|
67
|
-
@on_starting =
|
67
|
+
@on_starting = proc {
|
68
68
|
state = :running
|
69
|
-
|
70
|
-
@on_running =
|
69
|
+
}
|
70
|
+
@on_running = proc {
|
71
71
|
state = :stopping
|
72
|
-
|
73
|
-
@on_stopping =
|
72
|
+
}
|
73
|
+
@on_stopping = proc {
|
74
74
|
state = :stopped
|
75
|
-
|
76
|
-
@on_stopped =
|
75
|
+
}
|
76
|
+
@on_stopped = proc { }
|
77
77
|
# Always create the Application instance in the stopped state
|
78
78
|
state = :stopped
|
79
79
|
end
|
@@ -81,7 +81,7 @@ class Application
|
|
81
81
|
# This creates a new GK::Application project.
|
82
82
|
# The new application will be called "my_app.rb" and be placed in the
|
83
83
|
# current directory unless otherwise specified.
|
84
|
-
def project(name
|
84
|
+
def project(name: TEMPLATE_PROJECT)
|
85
85
|
# Get the path for the gk-application gem
|
86
86
|
spec = Gem::Specification.find_by_name(GEM_NAME)
|
87
87
|
gem_root = spec.gem_dir
|
data/my_app.rb
CHANGED
@@ -6,24 +6,24 @@ require 'gk-application'
|
|
6
6
|
my_app = GK::Application.new
|
7
7
|
|
8
8
|
|
9
|
-
my_app.on_starting =
|
9
|
+
my_app.on_starting = proc {
|
10
10
|
puts 'Starting.'
|
11
11
|
my_app.state = :running
|
12
|
-
|
12
|
+
}
|
13
13
|
|
14
|
-
my_app.on_running =
|
14
|
+
my_app.on_running = proc {
|
15
15
|
puts 'Running.'
|
16
16
|
my_app.state = :stopping
|
17
|
-
|
17
|
+
}
|
18
18
|
|
19
|
-
my_app.on_stopping =
|
19
|
+
my_app.on_stopping = proc {
|
20
20
|
puts 'Stopping.'
|
21
21
|
my_app.state = :stopped
|
22
|
-
|
22
|
+
}
|
23
23
|
|
24
|
-
my_app.on_stopped =
|
24
|
+
my_app.on_stopped = proc {
|
25
25
|
puts 'Stopped.'
|
26
|
-
|
26
|
+
}
|
27
27
|
|
28
28
|
|
29
29
|
my_app.state = :starting
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gk-application
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Greg M. Krsak
|
@@ -40,13 +40,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 2.0.0
|
44
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
45
|
none: false
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 2.0.0
|
50
50
|
requirements: []
|
51
51
|
|
52
52
|
rubyforge_project:
|