ll 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4bbc223368fe6160c36c0f42b7a9c4461b20d0fa199e78754e7a758bffd8ff0
4
- data.tar.gz: cd9866c24fa6313c8ae157b2847f4dc6ff33e3b3f1d94fb61144c58a3d89f3dc
3
+ metadata.gz: 7a9c96ac0bda2425338cd0312cc63c2f731332853ad6d9f5e8043e281fedafd0
4
+ data.tar.gz: af61f5a74e8939b56479c24e6cb2f126e02c0615a67831941d80462a16cfe4ac
5
5
  SHA512:
6
- metadata.gz: ff4d5f0a92c934538f4a0ef3350a949f7710686a19d4da29bf4e95b742724a6ed64d37640e42a1d6cef265c5103cd9fa3886296beb95acb1629a6e5cb1cb59c5
7
- data.tar.gz: cff18272cae814ef99f32201de3a538686d59e2fea84461184f922b49030274fe7bbedf1287310e644c3f79af9df4c6fffdde215fb620f54d038c3e33ac44003
6
+ metadata.gz: '0030849c4e589aebd29b086d1a39b03c0258e0bbebaed789f96222a3b6314ca7f51f0591452b552c9640e278c021ed7ad871e5bff011052f6889c7c540d32e1d'
7
+ data.tar.gz: 1006dab7dee8774be6d1cd1ff93585d7b1483d0dc9ae81f3012bc3ee1cfdc6db261a650b453bae1dba23cb0e8358cb4aac01157b8c676eee565a2fed30ecc72a
data/lib/ll.rb CHANGED
@@ -1,3 +1,4 @@
1
- require 'vv'
1
+ require "pry"
2
+ require "vv"
2
3
 
3
4
  Gem.require_files "ll/*.rb"
@@ -2,12 +2,33 @@ class LL::Checklist
2
2
 
3
3
  attr_reader :name
4
4
 
5
- def initialize
6
- @name = "Prototypical"
5
+ def self.load( dir: )
6
+ filepaths = Dir.glob(File.join dir, "checklists/*")
7
+ filepaths.each do | filepath |
8
+ self.new File.read filepath
9
+ end
10
+ end
11
+
12
+ def initialize json_document=nil, name: nil
13
+ # TODO: Parse the document
14
+ @name = name
15
+ @name ||= "Prototypical"
16
+ end
17
+
18
+ def parse_document json_document
19
+ raise NotImplementedError
7
20
  end
8
21
 
9
22
  def to_s
10
23
  "Checklist: #{self.name}"
11
24
  end
12
25
 
26
+ def to_h
27
+ { name: self.name }
28
+ end
29
+
30
+ def to_json
31
+ JSON.dump self.to_hash
32
+ end
33
+
13
34
  end
