runeblog 0.2.69 → 0.2.70

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: cac83d9c4f6850081ed2e007400c08c0a45e0515384e1eab36deb24ff8f269f1
4
- data.tar.gz: 77164031eeee9f02d96d8b966831c4e04544def4973affad48b3f1f43acd702f
3
+ metadata.gz: e0d49c8d62c0c29650322fcff89f90294b364bd631ab2c678e6fe79a5db478c3
4
+ data.tar.gz: e6c772a8d7cdb0a5032fee2a3ed09179a1eb6acc60278c443e40b96e8cb8d7f2
5
5
  SHA512:
6
- metadata.gz: 292cdd9ee19c4b7c290c0a41a7c2966758f3f89fdd0453ec8e58a827501d95b2761491f9799a0f009ae1a0ef99ac78e489ded615bc496121919ecfd613184737
7
- data.tar.gz: 4128e54f173bc9edb46dea6ca62abb815bb1c4e50320879517f7e01d8ec1e1579d439431bcbc183d0bfdd6e627a025f7b2b2bd27f7819ca06e7ff725eae1dba1
6
+ metadata.gz: ecaacf45f6a89e49204df2ca539f17bd1635cf9cd346d2212c73de6e35aa459cbde02dfb6a1376b491e9290730af11e962e7f5c120b4d7f23cc8aa36f2a08fe9
7
+ data.tar.gz: c14a8482023fa93f8efa06d1f728f8d314028176f1ea003191a547a5795338fc6e4c4e232d0109e165dadf0ce50c329847d166e83d1dadba4d8d9d15f4680120
data/data/EDITOR ADDED
@@ -0,0 +1 @@
1
+ /usr/local/bin/vim
data/data/ROOT ADDED
@@ -0,0 +1 @@
1
+ /FULL/PATH/.blogs
data/data/VIEW ADDED
@@ -0,0 +1 @@
1
+ [no view]
data/lib/helpers-blog.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'runeblog_version'
2
2
  require 'fileutils'
3
3
 
4
+ require 'pathmagic'
4
5
  require 'xlate'
5
6
 
6
7
  module RuneBlog::Helpers
@@ -19,46 +20,26 @@ module RuneBlog::Helpers
19
20
  puts " Failed: #{cmd} - from #{caller[0]}" unless rc
20
21
  end
21
22
 
22
- def read_config(file, *syms)
23
- log!(enter: __method__, args: [file, *syms], level: 3)
24
- lines = File.readlines(file).map(&:chomp)
25
- obj = ::OpenStruct.new
26
- lines.each do |line|
27
- next if line == "\n" || line[0] == "#"
28
- key, val = line.split(/: +/, 2)
29
- obj.send(key+"=", val)
23
+ def copy_data(tag, dest)
24
+ data = RuneBlog::Path/"../data" # files kept inside gem
25
+ case tag
26
+ when :config; files = %w[ROOT VIEW EDITOR]
30
27
  end
31
- return obj if syms.empty?
28
+ files.each {|file| copy(data/file, dest) }
29
+ end
32
30
 
33
- vals = []
34
- if syms.empty?
35
- vals = obj.to_hash.values
36
- else
37
- syms.each {|sym| vals << obj.send(sym) }
38
- end
39
- return vals
31
+ def read_config
32
+ log!(enter: __method__, level: 3)
33
+ @editor = File.read("data/EDITOR").chomp
34
+ @current_view = File.read("data/VIEW").chomp
35
+ @root = File.read("data/EDITOR").chomp
40
36
  rescue => err
41
- puts "Can't read config file '#{file}': #{err}"
37
+ puts "Can't read config: #{err}"
42
38
  puts err.backtrace.join("\n")
43
39
  puts "dir = #{Dir.pwd}"
44
40
  exit
45
41
  end
46
42
 
47
- def try_read_config(file, hash)
48
- log!(enter: __method__, args: [file, hash], level: 3)
49
- return hash.values unless File.exist?(file)
50
- vals = read_config(file, *hash.keys)
51
- vals
52
- end
53
-
54
- def write_config(obj, file)
55
- log!(enter: __method__, args: [obj, file], level: 2)
56
- hash = obj.to_h
57
- File.open(file, "w") do |out|
58
- hash.each_pair {|key, val| out.puts "#{key}: #{val}" }
59
- end
60
- end
61
-
62
43
  def get_views # read from filesystem
63
44
  log!(enter: __method__, level: 3)
64
45
  dirs = subdirs("#@root/views/").sort
data/lib/liveblog.rb CHANGED
@@ -11,7 +11,7 @@ require 'xlate'
11
11
  def init_liveblog # FIXME - a lot of this logic sucks
12
12
  here = Dir.pwd
13
13
  dir = here
14
- loop { dir = Dir.pwd; break if File.exist?("config"); Dir.chdir("..") }
14
+ loop { dir = Dir.pwd; break if File.exist?("data/ROOT"); Dir.chdir("..") }
15
15
  Dir.chdir(here) # here??? or dir??
16
16
  @blog = RuneBlog.new(dir)
17
17
  @root = @blog.root
data/lib/repl.rb CHANGED
@@ -255,7 +255,7 @@ module RuneBlog::REPL
255
255
  return @out
256
256
  else
257
257
  if @blog.view?(arg)
258
- @blog.view = arg # reads config
258
+ @blog.view = arg
259
259
  output "View: " + @blog.view.name.to_s
260
260
  puts "\n ", fx(arg, :bold), "\n" unless testing
