dream 0.1.3 → 1.0.0

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
  SHA1:
3
- metadata.gz: 1d2c0c68104db151d56cc1f380ec0d55db1feb7a
4
- data.tar.gz: be198da7eaf0ca3c978c665715e25e396fd31552
3
+ metadata.gz: dfa0ba319255f29268ca5be5afe7431ef733f1ab
4
+ data.tar.gz: 41cf82c8102c8690ccdc1d70ee9a6d33706a2984
5
5
  SHA512:
6
- metadata.gz: cd292aef55f2de5b80d6480f2781896fd01310a68920d4b54dd1c4fc6732983fdff730d1a33840fba5f5c5c581a905da464110aaa72875640cb726a9dbf4c2a4
7
- data.tar.gz: 88d28ab111c8bfa3fdc7d18d3c1d9663d21e5fcb1465a8f3ea0a53f97e4e3f6573f93c33e2161b493e281d8890fa29716d73b50081c44a16935804d307b85f03
6
+ metadata.gz: 46da1b199b883d3ced141e8d7e7684ee0bf04ca121af191f45e973167de7d2972277b5a530665d54ce757ba4784028c570ffa4dab9a6dcda41fb1e6d9e129c5b
7
+ data.tar.gz: 1e5d1144455b120c9a1eff73cf5c3c14d659f45383969dd57a744843955789a7a2bf1f8e7124eb0e18d3b88261b3d8825c24da3ca13ff6bcbdf7906cb73c9c18
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/dream.gemspec CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "thor", "~> 0.19"
23
+
23
24
  spec.add_development_dependency "bundler", "~> 1.10"
24
25
  spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.9"
25
27
  end
data/lib/dream/cli.rb CHANGED
@@ -2,55 +2,55 @@ require 'thor'
2
2
  require 'yaml'
3
3
 
4
4
  module Dream
5
- class Mind < Thor
6
- include Thor::Actions
7
- desc "sleep", "Install Dream"
8
- option :install
9
- option :name
10
- def sleep()
11
- install('dream.yml')
5
+ class Mind < Thor
6
+ include Thor::Actions
7
+ desc "sleep", "Install Dream"
8
+ option :install
9
+ option :name
10
+ def sleep()
11
+ install('dream.yml')
12
+ end
13
+ private
14
+ def install(template_file)
15
+ install_path = options[:install] ? options[:install] : '.'
16
+ filename = options[:name] ? options[:name] : template_file
17
+ template = File.read(File.join(File.dirname(__FILE__),'templates',template_file))
18
+ success = false
19
+ msg = ''
20
+ file = File.join(install_path, filename)
21
+ if File.exists?(file)
22
+ warn "[skip] `#{filename}' already exists"
23
+ if yes?("Would you like to overwrite the existing file?")
24
+ msg = "#{filename} has been overwritten"
25
+ success=true
26
+ end
27
+ elsif File.exists?(file.downcase)
28
+ warn "[skip] `#{filename.downcase}' exists, which could conflict with `#{filename}'"
29
+ if yes?("Would you like to overwrite the existing file?")
30
+ msg = "#{filename} has been overwritten"
31
+ success=true
32
+ end
33
+ elsif !File.exists?(File.dirname(file))
34
+ warn "[skip] directory `#{File.dirname(file)}' does not exist"
35
+ if yes?("Would you like to make the directory?")
36
+ FileUtils.mkdir_p(install_path)
37
+ msg = "The directory #{install_path} was created"
38
+ success=true
39
+ end
40
+ else
41
+ msg = "There were no issues with the installation"
42
+ success=true
12
43
  end
13
- private
14
- def install(template_file)
15
- install_path = options[:install] ? options[:install] : '.'
16
- filename = options[:name] ? options[:name] : template_file
17
- template = File.read(File.join(File.dirname(__FILE__),'templates',template_file))
18
- success = false
19
- msg = ''
20
- file = File.join(install_path, filename)
21
- if File.exists?(file)
22
- warn "[skip] `#{filename}' already exists"
23
- if yes?("Would you like to overwrite the existing file?")
24
- msg = "#{filename} has been overwritten"
25
- success=true
26
- end
27
- elsif File.exists?(file.downcase)
28
- warn "[skip] `#{filename.downcase}' exists, which could conflict with `#{filename}'"
29
- if yes?("Would you like to overwrite the existing file?")
30
- msg = "#{filename} has been overwritten"
31
- success=true
32
- end
33
- elsif !File.exists?(File.dirname(file))
34
- warn "[skip] directory `#{File.dirname(file)}' does not exist"
35
- if yes?("Would you like to make the directory?")
36
- FileUtils.mkdir_p(install_path)
37
- msg = "The directory #{install_path} was created"
38
- success=true
39
- end
40
- else
41
- msg = "There were no issues with the installation"
42
- success=true
43
- end
44
44
 
45
- if success
46
- puts "[add] writing `#{filename}'"
47
- File.open(file, "w") { |f| f.write(template) }
48
- puts "#{msg}"
49
- puts "[done] Dream was successfully installed. Sleep well."
50
- else
51
- puts "[error] Dream was not successfully installed."
52
- end
53
- end
54
- end
55
- Mind.start(ARGV)
45
+ if success
46
+ puts "[add] writing `#{filename}'"
47
+ File.open(file, "w") { |f| f.write(template) }
48
+ puts "#{msg}"
49
+ puts "[done] Dream was successfully installed. Sleep well."
50
+ else
51
+ puts "[error] Dream was not successfully installed."
52
+ end
53
+ end
54
+ end
55
+ Mind.start(ARGV)
56
56
  end
