nesta 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +21 -0
  3. data/.gitmodules +0 -6
  4. data/CHANGES +26 -0
  5. data/Gemfile.lock +35 -33
  6. data/LICENSE +1 -1
  7. data/README.md +7 -14
  8. data/RELEASING.md +9 -7
  9. data/Rakefile +2 -2
  10. data/bin/nesta +1 -1
  11. data/config/deploy.rb.sample +1 -1
  12. data/lib/nesta/commands/demo/content.rb +8 -10
  13. data/lib/nesta/commands/edit.rb +2 -6
  14. data/lib/nesta/commands/new.rb +9 -11
  15. data/lib/nesta/commands/plugin/create.rb +7 -9
  16. data/lib/nesta/commands/template.rb +20 -0
  17. data/lib/nesta/commands/theme/create.rb +8 -8
  18. data/lib/nesta/commands/theme/enable.rb +3 -5
  19. data/lib/nesta/commands/theme/install.rb +6 -10
  20. data/lib/nesta/commands.rb +8 -0
  21. data/lib/nesta/config_file.rb +25 -0
  22. data/lib/nesta/system_command.rb +15 -0
  23. data/lib/nesta/version.rb +1 -1
  24. data/lib/nesta.rb +6 -1
  25. data/nesta.gemspec +1 -1
  26. data/test/integration/commands/demo/content_test.rb +8 -6
  27. data/test/integration/commands/edit_test.rb +4 -4
  28. data/test/integration/commands/new_test.rb +22 -51
  29. data/test/integration/commands/plugin/create_test.rb +7 -4
  30. data/test/integration/commands/theme/create_test.rb +8 -2
  31. data/test/integration/commands/theme/enable_test.rb +7 -1
  32. data/test/integration/commands/theme/install_test.rb +13 -9
  33. data/test/unit/system_command_test.rb +20 -0
  34. metadata +14 -9
  35. data/.hound.yml +0 -2
  36. data/.rspec +0 -1
  37. data/.travis.yml +0 -11
  38. data/lib/nesta/commands/command.rb +0 -57
  39. data/test/support/silence_commands_during_tests.rb +0 -5
  40. data/test/unit/commands_test.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a79722f3a6494862b4365151dd2300b0eccece20b6cb711298c753763926d9ea
4
- data.tar.gz: 4eca7c5b41e3103500237791960658ca8a3b0d1bf50e83860d74d531dd40fb17
3
+ metadata.gz: e80fef7e8fe518a674eb7527d91410d162fca8288985971e641a3329ae192eef
4
+ data.tar.gz: bc6f671dc4f0ae10b403fa53b489f06c74ae8e9c6560ae49e08dc2518185dc22
5
5
  SHA512:
6
- metadata.gz: 36a89f709fa69d85e340a93ef44ca6fa43a31f54585d0da3c7ca359ed40dddd1003374a75feb0350bd53403595df0f71e513255a16e13dce0568c434fca62d9e
7
- data.tar.gz: b3c443a50646d62b70247743c6157433a946d98566b72631284217458e218908720c2ce3bf01534630458cb35cd4c3045d187861385ad3ada43256f74e55f054
6
+ metadata.gz: 857872073a0ea318df15323bd0f9a64de0104106b45c0c749a2261e266866abc0dd38f475fa98de07fb9cb09ee41411b837ec91a1e7d581bb1924f697557184d
7
+ data.tar.gz: 828a24e35350cfae15ff093f42a67a6ee33faf48435b0e0d9ff831e3e5a1592b2e22db2910442eb39adc7642f5b3f451224dcf8f49fcc11d7a062e7a48f4b47c
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: run-tests
3
+
4
+ on: [push, pull_request]
5
+
6
+ jobs:
7
+ test:
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: ["2.7", "3.0", "3.1", "head"]
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ bundler-cache: true
19
+ - run: bundle exec rake test
20
+ env:
21
+ REPORTER: default
data/.gitmodules CHANGED
@@ -1,6 +0,0 @@
1
- [submodule "test/fixtures/demo-content.git"]
2
- path = test/fixtures/demo-content.git
3
- url = https://github.com/gma/nesta-demo-content.git
4
- [submodule "test/fixtures/nesta-theme-test"]
5
- path = test/fixtures/nesta-theme-test.git
6
- url = https://github.com/gma/nesta-theme-test.git
data/CHANGES CHANGED
@@ -1,3 +1,29 @@
1
+ = 0.13.0 / (28 September 2022)
2
+
3
+ * Update dependencies in order to support Ruby 3.0 and above.
4
+ (Graham Ashton)
5
+
6
+ * Upgrade multiple dependencies to fix security vulnerabilities.
7
+ (Graham Ashton)
8
+
9
+ * Switch Git repository URLs to HTTPS (fixes the demo:content command).
10
+ (Graham Ashton)
11
+
12
+ * Update dependency on Haml; Nesta currently requires a version lower
13
+ than 6.0. (Graham Ashton)
14
+
15
+ * Refactor: Extracted logic for running external processes into
16
+ a new `Nesta::SystemCommand` class. (Graham Ashton)
17
+
18
+ * Refactor: Created a new `Nesta::Commands::Template` class for
19
+ commands that create files from templates. (Graham Ashton)
20
+
21
+ * Refactor: Move logic for editing the config file from within Nesta's
22
+ commands into new `Nesta::ConfigFile` class. (Graham Ashton)
23
+
24
+ * Stopped the test suite from executing external commands during tests.
25
+ (Graham Ashton)
26
+
1
27
  = 0.12.0 / (30 June 2020)
2
28
 
3
29
  * Upgrade to Sinatra 2 and Rack 2. (Graham Ashton)
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nesta (0.12.0)
4
+ nesta (0.13.0)
5
5
  RedCloth (~> 4.2)
6
- haml (>= 3.1)
6
+ haml (>= 3.1, < 6.0)
7
7
  haml-contrib (>= 1.0)
8
8
  rack (~> 2.0)
9
9
  rdiscount (~> 2.1)
@@ -15,8 +15,8 @@ GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
17
  RedCloth (4.3.2)