261
261
  end
data/lib/runeblog.rb CHANGED
@@ -19,7 +19,6 @@ require 'pathmagic'
19
19
  class RuneBlog
20
20
 
21
21
  DotDir = ".blogs"
22
- ConfigFile = "config"
23
22
  Themes = RuneBlog::Path/"../themes"
24
23
 
25
24
  make_exception(:FileNotFound, "File $1 was not found")
@@ -53,34 +52,25 @@ class RuneBlog
53
52
  puts "Error: See #{out}"
54
53
  end
55
54
 
56
- def self.create_new_blog_repo(dir = ".blogs")
57
- log!(enter: __method__, args: [dir])
58
- raise ArgumentError unless dir.is_a?(String) && ! dir.empty?
59
- root_dir = Dir.pwd/dir
60
- self.create(dir)
61
- rescue => err
62
- puts "Can't create blog repo: '#{dir}' - #{err}"
63
- puts err.backtrace.join("\n")
64
- end
65
-
66
- def self.create(root = ".blogs")
67
- log!(enter: __method__, args: [root], level: 1)
55
+ def self.create_new_blog_repo(root = ".blogs")
56
+ log!(enter: __method__, args: [root])
57
+ raise ArgumentError unless root.is_a?(String) && ! root.empty?
58
+ root_dir = Dir.pwd/root
68
59
  # Crude - FIXME later - # What views are there? Publishing, etc.
69
60
  self.blog = self # Weird. Like a singleton - dumbass circular dependency?
70
61
  root = Dir.pwd/root
71
62
  raise BlogRepoAlreadyExists if Dir.exist?(root)
72
63
  create_dirs(root)
73
64
  Dir.chdir(root) do
74
- create_dirs(:drafts, :views, :posts)
65
+ create_dirs(:data, :drafts, :views, :posts)
66
+ copy_data(:config, "./data/")
75
67
  new_sequence
76
68
  end
77
- x = OpenStruct.new
78
- x.root, x.current_view, x.editor = root, "test_view", "/usr/bin/vim " # dumb - FIXME later
79
- write_config(x, root/ConfigFile)
80
69
  @blog = self.new(root)
81
70
  @blog
82
71
  rescue => err
83
- _tmp_error(err)
72
+ puts "Can't create blog repo: '#{root}' - #{err}"
73
+ puts err.backtrace.join("\n")
84
74
  end
85
75
 
86
76
  def self.open(root = ".blogs")
@@ -99,11 +89,7 @@ class RuneBlog
99
89
  self.class.blog = self # Weird. Like a singleton - dumbass circular dependency?
100
90
 
101
91
  @root = root_dir
102
- file = @root/ConfigFile
103
- errmsg = "No config file! file = #{file.inspect} dir = #{Dir.pwd}"
104
- raise errmsg unless File.exist?(file)
105
-
106
- @root, @view_name, @editor = read_config(file, :root, :current_view, :editor)
92
+ read_config
107
93
  md = Dir.pwd.match(%r[.*/views/(.*?)/])
108
94
  @view_name = md[1] if md
109
95
  @views = get_views
@@ -204,6 +190,7 @@ class RuneBlog
204
190
 
205
191
  def view=(arg)
206
192
  log!(enter: __method__, args: [arg], level: 2)
193
+ # FIXME should write VIEW file?
207
194
  case arg
208
195
  when RuneBlog::View
209
196
  @view = arg
@@ -429,8 +416,7 @@ class RuneBlog
429
416
  log!(enter: __method__, args: [view], level: 3)
430
417
  raise ArgumentError unless view.is_a?(String) || view.is_a?(RuneBlog::View)
431
418
  x = OpenStruct.new
432
- x.root, x.current_view, x.editor = @root, view.to_s, @editor # dumb - FIXME later
433
- write_config(x, @root/ConfigFile)
419
+ File.write(@root/"data/VIEW", view.to_s)
434
420
  self.view = view # error checking?
435
421
  end
436
422
 
@@ -2,7 +2,7 @@
2
2
  if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
3
3
 
4
4
  class RuneBlog
5
- VERSION = "0.2.69"
5
+ VERSION = "0.2.70"
6
6
 
7
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
8
8
  Path = File.dirname(path)
data/runeblog.gemspec CHANGED
@@ -28,11 +28,12 @@ spec = Gem::Specification.new do |s|
28
28
  # Files...
29
29
  main = Find.find("bin").to_a +
30
30
  Find.find("lib").to_a
31
+ data = Find.find("data").to_a
31
32
  test = Find.find("test").to_a
32
33
  misc = %w[./README.lt3 ./README.md ./runeblog.gemspec]
33
34
  empty_view = Find.find("empty_view").to_a
34
35
 
35
- s.files = main + misc + test + empty_view
36
+ s.files = main + misc + data + test + empty_view
36
37
  s.homepage = 'https://github.com/Hal9000/runeblog'
37
38
  s.license = "Ruby"
38
39
  s.post_install_message = "\n Success! Run 'blog' command and type h for help.\n "
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.69
4
+ version: 0.2.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
@@ -76,6 +76,9 @@ files:
76
76
  - "./runeblog.gemspec"
77
77
  - bin/blog
78
78
  - bin/mkwidget
79
+ - data/EDITOR
80
+ - data/ROOT
81
+ - data/VIEW
79
82
  - empty_view/assets/austin-pano.jpg
80
83
  - empty_view/assets/sky2.jpg
81
84
  - empty_view/remote/assets/GIT_IS_DUMB