@@ -0,0 +1,187 @@
1
+ class LL::ListyList
2
+
3
+ def initialize cli: nil,
4
+ name: nil
5
+
6
+ @checklists = []
7
+ @schemas = []
8
+
9
+ name ||= "listy-list".style :forestgreen, :bold
10
+
11
+ @cli = cli
12
+ @cli ||= VV::CLI.new name: name,
13
+ version: LL::VERSION,
14
+ argv: ARGV
15
+ self.uri = "/"
16
+
17
+ self.first_boot
18
+ end
19
+
20
+ def first_boot
21
+ self.create_directories
22
+
23
+ self.boot! do
24
+ self.show_help! if @cli.help?
25
+ self.show_version! if @cli.version?
26
+ end
27
+ end
28
+
29
+ def boot!
30
+ @_status = :boot
31
+ yield
32
+ self.load
33
+ end
34
+
35
+ def loop
36
+ self.status = :loop unless shutdown?
37
+
38
+ while loop? do
39
+ self.load
40
+ self.lock
41
+ self.display
42
+ self.await_input
43
+ self.react
44
+ self.persist
45
+ self.unlock
46
+ end
47
+
48
+ self.shutdown
49
+ ensure
50
+ self.unlock
51
+ end
52
+
53
+ def react
54
+ end
55
+
56
+ def show_help
57
+ self.uri = "/help"
58
+ @cli.print_help
59
+ end
60
+
61
+ def show_help!
62
+ self.show_help
63
+ self.shutdown!
64
+ end
65
+
66
+ def show_version
67
+ self.uri = "/version"
68
+ @cli.print_version
69
+ end
70
+
71
+ def show_version!
72
+ self.show_version
73
+ self.shutdown!
74
+ end
75
+
76
+ def shutdown
77
+ :shutdown_safely
78
+ end
79
+
80
+ def shutdown?
81
+ self.status == :shutdown
82
+ end
83
+
84
+ def shutdown!
85
+ self.status = :shutdown
86
+ end
87
+
88
+ def load
89
+ self.load_schemas
90
+ self.load_checklists
91
+ end
92
+ alias_method :reload, :load
93
+
94
+ def load_schemas
95
+ @schemas = LL::Schema.load dir: @cli.data_path
96
+ end
97
+
98
+ def load_checklists
99
+ @checklists = LL::Checklist.load dir: @cli.data_path
100
+ end
101
+
102
+ def lock_path
103
+ @cli.data_path.file_join "listy.lock"
104
+ end
105
+
106
+ def lock_contents
107
+ File.read(lock_path).chomp
108
+ end
109
+
110
+ def lock
111
+ File.write(lock_path, Process.pid.to_s) unless File.exists? lock_path
112
+
113
+ return true if lock_contents == Process.pid.to_s
114
+
115
+ fail "Unable to lock #{lock_path}, contains pid mismatch."
116
+ end
117
+
118
+ def unlock
119
+ message = "Unable to unlock #{lock_path}, contains pid mismatch."
120
+ fail message if lock_contents != Process.pid.to_s
121
+
122
+ File.remove lock_path
123
+ end
124
+
125
+ def display
126
+ puts :display
127
+ end
128
+
129
+ def persist
130
+ self.save_uri
131
+ self.save_checklist
132
+ self.save_schema_changes
133
+ self.sync
134
+ end
135
+
136
+ # TOOD: Implement these
137
+ def save_uri
138
+ end
139
+ def save_checklist
140
+ end
141
+ def save_schema_changes
142
+ end
143
+ def sync
144
+ end
145
+
146
+ def loop?
147
+ self.status == :loop
148
+ end
149
+
150
+ def boot?
151
+ self.status == :boot
152
+ end
153
+
154
+ def await_input
155
+ input = @cli.await_input message: "hi"
156
+ input
157
+ end
158
+
159
+ # Log this. Maybe incorporate into VV::CLI?
160
+ def uri= uri
161
+ @_uri = uri
162
+ end
163
+
164
+ def uri
165
+ @_uri
166
+ end
167
+
168
+ def status= status
169
+ message = \
170
+ "Currently shutdown. Call `boot!` to return to resume."
171
+ fail message if self.status == :shutdown
172
+ %i[ loop boot pause shutdown ].includes! status
173
+ @_status = status
174
+ end
175
+
176
+ def status
177
+ @_status
178
+ end
179
+
180
+ def create_directories
181
+ %w[ checklists schemas ].each do | _directory |
182
+ directory = @cli.data_path.file_join _directory
183
+ File.make_directory_if_not_exists directory
184
+ end
185
+ end
186
+
187
+ end
@@ -0,0 +1,6 @@
1
+ class LL::Schema
2
+
3
+ def self.load( dir: )
4
+ end
5
+
6
+ end
@@ -0,0 +1,39 @@
1
+ class LL::Step
2
+
3
+ attr_reader :title,
4
+ :description,
5
+ :action,
6
+ :kind,
7
+ :status,
8
+ :identifier,
9
+ :schema,
10
+ :by,
11
+ :via,
12
+ :action_at,
13
+ :version
14
+
15
+ def initialize json_document
16
+ # TODO: Auto convert dasherized to underscore
17
+ data = json_document.to_h.symbolize_keys
18
+
19
+ @title = data[:title]
20
+ @description = data[:description]
21
+ @action = data[:action]
22
+ @kind = data[:kind]
23
+ @status = data[:status]
24
+ @identifier = data[:identifier]
25
+ @schema = data[:schema]
26
+ @by = data[:by]
27
+ @via = data[:via]
28
+ @os = data[:via]
29
+ @with = data[:via]
30
+ @doc_version = data[:doc_version]
31
+ @action_at = data[:action_at]
32
+ end
33
+
34
+ # This is useful to upgrade formats between versions.
35
+ def reformat
36
+ raise NotImplementedError
37
+ end
38
+
39
+ end
@@ -1,3 +1,3 @@
1
1
  module LL
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,35 @@
1
+ {"title": "Gem Tasks",
2
+ "description": "Finicky gem build details",
3
+ "action": "create",
4
+ "kind": "checklist",
5
+ "identifier": "vux25anby00000000000000000",
6
+ "action_at": "2019-02-21T19:42:06Z",
7
+ "format": "json-v0.0.2",
8
+ "steps": [ { "title": "Bump version",
9
+ "description": null,
10
+ "action": "create",
11
+ "kind": "simple",
12
+ "status": "blank",
13
+ "identifier": "vux25anby10000000000000000",
14
+ "by": "zachaysan@gmail.com",
15
+ "via": "zach@vux",
16
+ "action_at": "2019-02-21T19:41:06Z"},
17
+ { "title": "Tweet about upcoming release",
18
+ "description": null,
19
+ "action": "create",
20
+ "kind": "quantity",
21
+ "status": "0 of 5",
22
+ "identifier": "vux25anby20000000000000000",
23
+ "by": "zachaysan@gmail.com",
24
+ "via": "zach@vux",
25
+ "action_at": "2019-02-21T19:41:06Z"},
26
+ { "action": "create",
27
+ "kind": "embeded",
28
+ "status": "blank",
29
+ "title": null,
30
+ "description": null,
31
+ "identifier": "vux25anby30000000000000000",
32
+ "schema": "vuxazbhlfheq30000000000000",
33
+ "by": "zachaysan@gmail.com",
34
+ "via": "zach@vux",
35
+ "action_at": "2019-02-21T19:42:06Z" } ] }
@@ -0,0 +1,7 @@
1
+ require "minitest/autorun"
2
+ require "ll"
3
+
4
+ begin
5
+ require "pry"
6
+ rescue LoadError
7
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "test_helper.rb"
2
+
3
+ class ListyListTest < Minitest::Test
4
+
5
+ def test_new
6
+ listy_list = LL::ListyList.new
7
+ assert_equal :boot, listy_list.status
8
+ end
9
+
10
+ end
@@ -1,5 +1,4 @@
1
- require "minitest/autorun"
2
- require "ll"
1
+ require_relative "test_helper.rb"
3
2
 