18
- addressable (2.7.0)
19
- public_suffix (>= 2.0.2, < 5.0)
18
+ addressable (2.8.1)
19
+ public_suffix (>= 2.0.2, < 6.0)
20
20
  ansi (1.5.0)
21
21
  builder (3.2.4)
22
22
  byebug (11.1.3)
@@ -27,21 +27,21 @@ GEM
27
27
  rack (>= 1.0.0)
28
28
  rack-test (>= 0.5.4)
29
29
  xpath (>= 2.0, < 4.0)
30
- ffi (1.13.1)
31
- haml (5.1.2)
30
+ ffi (1.15.5)
31
+ haml (5.2.2)
32
32
  temple (>= 0.8.0)
33
33
  tilt
34
34
  haml-contrib (1.0.0.1)
35
35
  haml (>= 3.2.0.alpha.13)
36
- kgio (2.11.3)
36
+ kgio (2.11.4)
37
37
  listen (1.3.1)
38
38
  rb-fsevent (>= 0.9.3)
39
39
  rb-inotify (>= 0.9)
40
40
  rb-kqueue (>= 0.2)
41
- mini_mime (1.0.2)
42
- mini_portile2 (2.4.0)
43
- minitest (5.14.1)
44
- minitest-reporters (1.4.2)
41
+ mini_mime (1.1.2)
42
+ mini_portile2 (2.8.0)
43
+ minitest (5.16.3)
44
+ minitest-reporters (1.5.0)
45
45
  ansi
46
46
  builder
47
47
  minitest (>= 5.0)
@@ -51,36 +51,38 @@ GEM
51
51
  rb-fsevent (>= 0.9)
52
52
  rb-inotify (>= 0.8)
53
53
  unicorn (>= 4.5)
54
- mustermann (1.1.1)
54
+ mustermann (2.0.2)
55
55
  ruby2_keywords (~> 0.0.1)
56
- nokogiri (1.10.9)
57
- mini_portile2 (~> 2.4.0)
58
- public_suffix (4.0.5)
59
- rack (2.2.3)
60
- rack-protection (2.0.8.1)
56
+ nokogiri (1.13.8)
57
+ mini_portile2 (~> 2.8.0)
58
+ racc (~> 1.4)
59
+ public_suffix (5.0.0)
60
+ racc (1.6.0)
61
+ rack (2.2.4)
62
+ rack-protection (2.2.2)
61
63
  rack
62
- rack-test (1.1.0)
63
- rack (>= 1.0, < 3)
64
- raindrops (0.19.1)
65
- rake (13.0.1)
66
- rb-fsevent (0.10.4)
64
+ rack-test (2.0.2)
65
+ rack (>= 1.3)
66
+ raindrops (0.20.0)
67
+ rake (13.0.6)
68
+ rb-fsevent (0.11.2)
67
69
  rb-inotify (0.10.1)
68
70
  ffi (~> 1.0)
69
- rb-kqueue (0.2.5)
71
+ rb-kqueue (0.2.8)
70
72
  ffi (>= 0.5.0)
71
- rdiscount (2.2.0.1)
72
- ruby-progressbar (1.10.1)
73
- ruby2_keywords (0.0.2)
73
+ rdiscount (2.2.0.2)
74
+ ruby-progressbar (1.11.0)
75
+ ruby2_keywords (0.0.5)
74
76
  sassc (2.4.0)
75
77
  ffi (~> 1.9)
76
- sinatra (2.0.8.1)
77
- mustermann (~> 1.0)
78
- rack (~> 2.0)
79
- rack-protection (= 2.0.8.1)
78
+ sinatra (2.2.2)
79
+ mustermann (~> 2.0)
80
+ rack (~> 2.2)
81
+ rack-protection (= 2.2.2)
80
82
  tilt (~> 2.0)
81
83
  temple (0.8.2)
82
- tilt (2.0.10)
83
- unicorn (5.5.5)
84
+ tilt (2.0.11)
85
+ unicorn (6.1.0)
84
86
  kgio (~> 2.6)
85
87
  raindrops (~> 0.7)
86
88
  xpath (3.2.0)
@@ -99,4 +101,4 @@ DEPENDENCIES
99
101
  rake
100
102
 
101
103
  BUNDLED WITH
102
- 2.1.4
104
+ 2.3.14
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2020 Graham Ashton
1
+ Copyright (c) 2008-2022 Graham Ashton
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Nesta - a CMS for Ruby Developers
2
2
 
3
- A CMS for small web sites and blogs, written in [Sinatra][frank].
3
+ A file-based CMS for web sites and blogs, written in [Sinatra][frank].
4
4
 
5
5
  Content can be written in [Markdown][markdown] or [Textile][textile] and
6
6
  stored in text files (though you can also use Haml if you need to add
@@ -44,9 +44,8 @@ full instructions).
44
44
  ## Support
45
45
 
46
46
  There's plenty of information on <http://nestacms.com>. If you need some
47
- help with anything just jump on the [mailing list][] and ask.
48
-
49
- [mailing list]: http://nestacms.com/support
47
+ help with anything feel free to file an issue, or contact me (@grahamashton)
48
+ on Twitter.
50
49
 
51
50
  If you like Nesta you can keep up with developments by following [@nestacms][]
52
51
  on Twitter, and on [the blog][].
@@ -56,19 +55,13 @@ on Twitter, and on [the blog][].
56
55
 
57
56
  ## Contributing
58
57
 
59
- If you want to add a new feature, I recommend that you post a quick
60
- message to the [mailing list][] before you start coding. I'm likely to
61
- suggest that we implement it as a [plugin][] (to keep Nesta itself lean
62
- and simple), so you might save yourself some time if we chat about a
63
- good approach before you start.
58
+ If you want to add a new feature, I recommend that you file an issue to discuss
59
+ it before you start coding. I'm likely to suggest that we implement it as a
60
+ [plugin][] (to keep Nesta itself lean and simple), so you might save yourself
61
+ some time if we chat about a good approach before you start.
64
62
 
65
63
  [plugin]: http://nestacms.com/docs/plugins
66
64
 
