scriptorium 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: fc85d4908abe528a86e9d7debab72ffe6db188bc14da0fe8a6a03ac4fa71e739
4
- data.tar.gz: d83737681bac36cb0c48e378a401b137b6c9ecbbc4add3c2a9649cdd1ee856d4
3
+ metadata.gz: bd8976bc35d478aa3db8436bb05812014abcc09f4b9a36ee20b14b2190468d98
4
+ data.tar.gz: 6745ebaf60ccb3f5bfdf60b80b8931725218d27a03a66f852d133cd5a5573ea1
5
5
  SHA512:
6
- metadata.gz: f66116f56620ea07e30fccb245f4d6134f256ed3c2b103b18bc00c8babc724a2a6e05bbf347a840fef751faf2778dfe233cf68371f59b9c33ded40c98fd28159
7
- data.tar.gz: 04ce8568e5df65eb61439544333ea0c15b751b529dd19ea3bec4fd19e730e8ab75ed4c3cc26f0cbed09e3c4d628d678a271d0d197a2ad0566206f104ff5bfed4
6
+ metadata.gz: 061bf84937fe3de2727328300d0308bc14de9fdab705e4fed1c81b5a06c6622d16d55cd3c9399230d4af1d09c3ee1e2ff8fe69020add4a660b17d818c6594863
7
+ data.tar.gz: 4e923d45513ab03f8c438f9673a3bf37646e381eb1d45a144f28deec95f29a37a71481b1e9213316c8796d9bd3bc60bff2e974f9774cce9b404b8894783ab242
@@ -0,0 +1,22 @@
1
+ module Scriptorium::Engine
2
+
3
+ include Scriptorium::Exceptions
4
+
5
+ def repo_exists?
6
+ Dir.exist?(@dir)
7
+ end
8
+
9
+ def create_new_repo
10
+ Dir.mkdir(@dir)
11
+ Dir.chdir(@dir) do
12
+ subs = %w[config views]
13
+ subs.each {|sub| Dir.mkdir(sub) }
14
+ end
15
+ end
16
+
17
+ def destroy_repo
18
+ raise TestModeOnly unless Scriptorium.testing
19
+ system("rm -rf #@dir")
20
+ end
21
+
22
+ end
@@ -0,0 +1,5 @@
1
+ module Scriptorium::Exceptions
2
+
3
+ class TestModeOnly < Exception; end
4
+
5
+ end
@@ -1,5 +1,5 @@
1
1
  class Scriptorium
2
2
 
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
 
5
5
  end
data/lib/scriptorium.rb CHANGED
@@ -1,10 +1,42 @@
1
1
  require_relative "skeleton"
2
2
 
3
+ require_relative "scriptorium/engine"
4
+ require_relative "scriptorium/exceptions"
5
+
6
+ require 'singleton'
7
+
8
+ ###
9
+
3
10
  class Scriptorium
4
11
 
12
+ include Singleton
13
+
14
+ include Exceptions
15
+ include Engine
16
+
17
+ # Class instance vars...
18
+ @testing = $testing # good/bad idea?
19
+ @blog = nil
20
+
21
+ class << self
22
+ attr_accessor :testing
23
+ alias blog instance
24
+ end
25
+
26
+ # Instance attrs/methods
27
+
28
+ attr_reader :name, :dir
29
+
5
30
  def initialize
6
- puts "Initializing... no code yet."
7
- puts
31
+ @testing = self.class.testing
32
+ @home = ENV['HOME']
33
+ if @testing
34
+ @name = "TEST-ONLY BLOG REPO"
35
+ @dir = "#@home/test-scriptorium"
36
+ else
37
+ @name = "Scriptorium repository"
38
+ @dir = "#@home/Scriptorium"
39
+ end
8
40
  end
9
41
 
10
42
  end
data/lib/skeleton.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  class Scriptorium
2
2
 
3
- class Engine
3
+ module Exceptions
4
+ end
5
+
6
+ module Engine
4
7
  end
5
8
 
6
9
  class UI
@@ -0,0 +1,44 @@
1
+ require 'minitest/autorun'
2
+
3
+ require_relative '../../lib/scriptorium'
4
+
5
+ class TestScriptoriumEngine < MiniTest::Test
6
+
7
+ TestModeOnly = Scriptorium::TestModeOnly
8
+
9
+ def setup
10
+ @blog = Scriptorium.blog
11
+ Scriptorium.testing = true
12
+ end
13
+
14
+ def teardown
15
+ Scriptorium.testing = true
16
+ end
17
+
18
+ def test_singleton
19
+ refute_nil @blog, "blog accessor was nil"
20
+ assert_raises(NoMethodError) { y = Scriptorium.new }
21
+ end
22
+
23
+ def test_repo_create_destroy
24
+ t0 = @blog.repo_exists?
25
+ refute t0, "Repo should not exist yet"
26
+
27
+ @blog.create_new_repo
28
+
29
+ t1 = @blog.repo_exists?
30
+ assert t1, "Repo should exist"
31
+
32
+ @blog.destroy_repo
33
+
34
+ t2 = @blog.repo_exists?
35
+ refute t2, "Repo should have been destroyed"
36
+ end
37
+
38
+ def test_illegal_destroy
39
+ Scriptorium.testing = false
40
+ assert_raises(TestModeOnly) { @blog.destroy_repo }
41
+ # @blog.destroy_repo
42
+ end
43
+
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scriptorium
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
  - Hal Fulton
@@ -102,8 +102,11 @@ files:
102
102
  - "./scriptorium.gemspec"
103
103
  - bin/sblog
104
104
  - lib/scriptorium.rb
105
+ - lib/scriptorium/engine.rb
106
+ - lib/scriptorium/exceptions.rb
105
107
  - lib/scriptorium/version.rb
106
108
  - lib/skeleton.rb
109
+ - test/engine/unit.rb
107
110
  homepage: https://github.com/Hal9000/scriptorium
108
111
  licenses:
109
112
  - Ruby