@@ -1,7 +1,7 @@
1
1
  records:
2
2
  name: 'record'
3
3
  timestamp: true
4
- extension: 'txt'
4
+ extension: 'json'
5
5
  messages:
6
6
  started: "Started "
7
7
  finished: "Finished"
data/lib/dream/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dream
2
- VERSION = "0.1.3"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/dream.rb CHANGED
@@ -1,72 +1,123 @@
1
1
  require "dream/version"
2
+ require 'json'
2
3
 
3
4
  module Dream
4
5
  class Spectre
5
6
  def initialize(library)
6
7
  @library = library
7
- @book = Array.new
8
8
  @name = record_name()
9
9
  @messages = library['records']['messages']
10
+ @format = library['records']['format']
10
11
  @watches = {}
12
+ @book = Array.new
11
13
  end
12
- def record(status, msg)
14
+
15
+
16
+ def record(status, directory, message)
13
17
  timestamp = Time.now
14
- @book.push("[#{timestamp}]> #{status} | #{msg}")
18
+ path = directory.split("/")
19
+ node = branch(path[0..-2])
20
+ record = {
21
+ "name" => path[-1],
22
+ "timestamp" => timestamp,
23
+ "status" => status,
24
+ "message" => message,
25
+ "children" => []
26
+ }
27
+ node.push(record)
15
28
  end
29
+
16
30
  def record_start()
17
31
  watch(@messages['started'])
18
32
  end
33
+
19
34
  def record_finished()
20
35
  watch(@messages['finished'])
21
36
  end
37
+
22
38
  def watch(name)
23
39
  @watches[:"#{name}"] = timestamp()
24
40
  end
41
+
25
42
  def time_records(name)
26
43
  return @watches[:"#{name}"]
27
44
  end
45
+
28
46
  def started
29
47
  return @messages['started']
30
48
  end
49
+
31
50
  def finished
32
51
  return @messages['finished']
33
52
  end
53
+
34
54
  def success
35
55
  return @messages['success']
36
56
  end
57
+
37
58
  def info
38
59
  return @messages['info']
39
60
  end
61
+
40
62
  def warning
41
63
  return @messages['warning']
42
64
  end
65
+
43
66
  def error
44
67
  return @messages['error']
45
68
  end
69
+
46
70
  def manuscript(clear)
71
+ replica = @book
47
72
  if clear
48
73
  @book = Array.new
49
74
  end
50
- return @book
75
+ return replica
51
76
  end
52
- def author(chapters)
53
- @book = @book + chapters
77
+
78
+ def author(directory, chapters)
79
+ path = directory.split("/")
80
+ node = branch(path[0..-2])
81
+ node.push(chapters)
54
82
  end
83
+
55
84
  def save()
56
85
  File.open(@name, "w+") do |f|
57
- f.puts(@book)
86
+ f.puts(@book.to_json)
58
87
  end
59
88
  end
89
+
60
90
  def clean()
61
91
  FileUtils.rm_rf(@name)
62
92
  end
93
+
63
94
  private
64
- def record_name()
65
- timestamp = @library['records']['timestamp'] ? "-#{Time.now.strftime "%Y%m%d%H%M%S-%L"}" : ""
66
- return "#{@library['records']['name']}#{timestamp}.#{@library['records']['extension']}"
67
- end
68
- def timestamp()
69
- return Time.now.strftime "%Y-%m-%dT%H:%M:%S.%LZ"
95
+
96
+ def is_even?(num)
97
+ return (num % 2).eql?(0)
98
+ end
99
+
100
+ def branch(branches)
101
+ edge = @book
102
+ branches.each do | branch |
103
+ if edge[-1]["name"].eql?(branch)
104
+ edge = edge[-1]["children"]
105
+ else
106
+ break
107
+ end
70
108
  end
109
+ return edge
110
+ end
111
+
112
+ def record_name()
113
+ timestamp = @library['records']['timestamp'] ? "-#{Time.now.strftime "%Y%m%d%H%M%S-%L"}" : ""
114
+ return "#{@library['records']['name']}#{timestamp}.#{@library['records']['extension']}"
115
+ end
116
+
117
+ def timestamp()
118
+ return Time.now.strftime "%Y-%m-%dT%H:%M:%S.%LZ"
119
+ end
120
+
121
+
71
122
  end
72
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Vecchio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-05 00:00:00.000000000 Z
11
+ date: 2016-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.9'
55
69
  description: Ruby logging platform
56
70
  email:
57
71
  - au.vecchio@gmail.com
@@ -61,6 +75,7 @@ extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
77
  - ".gitignore"
78
+ - ".rspec"
64
79
  - ".travis.yml"
65
80
  - CODE_OF_CONDUCT.md
66
81
  - Gemfile
@@ -69,7 +84,6 @@ files:
69
84
  - Rakefile
70
85
  - bin/dream
71
86
  - dream.gemspec
72
- - lib/.ruby-version
73
87
  - lib/dream.rb
74
88
  - lib/dream/cli.rb
75
89
  - lib/dream/templates/dream.yml
@@ -99,4 +113,3 @@ signing_key:
99
113
  specification_version: 4
100
114
  summary: Logging platform
101
115
  test_files: []
102
- has_rdoc:
data/lib/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.4.0-dev