67
- If you think you've found a bug, please bring that up on the [mailing
68
- list][] too, rather than creating an issue on GitHub straight away.
69
- You'll probably get a faster response on the mailing list, as I'm the
70
- only person who'll see your new issue.
71
-
72
65
  -- Graham ([@grahamashton][] on Twitter).
73
66
 
74
67
  [@grahamashton]: http://twitter.com/grahamashton
data/RELEASING.md CHANGED
@@ -3,19 +3,21 @@
3
3
  When it comes time to release a new version of the Nesta gem, these are
4
4
  the steps:
5
5
 
6
- 1. Bump the version number in `lib/nesta/version.rb`. This will cause
6
+ 1. Check the versions of Ruby used in `.github/workflows` are up to date. If
7
+ new Ruby versions need testing, update the config and re-run the build.
8
+
9
+ 2. Bump the version number in `lib/nesta/version.rb`. This will cause
7
10
  the version number in `Gemfile.lock` to be updated too, so regenerate
8
11
  it now and check them in together.
9
12
 
10
- 2. Update the `CHANGES` file with a summary of significant changes since
13
+ 3. Update the `CHANGES` file with a summary of significant changes since
11
14
  the previous release.
12
15
 
13
- 3. Check the versions of Ruby used in `.travis.yml` are up to date. If new
14
- Ruby versions need testing, update the config and re-run the Travis build.
16
+ 4. Commit these changes with a commit message of 'Bump version to <version>'
15
17
 
16
- 4. Generate a new site with the `nesta` command, install the demo content,
18
+ 5. Generate a new site with the `nesta` command, install the demo content,
17
19
  check that it runs okay locally.
18
20
 
19
- 5. If everything seems fine, run `rake release`.
21
+ 6. If everything seems fine, run `rake release`.
20
22
 
21
- 6. Publish an announcement blog post and email the list.
23
+ 7. Publish an announcement blog post and email the list.
data/Rakefile CHANGED
@@ -15,11 +15,11 @@ namespace :test do
15
15
  end
16
16
 
17
17
  task units: :set_load_path do
18
- load_tests('unit')
18
+ load_tests('unit/**')
19
19
  end
20
20
 
21
21
  task integrations: :set_load_path do
22
- load_tests('integration')
22
+ load_tests('integration/**')
23
23
  end
24
24
  end
25
25
 
data/bin/nesta CHANGED
@@ -91,7 +91,7 @@ EOF
91
91
  rescue NameError
92
92
  usage
93
93
  else
94
- command_cls.new(ARGV[0], options).execute
94
+ command_cls.new(ARGV[0], options).execute(Nesta::SystemCommand.new)
95
95
  end
96
96
  rescue RuntimeError => e
97
97
  $stderr.puts "ERROR: #{e}"
@@ -1,5 +1,5 @@
1
1
  set :application, "nesta"
2
- set :repository, "git://github.com/gma/nesta.git"
2
+ set :repository, "https://github.com/gma/nesta.git"
3
3
 
4
4
  # Set :user if you want to connect (via ssh) to your server using a
5
5
  # different username. You will also need to include the user in :domain
@@ -1,12 +1,10 @@
1
- require File.expand_path('../command', File.dirname(__FILE__))
1
+ require File.expand_path('../../config_file', File.dirname(__FILE__))
2
2
 
3
3
  module Nesta
4
4
  module Commands
5
5
  module Demo
6
6
  class Content
7
- include Command
8
-
9
- @demo_repository = 'git://github.com/gma/nesta-demo-content.git'
7
+ @demo_repository = 'https://github.com/gma/nesta-demo-content.git'
10
8
  class << self
11
9
  attr_accessor :demo_repository
12
10
  end
@@ -15,12 +13,12 @@ module Nesta
15
13
  @dir = 'content-demo'
16
14
  end
17
15
 
18
- def clone_or_update_repository
16
+ def clone_or_update_repository(process)
19
17
  path = Nesta::Path.local(@dir)
20
18
  if File.exist?(path)
21
- FileUtils.cd(path) { run_process('git', 'pull', 'origin', 'master') }
19
+ FileUtils.cd(path) { process.run('git', 'pull', 'origin', 'master') }
22
20
  else
23
- run_process('git', 'clone', self.class.demo_repository, path)
21
+ process.run('git', 'clone', self.class.demo_repository, path)
24
22
  end
25
23
  end
26
24
 
@@ -45,10 +43,10 @@ module Nesta
45
43
  end
46
44
  end
47
45
 
48
- def execute
49
- clone_or_update_repository
46
+ def execute(process)
47
+ clone_or_update_repository(process)
50
48
  configure_git_to_ignore_repo
