blogster 0.1.1 → 0.1.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
  SHA1:
3
- metadata.gz: 344e489be60b80222b1dafdd63a5ec132d371f7e
4
- data.tar.gz: f1aa6432368fb5b30fe275693bbec3cee0d2e1c0
3
+ metadata.gz: 7ff4e8849e14f72f60d5ee2e8cf6961b96d3d37f
4
+ data.tar.gz: 84f07a0c65b4abb9921beca9191e89dd2731d155
5
5
  SHA512:
6
- metadata.gz: 978e739ccd852ec0c019725d25bb1f5ca3ec54662e4ab035cb65d10b0e3813b2bc53ea8eeb23700d61ef6d26fcf3226019aa29e374017c7230fe2c6286a8d1b4
7
- data.tar.gz: 51058a36bf84a8ed6ccf9da20b659421d3e50c2a87ad7846ff9476ae32a7b5db129bde0593365d97a1880e2d2d742851d31cd9663ea3b06fa130820f155148cd
6
+ metadata.gz: dcdaa91c1c6083889d8060ddee4a5cbc9e43bba5b1b925b0c65eac0e246bed03e49aedff19d0cf60160501aa6a88d465b5faaa1475175841aec3e1c8dc7a17c4
7
+ data.tar.gz: 28c4ad4a1a6525e8d48156998c8a25730318a4c1555b930316d5a2ada825c36f471631f3e7eb4385900f6bfac9f5096cd2e49c7838e98f7efbbec34cc03a6d2e
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  end
29
29
  spec.bindir = 'exe'
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.executables << 'blogster'
31
32
  spec.require_paths = ['lib']
32
33
 
33
34
  spec.add_development_dependency 'bundler', '~> 1.13'
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/blogster.rb'
4
+ require 'fileutils'
5
+
6
+ user_path = ENV['PWD']
7
+ command = ARGV.first
8
+
9
+
10
+ if command == 'run'
11
+ unless File.exist?("#{user_path}/.blogster")
12
+ puts 'You need to be inside a project root directory.'
13
+ exit
14
+ end
15
+
16
+ sub_directories = Dir['*/'].map { |file| File.join(user_path, file) }
17
+ parsed_files = Blogster::TemplatesParser.new(sub_directories)
18
+ templates = parsed_files.to_templates
19
+
20
+ Blogster.create(templates)
21
+ Blogster.run!
22
+ elsif command == 'generate'
23
+
24
+ page = ARGV[1]
25
+ template_name = ARGV[2]
26
+
27
+ unless File.exist?("#{user_path}/.blogster")
28
+ puts 'You need to be in a blogster file structure.'
29
+ puts 'Run the new command first.'
30
+ exit
31
+ end
32
+
33
+ if ARGV.size < 3
34
+ puts 'You need to supply two arguments - a page and a template.'
35
+ exit
36
+ end
37
+
38
+ template_path = File.join(user_path, "_#{page.downcase}")
39
+ template = File.join(template_path.downcase, "#{template_name}.md".downcase)
40
+
41
+ puts "Creating #{template_path} folder."
42
+ FileUtils.mkdir_p template_path
43
+
44
+ if File.exist?(template)
45
+ puts 'This template already exists.'
46
+ puts 'Delete the old one first and then run the command again.'
47
+ exit
48
+ end
49
+
50
+ puts "Generating markdown file: #{template}"
51
+ File.open(template, 'w') do |file|
52
+ time = Time.now.strftime('%d/%m/%Y at %I:%M%p')
53
+
54
+ puts "Published on #{time}"
55
+ file.puts <<-PAGE_TEMPLATE
56
+ # #{page.capitalize}
57
+
58
+ ## #{template_name.capitalize}
59
+
60
+ *published on #{time}*
61
+
62
+ 1. Template generated.
63
+ 2. **You can edit this markdown however you want.**
64
+ 3. You can inline HTML and all the cool stuff you get with markdown files.
65
+
66
+ **Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.**
67
+
68
+
69
+ *Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.*
70
+ PAGE_TEMPLATE
71
+ end
72
+
73
+ puts 'Finished.'
74
+ elsif command == 'new'
75
+
76
+ project_name = ARGV.second
77
+ root = File.dirname(__dir__)
78
+ template_path = File.join(root, 'template_folder', '.')
79
+
80
+ if ARGV.size < 2
81
+ puts 'You must run new command with an app_name argument.'
82
+ puts 'In which the project will be generated.'
83
+ exit
84
+ end
85
+
86
+ project_path = File.join(user_path, project_name)
87
+
88
+ puts 'Creating new blogster project...'
89
+
90
+ puts "Generating project's path."
91
+ FileUtils.mkdir_p(project_path)
92
+
93
+ puts 'Generating project templates.'
94
+ FileUtils.cp_r(template_path, project_path)
95
+
96
+ puts 'Finished.'
97
+ else
98
+ puts "You must construct addition pylons. I mean you must add additional arguments"
99
+ end
@@ -1,3 +1,3 @@
1
1
  module Blogster
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blogster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikola Jichev
@@ -126,6 +126,7 @@ description: You can create static blogs with this gem.
126
126
  email:
127
127
  - njichev@gmail.com
128
128
  executables:
129
+ - blogster
129
130
  - generate
130
131
  - new
131
132
  - run
@@ -145,6 +146,7 @@ files:
145
146
  - bin/setup
146
147
  - blogster.gemspec
147
148
  - config.ru
149
+ - exe/blogster
148
150
  - exe/generate
149
151
  - exe/new
150
152
  - exe/run