4
3
  class LLTest < Minitest::Test
5
4
 
@@ -0,0 +1,25 @@
1
+ require_relative "test_helper.rb"
2
+
3
+ class StepTest < Minitest::Test
4
+
5
+ def test_new_step
6
+ step_input = \
7
+ { "title": "Bump version",
8
+ "description": nil,
9
+ "action": "create",
10
+ "kind": "simple",
11
+ "status": "boot",
12
+ "identifier": "vux25anby10000000000000000",
13
+ "by": "zachaysan@gmail.com",
14
+ "via": "zach@vux",
15
+ "os": "Ubuntu 18.04.2 LTS",
16
+ "with": "ll-v0.0.2",
17
+ "doc_version": "0.0.2",
18
+ "action_at": "2019-02-21T19:41:06Z"}.to_json
19
+
20
+ step = LL::Step.new step_input
21
+ expected_status = "boot"
22
+ assert_equal expected_status, step.status
23
+ end
24
+
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Aysan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2019-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vv
@@ -77,9 +77,16 @@ files:
77
77
  - README.markdown
78
78
  - lib/ll.rb
79
79
  - lib/ll/checklist.rb
80
+ - lib/ll/listy_list.rb
81
+ - lib/ll/schema.rb
82
+ - lib/ll/step.rb
80
83
  - lib/ll/version.rb
84
+ - test/fixtures/checklists/v0.0.2.json
81
85
  - test/test_checklist.rb
86
+ - test/test_helper.rb
87
+ - test/test_listy_list.rb
82
88
  - test/test_ll.rb
89
+ - test/test_step.rb
83
90
  homepage: https://github.com/zachaysan/ll
84
91
  licenses:
85
92
  - MIT
@@ -105,5 +112,9 @@ signing_key:
105
112
  specification_version: 4
106
113
  summary: Listy List
107
114
  test_files:
115
+ - test/fixtures/checklists/v0.0.2.json
108
116
  - test/test_checklist.rb
117
+ - test/test_helper.rb
118
+ - test/test_listy_list.rb
109
119
  - test/test_ll.rb
120
+ - test/test_step.rb