51
- update_config_yaml(/^\s*#?\s*content:.*/, "content: #{@dir}")
49
+ Nesta::ConfigFile.new.set_value('content', @dir)
52
50
  end
53
51
  end
54
52
  end
@@ -1,20 +1,16 @@
1
- require File.expand_path('command', File.dirname(__FILE__))
2
-
3
1
  module Nesta
4
2
  module Commands
5
3
  class Edit
6
- include Command
7
-
8
4
  def initialize(*args)
9
5
  @filename = Nesta::Config.page_path(args.shift)
10
6
  end
11
7
 
12
- def execute
8
+ def execute(process)
13
9
  editor = ENV.fetch('EDITOR')
14
10
  rescue IndexError
15
11
  $stderr.puts "No editor: set EDITOR environment variable"
16
12
  else
17
- run_process(editor, @filename)
13
+ process.run(editor, @filename)
18
14
  end
19
15
  end
20
16
  end
@@ -1,10 +1,6 @@
1
- require File.expand_path('command', File.dirname(__FILE__))
2
-
3
1
  module Nesta
4
2
  module Commands
5
3
  class New
6
- include Command
7
-
8
4
  def initialize(*args)
9
5
  path = args.shift
10
6
  options = args.shift || {}
@@ -26,18 +22,18 @@ module Nesta
26
22
  @options['vlad']
27
23
  end
28
24
 
29
- def create_repository
25
+ def create_repository(process)
30
26
  FileUtils.cd(@path) do
31
27
  File.open('.gitignore', 'w') do |file|
32
28
  file.puts %w[._* .*.swp .bundle .DS_Store .sass-cache].join("\n")
33
29
  end
34
- run_process('git', 'init')
35
- run_process('git', 'add', '.')
36
- run_process('git', 'commit', '-m', 'Initial commit')
30
+ process.run('git', 'init')
31
+ process.run('git', 'add', '.')
32
+ process.run('git', 'commit', '-m', 'Initial commit')
37
33
  end
38
34
  end
39
35
 
40
- def execute
36
+ def execute(process)
41
37
  make_directories
42
38
  templates = {
43
39
  'config.ru' => "#{@path}/config.ru",
@@ -49,8 +45,10 @@ module Nesta
49
45
  if @options['vlad']
50
46
  templates['config/deploy.rb'] = "#{@path}/config/deploy.rb"
51
47
  end
52
- copy_templates(templates)
53
- create_repository if @options['git']
48
+ templates.each do |src, dest|
49
+ Nesta::Commands::Template.new(src).copy_to(dest, binding)
50
+ end
51
+ create_repository(process) if @options['git']
54
52
  end
55
53
  end
56
54
  end
@@ -1,11 +1,7 @@
1
- require File.expand_path('../command', File.dirname(__FILE__))
2
-
3
1
  module Nesta
4
2
  module Commands
5
3
  module Plugin
6
4
  class Create
7
- include Command
8
-
9
5
  def initialize(*args)
10
6
  name = args.shift
11
7
  name.nil? && (raise UsageError.new('name not specified'))
@@ -54,9 +50,9 @@ module Nesta
54
50
  File.join(@gem_name, path)
55
51
  end
56
52
 
57
- def execute
53
+ def execute(process)
58
54
  make_directories
59
- copy_templates(
55
+ {
60
56
  'plugins/README.md' => gem_path('README.md'),
61
57
  'plugins/gitignore' => gem_path('.gitignore'),
62
58
  'plugins/plugin.gemspec' => gem_path("#{@gem_name}.gemspec"),
@@ -65,10 +61,12 @@ module Nesta
65
61
  'plugins/lib/version.rb' => gem_path("lib/#{@gem_name}/version.rb"),
66
62
  'plugins/lib/init.rb' => gem_path("lib/#{@gem_name}/init.rb"),
67
63
  'plugins/Rakefile' => gem_path('Rakefile')
68
- )
64
+ }.each do |src, dest|
65
+ Nesta::Commands::Template.new(src).copy_to(dest, binding)
66
+ end
69
67
  Dir.chdir(@gem_name) do
70
- run_process('git', 'init')
71
- run_process('git', 'add', '.')
68
+ process.run('git', 'init')
69
+ process.run('git', 'add', '.')
72
70
  end
73
71
  end
74
72
 
@@ -0,0 +1,20 @@
1
+ module Nesta
2
+ module Commands
3
+ class Template
4
+ def initialize(filename)
5
+ @filename = filename
6
+ end
7
+
8
+ def template_path
9
+ dir = File.expand_path('../../../templates', File.dirname(__FILE__))
10
+ File.join(dir, @filename)
11
+ end
12
+
13
+ def copy_to(dest, context)
14
+ FileUtils.mkdir_p(File.dirname(dest))
15
+ template = ERB.new(File.read(template_path), trim_mode: "-")
16
+ File.open(dest, 'w') { |file| file.puts template.result(context) }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,18 +1,16 @@
1
- require File.expand_path('../command', File.dirname(__FILE__))
2
-
3
1
  module Nesta
4
2
  module Commands
5
3
  module Theme
6
4
  class Create
7
- include Command
8
-
9
5
  def initialize(*args)
10
6
  name = args.shift
11
7
  options = args.shift || {}
12
8
  name.nil? && (raise UsageError.new('name not specified'))
13
9
  @name = name
14
10
  @theme_path = Nesta::Path.themes(@name)
15
- fail("#{@theme_path} already exists") if File.exist?(@theme_path)
11
+ if File.exist?(@theme_path)
12
+ Nesta.fail_with("#{@theme_path} already exists")
13
+ end
16
14
  end
17
15
 
18
16
  def make_directories
@@ -20,15 +18,17 @@ module Nesta
20
18
  FileUtils.mkdir_p(File.join(@theme_path, 'views'))
21
19
  end
22
20
 
23
- def execute
21
+ def execute(process)
24
22
  make_directories
25
- copy_templates(
23
+ {
26
24
  'themes/README.md' => "#{@theme_path}/README.md",
27
25
  'themes/app.rb' => "#{@theme_path}/app.rb",
28
26
  'themes/views/layout.haml' => "#{@theme_path}/views/layout.haml",
29
27
  'themes/views/page.haml' => "#{@theme_path}/views/page.haml",
30
28
  'themes/views/master.sass' => "#{@theme_path}/views/master.sass"
31
- )
29
+ }.each do |src, dest|
30
+ Nesta::Commands::Template.new(src).copy_to(dest, binding)
31
+ end
32
32
  end
33
33
  end
34
34
  end
@@ -1,11 +1,9 @@
1
- require File.expand_path('../command', File.dirname(__FILE__))
1
+ require File.expand_path('../../config_file', File.dirname(__FILE__))
2
2
 
3
3
  module Nesta
4
4
  module Commands
5
5
  module Theme
6
6
  class Enable
7
- include Command
8
-
9
7
  def initialize(*args)
10
8
  name = args.shift
11
9
  options = args.shift || {}
@@ -13,8 +11,8 @@ module Nesta
13
11
  @name = name
14
12
  end
15
13
 
16
- def execute
17
- update_config_yaml(/^\s*#?\s*theme:.*/, "theme: #{@name}")
14
+ def execute(process)
15
+ Nesta::ConfigFile.new.set_value('theme', @name)
18
16
  end
19
17
  end
20
18
  end
@@ -1,11 +1,7 @@
1
- require File.expand_path('../command', File.dirname(__FILE__))
2
-
3
1
  module Nesta
4
2
  module Commands
5
3
  module Theme
6
4
  class Install
7
- include Command
8
-
9
5
  def initialize(*args)
10
6
  @url = args.shift
11
7
  @url.nil? && (raise UsageError.new('URL not specified'))
@@ -16,14 +12,14 @@ module Nesta
16
12
  File.basename(@url, '.git').sub(/nesta-theme-/, '')
17
13
  end
18
14
 
19
- def execute
20
- run_process('git', 'clone', @url, "themes/#{theme_name}")
21
- FileUtils.rm_r(File.join("themes/#{theme_name}", '.git'))
22
- enable
15
+ def execute(process)
16
+ process.run('git', 'clone', @url, "themes/#{theme_name}")
17
+ FileUtils.rm_rf(File.join("themes/#{theme_name}", '.git'))
18
+ enable(process)
23
19
  end
24
20
 
25
- def enable
26
- Enable.new(theme_name).execute
21
+ def enable(process)
22
+ Enable.new(theme_name).execute(process)
27
23
  end
28
24
  end
29
25
  end
@@ -4,10 +4,18 @@ require 'fileutils'
4
4
  require File.expand_path('env', File.dirname(__FILE__))
5
5
  require File.expand_path('app', File.dirname(__FILE__))
6
6
  require File.expand_path('path', File.dirname(__FILE__))
7
+ require File.expand_path('system_command', File.dirname(__FILE__))
7
8
  require File.expand_path('version', File.dirname(__FILE__))
8
9
 
9
10
  require File.expand_path('commands/demo', File.dirname(__FILE__))
10
11
  require File.expand_path('commands/edit', File.dirname(__FILE__))
11
12
  require File.expand_path('commands/new', File.dirname(__FILE__))
12
13
  require File.expand_path('commands/plugin', File.dirname(__FILE__))
14
+ require File.expand_path('commands/template', File.dirname(__FILE__))
13
15
  require File.expand_path('commands/theme', File.dirname(__FILE__))
16
+
17
+ module Nesta
18
+ module Commands
19
+ class UsageError < RuntimeError; end
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ module Nesta
2
+ class ConfigFile
3
+ def set_value(key, value)
4
+ pattern = /^\s*#?\s*#{key}:.*/
5
+ replacement = "#{key}: #{value}"
6
+
7
+ configured = false
8
+ File.open(Nesta::Config.yaml_path, 'r+') do |file|
9
+ output = ''
10
+ file.each_line do |line|
11
+ if configured
12
+ output << line
13
+ else
14
+ output << line.sub(pattern, replacement)
15
+ configured = true if line =~ pattern
16
+ end
17
+ end
18
+ output << "#{replacement}\n" unless configured
19
+ file.pos = 0
20
+ file.print(output)
21
+ file.truncate(file.pos)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module Nesta
2
+ class SystemCommand
3
+ def run(*args)
4
+ system(*args)
5
+ if ! $?.success?
6
+ message = if $?.exitstatus == 127
7
+ "#{args[0]} not found"
8
+ else
9
+ "'#{args.join(' ')}' failed with status #{$?.exitstatus}"
10
+ end
11
+ Nesta.fail_with(message)
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/nesta/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nesta
2
- VERSION = '0.12.0'
2
+ VERSION = '0.13.0'
3
3
  end
data/lib/nesta.rb CHANGED
@@ -4,6 +4,11 @@ module Nesta
4
4
  $stderr.puts "DEPRECATION WARNING: #{name} is deprecated; #{message}"
5
5
  end
6
6
  end
7
+
8
+ def self.fail_with(message)
9
+ $stderr.puts "Error: #{message}"
10
+ exit 1
11
+ end
7
12
  end
8
13
 
9
- require 'nesta/plugin'
14
+ require File.expand_path('nesta/plugin', File.dirname(__FILE__))
data/nesta.gemspec CHANGED
@@ -29,7 +29,7 @@ EOF
29
29
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
30
  s.require_paths = ["lib"]
31
31
 
32
- s.add_dependency('haml', '>= 3.1')
32
+ s.add_dependency('haml', '>= 3.1', '< 6.0')
33
33
  s.add_dependency('haml-contrib', '>= 1.0')
34
34
  s.add_dependency('rack', '~> 2.0')
35
35
  s.add_dependency('rdiscount', '~> 2.1')
@@ -1,9 +1,6 @@
1
1
  require 'test_helper'
2
- require_relative '../../../support/silence_commands_during_tests'
3
2
  require_relative '../../../../lib/nesta/commands'
4
3
 
5
- Nesta::Commands::Demo::Content.send(:include, SilenceCommandsDuringTests)
6
-
7
4
  describe 'nesta demo:content' do
8
5
  include TemporaryFiles
9
6
 
@@ -11,10 +8,15 @@ describe 'nesta demo:content' do
11
8
  Nesta::Commands::Demo::Content.demo_repository = '../../fixtures/demo-content.git'
12
9
  end
13
10
 
11
+ def process_stub
12
+ Object.new.tap do |stub|
13
+ def stub.run(*args); end
14
+ end
15
+ end
16
+
14
17
  it 'clones the demo repository and configures project to use it' do
15
18
  in_temporary_project do
16
- Nesta::Commands::Demo::Content.new.execute
17
- assert_exists_in_project 'content-demo/pages/index.haml'
19
+ Nesta::Commands::Demo::Content.new.execute(process_stub)
18
20
 
19
21
  yaml = File.read(File.join(project_root, 'config', 'config.yml'))
20
22
  assert_match /content: content-demo/, yaml
@@ -24,7 +26,7 @@ describe 'nesta demo:content' do
24
26
  it 'ensures demo repository is ignored by git' do
25
27
  in_temporary_project do
26
28
  FileUtils.mkdir('.git')
27
- Nesta::Commands::Demo::Content.new.execute
29
+ Nesta::Commands::Demo::Content.new.execute(process_stub)
28
30
  assert_match /content-demo/, File.read(project_path('.git/info/exclude'))
29
31
  end
30
32
  end
@@ -9,13 +9,13 @@ describe 'nesta edit' do
9
9
  end
10
10
 
11
11
  it 'launches the editor' do
12
- ENV['EDITOR'] = 'touch'
12
+ ENV['EDITOR'] = 'vi'
13
13
  edited_file = 'path/to/page.md'
14
+ process = Minitest::Mock.new
15
+ process.expect(:run, true, [ENV['EDITOR'], /#{edited_file}$/])
14
16
  with_temp_content_directory do
15
- FileUtils.mkdir_p(Nesta::Config.page_path(File.dirname(edited_file)))
16
17
  command = Nesta::Commands::Edit.new(edited_file)
17
- command.execute
18
- assert File.exist?(Nesta::Config.page_path(edited_file)), 'editor not run'
18
+ command.execute(process)
19
19
  end
20
20
  end
21
21
  end
@@ -1,9 +1,6 @@
1
1
  require 'test_helper'
2
- require_relative '../../support/silence_commands_during_tests'
3
2
  require_relative '../../../lib/nesta/commands'
4
3
 
5
- Nesta::Commands::New.send(:include, SilenceCommandsDuringTests)
6
-
7
4
  describe 'nesta new' do
8
5
  include TemporaryFiles
9
6
 
@@ -19,30 +16,36 @@ describe 'nesta new' do
19
16
  remove_temp_directory
20
17
  end
21
18
 
19
+ def process_stub
20
+ Object.new.tap do |stub|
21
+ def stub.run(*args); end
22
+ end
23
+ end
24
+
22
25
  describe 'without options' do
23
26
  it 'creates the content directories' do
24
- Nesta::Commands::New.new(project_root).execute
27
+ Nesta::Commands::New.new(project_root).execute(process_stub)
25
28
  assert_exists_in_project 'content/attachments'
26
29
  assert_exists_in_project 'content/pages'
27
30
  end
28
31
 
29
32
  it 'creates the home page' do
30
- Nesta::Commands::New.new(project_root).execute
33
+ Nesta::Commands::New.new(project_root).execute(process_stub)
31
34
  assert_exists_in_project 'content/pages/index.haml'
32
35
  end
33
36
 
34
37
  it 'creates the rackup file' do
35
- Nesta::Commands::New.new(project_root).execute
38
+ Nesta::Commands::New.new(project_root).execute(process_stub)
36
39
  assert_exists_in_project 'config.ru'
37
40
  end
38
41
 
39
42
  it 'creates the config.yml file' do
40
- Nesta::Commands::New.new(project_root).execute
43
+ Nesta::Commands::New.new(project_root).execute(process_stub)
41
44
  assert_exists_in_project 'config/config.yml'
42
45
  end
43
46
 
44
47
  it 'creates a Gemfile' do
45
- Nesta::Commands::New.new(project_root).execute
48
+ Nesta::Commands::New.new(project_root).execute(process_stub)
46
49
  assert_exists_in_project 'Gemfile'
47
50
  assert_match /gem 'nesta'/, gemfile_source
48
51
  end
@@ -51,67 +54,35 @@ describe 'nesta new' do
51
54
  describe 'with --git option' do
52
55
  it 'creates a .gitignore file' do
53
56
  command = Nesta::Commands::New.new(project_root, 'git' => '')
54
- command.stub(:run_process, nil) do
55
- command.execute
56
- assert_match /\.bundle/, File.read(project_path('.gitignore'))
57
- end
58
- end
59
-
60
- def disabling_git_hooks
61
- # I (@gma) have got a git repository template setup on my computer
62
- # containing git hooks that automatically run ctags in a
63
- # background process whenever I run `git commit`. The hooks are
64
- # copied into new repositories when I run `git init`.
65
- #
66
- # The generation of the ctags file (in a forked process) causes a
67
- # race condition; sometimes ctags will recreate a test's project
68
- # folder and git directory after the test's `after` block has
69
- # deleted it. If the project directory isn't removed after each
70
- # test, the New command will throw an error in the subsequent
71
- # test (complaining that the project directory already exists).
72
- #
73
- templates = temp_path('git_template')
74
- FileUtils.mkdir_p(templates)
75
- ENV['GIT_TEMPLATE_DIR'] = templates
76
- yield
77
- ENV.delete('GIT_TEMPLATE_DIR')
78
- FileUtils.rm_r(templates)
57
+ command.execute(process_stub)
58
+ assert_match /\.bundle/, File.read(project_path('.gitignore'))
79
59
  end
80
60
 
81
61
  it 'creates a git repo' do
82
- disabling_git_hooks do
83
- command = Nesta::Commands::New.new(project_root, 'git' => '')
84
- command.execute
85
- assert_exists_in_project '.git/config'
86
- end
87
- end
88
-
89
- it 'commits the blank project' do
90
- disabling_git_hooks do
91
- command = Nesta::Commands::New.new(project_root, 'git' => '')
92
- command.execute
93
- Dir.chdir(project_root) do
94
- assert_match /Initial commit/, `git log --pretty=oneline | head -n 1`
95
- end
96
- end
62
+ command = Nesta::Commands::New.new(project_root, 'git' => '')
63
+ process = Minitest::Mock.new
64
+ process.expect(:run, true, ['git', 'init'])
65
+ process.expect(:run, true, ['git', 'add', '.'])
66
+ process.expect(:run, true, ['git', 'commit', '-m', 'Initial commit'])
67
+ command.execute(process)
97
68
  end
98
69
  end
99
70
 
100
71
  describe 'with --vlad option' do
101
72
  it 'adds vlad to Gemfile' do
102
- Nesta::Commands::New.new(project_root, 'vlad' => '').execute
73
+ Nesta::Commands::New.new(project_root, 'vlad' => '').execute(process_stub)
103
74
  assert_match /gem 'vlad', '2.1.0'/, gemfile_source
104
75
  assert_match /gem 'vlad-git', '2.2.0'/, gemfile_source
105
76
  end
106
77
 
107
78
  it 'configures the vlad rake tasks' do
108
- Nesta::Commands::New.new(project_root, 'vlad' => '').execute
79
+ Nesta::Commands::New.new(project_root, 'vlad' => '').execute(process_stub)
109
80
  assert_exists_in_project 'Rakefile'
110
81
  assert_match /require 'vlad'/, rakefile_source
111
82
  end
112
83
 
113
84
  it 'creates deploy.rb' do
114
- Nesta::Commands::New.new(project_root, 'vlad' => '').execute
85
+ Nesta::Commands::New.new(project_root, 'vlad' => '').execute(process_stub)
115
86
  assert_exists_in_project 'config/deploy.rb'
116
87
  deploy_source = File.read(project_path('config/deploy.rb'))
117
88
  assert_match /set :application, 'mysite.com'/, deploy_source
@@ -24,13 +24,16 @@ describe 'nesta plugin:create' do
24
24
  "nesta-plugin-#{plugin_name}"
25
25
  end
26
26
 
27
+ def process_stub
28
+ Object.new.tap do |stub|
29
+ def stub.run(*args); end
30
+ end
31
+ end
32
+
27
33
  def create_plugin(&block)
28
34
  Dir.chdir(working_directory) do
29
35
  command = Nesta::Commands::Plugin::Create.new(plugin_name)
30
- command.stub(:run_process, nil) do
31
- command.execute
32
- yield
33
- end
36
+ command.execute(process_stub)
34
37
  end
35
38
  end
36
39
 
@@ -16,9 +16,15 @@ describe 'nesta theme:create' do
16
16
  remove_temp_directory
17
17
  end
18
18
 
19
+ def process_stub
20
+ Object.new.tap do |stub|
21
+ def stub.run(*args); end
22
+ end
23
+ end
24
+
19
25
  it 'creates default files in the theme directory' do
20
26
  Dir.chdir(project_root) do
21
- Nesta::Commands::Theme::Create.new('theme-name').execute
27
+ Nesta::Commands::Theme::Create.new('theme-name').execute(process_stub)
22
28
  end
23
29
  assert_exists_in_project theme_path('README.md')
24
30
  assert_exists_in_project theme_path('app.rb')
@@ -26,7 +32,7 @@ describe 'nesta theme:create' do
26
32
 
27
33
  it 'copies default view templates into views directory' do
28
34
  Dir.chdir(project_root) do
29
- Nesta::Commands::Theme::Create.new('theme-name').execute
35
+ Nesta::Commands::Theme::Create.new('theme-name').execute(process_stub)
30
36
  end
31
37
  %w(layout.haml page.haml master.sass).each do |template|
32
38
  assert_exists_in_project theme_path("views/#{template}")
@@ -13,9 +13,15 @@ describe 'nesta theme:enable' do
13
13
  remove_temp_directory
14
14
  end
15
15
 
16
+ def process_stub
17
+ Object.new.tap do |stub|
18
+ def stub.run(*args); end
19
+ end
20
+ end
21
+
16
22
  it 'enables the theme' do
17
23
  Dir.chdir(project_root) do
18
- Nesta::Commands::Theme::Enable.new('theme-name').execute
24
+ Nesta::Commands::Theme::Enable.new('theme-name').execute(process_stub)
19
25
  assert_match /^theme: theme-name/, File.read('config/config.yml')
20
26
  end
21
27
  end
@@ -1,9 +1,6 @@
1
1
  require 'test_helper'
2
- require_relative '../../../support/silence_commands_during_tests'
3
2
  require_relative '../../../../lib/nesta/commands'
4
3
 
5
- Nesta::Commands::Theme::Install.send(:include, SilenceCommandsDuringTests)
6
-
7
4
  describe 'nesta theme:install' do
8
5
  include TemporaryFiles
9
6
 
@@ -27,35 +24,42 @@ describe 'nesta theme:install' do
27
24
  remove_temp_directory
28
25
  end
29
26
 
27
+ def process_stub
28
+ Object.new.tap do |stub|
29
+ def stub.run(*args); end
30
+ end
31
+ end
32
+
30
33
  it 'clones the repository' do
34
+ process = Minitest::Mock.new
35
+ process.expect(:run, true, ['git', 'clone', repo_url, "themes/#{theme_name}"])
31
36
  in_temporary_project do
32
- Nesta::Commands::Theme::Install.new(repo_url).execute
33
- assert File.directory?(theme_dir), 'theme not cloned'
37
+ Nesta::Commands::Theme::Install.new(repo_url).execute(process)
34
38
  end
35
39
  end
36
40
 
37
41
  it "removes the theme's .git directory" do
38
42
  in_temporary_project do
39
- Nesta::Commands::Theme::Install.new(repo_url).execute
43
+ Nesta::Commands::Theme::Install.new(repo_url).execute(process_stub)
40
44
  refute File.exist?("#{theme_dir}/.git"), '.git folder found'
41
45
  end
42
46
  end
43
47
 
44
48
  it 'enables the freshly installed theme' do
45
49
  in_temporary_project do
46
- Nesta::Commands::Theme::Install.new(repo_url).execute
50
+ Nesta::Commands::Theme::Install.new(repo_url).execute(process_stub)
47
51
  assert_match /theme: #{theme_name}/, File.read('config/config.yml')
48
52
  end
49
53
  end
50
54
 
51
55
  it 'determines name of theme from name of repository' do
52
- url = 'git://foobar.com/path/to/nesta-theme-the-name.git'
56
+ url = 'https://foobar.com/path/to/nesta-theme-the-name.git'
53
57
  command = Nesta::Commands::Theme::Install.new(url)
54
58
  assert_equal 'the-name', command.theme_name
55
59
  end
56
60
 
57
61
  it "falls back to name of repo when theme name doesn't match correct format" do
58
- url = 'git://foobar.com/path/to/mytheme.git'
62
+ url = 'https://foobar.com/path/to/mytheme.git'
59
63
  command = Nesta::Commands::Theme::Install.new(url)
60
64
  assert_equal 'mytheme', command.theme_name
61
65
  end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+ require_relative '../../lib/nesta/system_command'
3
+
4
+ describe 'Nesta::SystemCommand' do
5
+ describe '#run' do
6
+ it 'catches errors when running external processes' do
7
+ command = Nesta::SystemCommand.new
8
+ command.run('ls / >/dev/null')
9
+ begin
10
+ stderr, $stderr = $stderr, StringIO.new
11
+ assert_raises(SystemExit) do
12
+ command.run('ls no-such-file 2>/dev/null')
13
+ end
14
+ ensure
15
+ $stderr.close
16
+ $stderr = stderr
17
+ end
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nesta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham Ashton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-30 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: haml-contrib
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -225,11 +231,9 @@ executables:
225
231
  extensions: []
226
232
  extra_rdoc_files: []
227
233
  files:
234
+ - ".github/workflows/tests.yml"
228
235
  - ".gitignore"
229
236
  - ".gitmodules"
230
- - ".hound.yml"
231
- - ".rspec"
232
- - ".travis.yml"
233
237
  - CHANGES
234
238
  - Gemfile
235
239
  - Gemfile.lock
@@ -244,18 +248,19 @@ files:
244
248
  - lib/nesta.rb
245
249
  - lib/nesta/app.rb
246
250
  - lib/nesta/commands.rb
247
- - lib/nesta/commands/command.rb
248
251
  - lib/nesta/commands/demo.rb
249
252
  - lib/nesta/commands/demo/content.rb
250
253
  - lib/nesta/commands/edit.rb
251
254
  - lib/nesta/commands/new.rb
252
255
  - lib/nesta/commands/plugin.rb
253
256
  - lib/nesta/commands/plugin/create.rb
257
+ - lib/nesta/commands/template.rb
254
258
  - lib/nesta/commands/theme.rb
255
259
  - lib/nesta/commands/theme/create.rb
256
260
  - lib/nesta/commands/theme/enable.rb
257
261
  - lib/nesta/commands/theme/install.rb
258
262
  - lib/nesta/config.rb
263
+ - lib/nesta/config_file.rb
259
264
  - lib/nesta/env.rb
260
265
  - lib/nesta/helpers.rb
261
266
  - lib/nesta/models.rb
@@ -263,6 +268,7 @@ files:
263
268
  - lib/nesta/overrides.rb
264
269
  - lib/nesta/path.rb
265
270
  - lib/nesta/plugin.rb
271
+ - lib/nesta/system_command.rb
266
272
  - lib/nesta/version.rb
267
273
  - nesta.gemspec
268
274
  - scripts/import-from-mephisto
@@ -305,17 +311,16 @@ files:
305
311
  - test/integration/sitemap_test.rb
306
312
  - test/integration_test_helper.rb
307
313
  - test/support/model_factory.rb
308
- - test/support/silence_commands_during_tests.rb
309
314
  - test/support/temporary_files.rb
310
315
  - test/support/test_configuration.rb
311
316
  - test/test_helper.rb
312
- - test/unit/commands_test.rb
313
317
  - test/unit/config_test.rb
314
318
  - test/unit/file_model_test.rb
315
319
  - test/unit/menu_test.rb
316
320
  - test/unit/page_test.rb
317
321
  - test/unit/path_test.rb
318
322
  - test/unit/plugin_test.rb
323
+ - test/unit/system_command_test.rb
319
324
  - views/analytics.haml
320
325
  - views/atom.haml
321
326
  - views/categories.haml
@@ -353,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
353
358
  - !ruby/object:Gem::Version
354
359
  version: '0'
355
360
  requirements: []
356
- rubygems_version: 3.1.2
361
+ rubygems_version: 3.3.7
357
362
  signing_key:
358
363
  specification_version: 4
359
364
  summary: Ruby CMS, written in Sinatra
data/.hound.yml DELETED
@@ -1,2 +0,0 @@
1
- ruby:
2
- enabled: true
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5
4
- - 2.6
5
- - 2.7
6
- before_script:
7
- - git config --global user.email "continuous-integration@nestacms.com"
8
- - git config --global user.name "Nesta CI"
9
- script: bundle exec rake test
10
- env:
11
- - REPORTER=default
@@ -1,57 +0,0 @@
1
- module Nesta
2
- module Commands
3
- class UsageError < RuntimeError; end
4
-
5
- module Command
6
- def run_process(*args)
7
- system(*args)
8
- if ! $?.success?
9
- message = if $?.exitstatus == 127
10
- "#{args[0]} not found"
11
- else
12
- "'#{args.join(' ')}' failed with status #{$?.exitstatus}"
13
- end
14
- fail(message)
15
- end
16
- end
17
-
18
- def fail(message)
19
- $stderr.puts "Error: #{message}"
20
- exit 1
21
- end
22
-
23
- def template_root
24
- File.expand_path('../../../templates', File.dirname(__FILE__))
25
- end
26
-
27
- def copy_template(src, dest)
28
- FileUtils.mkdir_p(File.dirname(dest))
29
- template = ERB.new(File.read(File.join(template_root, src)), nil, "-")
30
- File.open(dest, 'w') { |file| file.puts template.result(binding) }
31
- end
32
-
33
- def copy_templates(templates)
34
- templates.each { |src, dest| copy_template(src, dest) }
35
- end
36
-
37
- def update_config_yaml(pattern, replacement)
38
- configured = false
39
- File.open(Nesta::Config.yaml_path, 'r+') do |file|
40
- output = ''
41
- file.each_line do |line|
42
- if configured
43
- output << line
44
- else
45
- output << line.sub(pattern, replacement)
46
- configured = true if line =~ pattern
47
- end
48
- end
49
- output << "#{replacement}\n" unless configured
50
- file.pos = 0
51
- file.print(output)
52
- file.truncate(file.pos)
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,5 +0,0 @@
1
- module SilenceCommandsDuringTests
2
- def run_process(*args)
3
- super(*args, out: '/dev/null', err: '/dev/null')
4
- end
5
- end
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
- require_relative '../../lib/nesta/commands'
3
-
4
- class TestCommand
5
- include Nesta::Commands::Command
6
- end
7
-
8
- describe 'Nesta::Commands::Command' do
9
- describe '#run_process' do
10
- it 'catches errors when running external processes' do
11
- TestCommand.new.run_process('ls / >/dev/null')
12
- begin
13
- stderr, $stderr = $stderr, File.open('/dev/null', 'w')
14
- assert_raises(SystemExit) do
15
- TestCommand.new.run_process('ls no-such-file 2>/dev/null')
16
- end
17
- ensure
18
- $stderr.close
19
- $stderr = stderr
20
- end
21
- end
22
- end
23
- end