nesta 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/tests.yml +21 -0
  3. data/.gitmodules +0 -0
  4. data/CHANGES +44 -2
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +73 -55
  7. data/LICENSE +1 -1
  8. data/README.md +7 -14
  9. data/RELEASING.md +10 -9
  10. data/Rakefile +20 -3
  11. data/bin/nesta +1 -1
  12. data/config/deploy.rb.sample +1 -1
  13. data/lib/nesta/app.rb +4 -8
  14. data/lib/nesta/commands/demo/content.rb +28 -12
  15. data/lib/nesta/commands/edit.rb +2 -6
  16. data/lib/nesta/commands/new.rb +9 -11
  17. data/lib/nesta/commands/plugin/create.rb +7 -9
  18. data/lib/nesta/commands/template.rb +20 -0
  19. data/lib/nesta/commands/theme/create.rb +8 -8
  20. data/lib/nesta/commands/theme/enable.rb +3 -5
  21. data/lib/nesta/commands/theme/install.rb +12 -14
  22. data/lib/nesta/commands.rb +8 -0
  23. data/lib/nesta/config_file.rb +25 -0
  24. data/lib/nesta/helpers.rb +14 -0
  25. data/lib/nesta/models.rb +26 -22
  26. data/lib/nesta/navigation.rb +1 -1
  27. data/lib/nesta/system_command.rb +15 -0
  28. data/lib/nesta/version.rb +1 -1
  29. data/lib/nesta.rb +6 -1
  30. data/nesta.gemspec +11 -12
  31. data/templates/config/config.yml +1 -1
  32. data/{spec → test}/fixtures/nesta-plugin-test/Gemfile +0 -0
  33. data/{spec → test}/fixtures/nesta-plugin-test/Rakefile +0 -0
  34. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +0 -0
  35. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/version.rb +0 -0
  36. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test.rb +0 -0
  37. data/{spec → test}/fixtures/nesta-plugin-test/nesta-plugin-test.gemspec +0 -0
  38. data/test/integration/atom_feed_test.rb +178 -0
  39. data/test/integration/commands/demo/content_test.rb +33 -0
  40. data/test/integration/commands/edit_test.rb +21 -0
  41. data/test/integration/commands/new_test.rb +91 -0
  42. data/test/integration/commands/plugin/create_test.rb +131 -0
  43. data/test/integration/commands/theme/create_test.rb +41 -0
  44. data/test/integration/commands/theme/enable_test.rb +28 -0
  45. data/test/integration/commands/theme/install_test.rb +66 -0
  46. data/test/integration/default_theme_test.rb +220 -0
  47. data/test/integration/overrides_test.rb +118 -0
  48. data/test/integration/route_handlers_test.rb +96 -0
  49. data/test/integration/sitemap_test.rb +85 -0
  50. data/test/integration_test_helper.rb +61 -0
  51. data/test/support/model_factory.rb +169 -0
  52. data/test/support/temporary_files.rb +33 -0
  53. data/test/support/test_configuration.rb +19 -0
  54. data/test/test_helper.rb +26 -0
  55. data/test/unit/config_test.rb +138 -0
  56. data/test/unit/file_model_test.rb +71 -0
  57. data/test/unit/menu_test.rb +82 -0
  58. data/test/unit/page_test.rb +571 -0
  59. data/test/unit/path_test.rb +41 -0
  60. data/test/unit/plugin_test.rb +47 -0
  61. data/test/unit/system_command_test.rb +20 -0
  62. data/views/master.sass +1 -1
  63. metadata +90 -89
  64. data/.hound.yml +0 -2
  65. data/.rspec +0 -1
  66. data/.travis.yml +0 -6
  67. data/lib/nesta/commands/command.rb +0 -58
  68. data/smoke-test.sh +0 -107
  69. data/spec/atom_spec.rb +0 -141
  70. data/spec/commands/demo/content_spec.rb +0 -65
  71. data/spec/commands/edit_spec.rb +0 -27
  72. data/spec/commands/new_spec.rb +0 -88
  73. data/spec/commands/plugin/create_spec.rb +0 -97
  74. data/spec/commands/system_spec.rb +0 -25
  75. data/spec/commands/theme/create_spec.rb +0 -41
  76. data/spec/commands/theme/enable_spec.rb +0 -44
  77. data/spec/commands/theme/install_spec.rb +0 -56
  78. data/spec/config_spec.rb +0 -127
  79. data/spec/model_factory.rb +0 -92
  80. data/spec/models_spec.rb +0 -700
  81. data/spec/overrides_spec.rb +0 -132
  82. data/spec/page_spec.rb +0 -560
  83. data/spec/path_spec.rb +0 -28
  84. data/spec/plugin_spec.rb +0 -51
  85. data/spec/sitemap_spec.rb +0 -105
  86. data/spec/spec_helper.rb +0 -114
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f7a279baf5e3392482afcd20db4e9a0dad93bd96
4
- data.tar.gz: 99e8396b1cf4d3895adab3cf9290845bd7142ee8
2
+ SHA256:
3
+ metadata.gz: e80fef7e8fe518a674eb7527d91410d162fca8288985971e641a3329ae192eef
4
+ data.tar.gz: bc6f671dc4f0ae10b403fa53b489f06c74ae8e9c6560ae49e08dc2518185dc22
5
5
  SHA512:
6
- metadata.gz: 66f8714a375bc4cf7e801ca9f8f1f6f24a103736763a4b87e850c58ff983344999543e260b1dbb3add73a8ebae935e08109828fac06a649c4958fb9c3f2c2c8c
7
- data.tar.gz: 44ee76299e95a5a329fc8fd6679d8d3be9d7a0eac5c4ef321029c7038b56024ed100a0890937ba045dc46836e96ca1c6d7f3f023b4f0d0444b85a84c69e53b34
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 ADDED
File without changes
data/CHANGES CHANGED
@@ -1,3 +1,45 @@
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
+
27
+ = 0.12.0 / (30 June 2020)
28
+
29
+ * Upgrade to Sinatra 2 and Rack 2. (Graham Ashton)
30
+
31
+ * Upgrade from tilt 1.4 to 2.0. (Graham Ashton)
32
+
33
+ * Replace the deprecated sass gem with sassc. (Brad Weslake)
34
+
35
+ * Port the test suite from RSpec and Webrat to Minitest and Capybara.
36
+ (Graham Ashton)
37
+
38
+ * Silence deprecation warnings produced under Ruby 2.7. (Graham Ashton)
39
+
40
+ * Stop running the test suite under Ruby 2.3 and 2.4, both of which
41
+ have reached end-of-life. (Graham Ashton)
42
+
1
43
  = 0.11.1 / (26 March 2015)
2
44
 
3
45
  * Tighten dependency on Tilt, as version 2.x is incompatible.
@@ -288,7 +330,7 @@
288
330
  * Bug fix: The Sinatra app's root directory wasn't set which meant
289
331
  that Nesta couldn't always find the ./public directory (such as when
290
332
  running on Heroku).
291
-
333
+
292
334
  The modifications made in 0.9.6 to make Nesta easier to mount inside
293
335
  another Rack application moved Nesta::App.root to the (new)
294
336
  Nesta::Env class. In 0.9.6 I forgot to actually set Nesta::App.root
@@ -360,7 +402,7 @@
360
402
 
361
403
  = 0.9.3 / 18 January 2011
362
404
 
363
- * The route and view for serving the home page (/) has been removed,
405
+ * The route and view for serving the home page (/) has been removed,
364
406
  and the home page must now be created as an index page in
365
407
  content/pages.
366
408
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in nesta.gemspec
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,86 +1,104 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nesta (0.11.1)
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
- rack (>= 1.3)
8
+ rack (~> 2.0)
9
9
  rdiscount (~> 2.1)
10
- sass (>= 3.1)
11
- sinatra (~> 1.4)
12
- tilt (~> 1.4)
10
+ sassc (>= 2.2)
11
+ sinatra (~> 2.0)
12
+ tilt (~> 2.0)
13
13
 
14
14
  GEM
15
- remote: http://rubygems.org/
15
+ remote: https://rubygems.org/
16
16
  specs:
17
- RedCloth (4.2.9)
18
- diff-lcs (1.2.5)
19
- ffi (1.9.8)
20
- haml (4.0.6)
17
+ RedCloth (4.3.2)
18
+ addressable (2.8.1)
19
+ public_suffix (>= 2.0.2, < 6.0)
20
+ ansi (1.5.0)
21
+ builder (3.2.4)
22
+ byebug (11.1.3)
23
+ capybara (2.18.0)
24
+ addressable
25
+ mini_mime (>= 0.1.3)
26
+ nokogiri (>= 1.3.3)
27
+ rack (>= 1.0.0)
28
+ rack-test (>= 0.5.4)
29
+ xpath (>= 2.0, < 4.0)
30
+ ffi (1.15.5)
31
+ haml (5.2.2)
32
+ temple (>= 0.8.0)
21
33
  tilt
22
34
  haml-contrib (1.0.0.1)
23
35
  haml (>= 3.2.0.alpha.13)
24
- hoe (3.13.1)
25
- rake (>= 0.8, < 11.0)
26
- kgio (2.9.3)
36
+ kgio (2.11.4)
27
37
  listen (1.3.1)
28
38
  rb-fsevent (>= 0.9.3)
29
39
  rb-inotify (>= 0.9)
30
40
  rb-kqueue (>= 0.2)
31
- mini_portile (0.6.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
+ ansi
46
+ builder
47
+ minitest (>= 5.0)
48
+ ruby-progressbar
32
49
  mr-sparkle (0.3.0)
33
50
  listen (~> 1.0)
34
51
  rb-fsevent (>= 0.9)
35
52
  rb-inotify (>= 0.8)
36
53
  unicorn (>= 4.5)
37
- nokogiri (1.6.6.2)
38
- mini_portile (~> 0.6.0)
39
- rack (1.6.0)
40
- rack-protection (1.5.3)
54
+ mustermann (2.0.2)
55
+ ruby2_keywords (~> 0.0.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)
41
63
  rack
42
- rack-test (0.6.1)
43
- rack (>= 1.0)
44
- raindrops (0.13.0)
45
- rake (10.4.2)
46
- rb-fsevent (0.9.4)
47
- rb-inotify (0.9.5)
48
- ffi (>= 0.5.0)
49
- rb-kqueue (0.2.3)
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)
69
+ rb-inotify (0.10.1)
70
+ ffi (~> 1.0)
71
+ rb-kqueue (0.2.8)
50
72
  ffi (>= 0.5.0)
51
- rdiscount (2.1.8)
52
- rspec (2.14.1)
53
- rspec-core (~> 2.14.0)
54
- rspec-expectations (~> 2.14.0)
55
- rspec-mocks (~> 2.14.0)
56
- rspec-core (2.14.8)
57
- rspec-expectations (2.14.5)
58
- diff-lcs (>= 1.1.3, < 2.0)
59
- rspec-mocks (2.14.6)
60
- sass (3.4.13)
61
- sinatra (1.4.5)
62
- rack (~> 1.4)
63
- rack-protection (~> 1.4)
64
- tilt (>= 1.3, < 3)
65
- test-unit (1.2.3)
66
- hoe (>= 1.5.1)
67
- tilt (1.4.1)
68
- unicorn (4.8.3)
73
+ rdiscount (2.2.0.2)
74
+ ruby-progressbar (1.11.0)
75
+ ruby2_keywords (0.0.5)
76
+ sassc (2.4.0)
77
+ ffi (~> 1.9)
78
+ sinatra (2.2.2)
79
+ mustermann (~> 2.0)
80
+ rack (~> 2.2)
81
+ rack-protection (= 2.2.2)
82
+ tilt (~> 2.0)
83
+ temple (0.8.2)
84
+ tilt (2.0.11)
85
+ unicorn (6.1.0)
69
86
  kgio (~> 2.6)
70
- rack
71
87
  raindrops (~> 0.7)
72
- webrat (0.7.3)
73
- nokogiri (>= 1.2.0)
74
- rack (>= 1.0)
75
- rack-test (>= 0.5.3)
88
+ xpath (3.2.0)
89
+ nokogiri (~> 1.8)
76
90
 
77
91
  PLATFORMS
78
92
  ruby
79
93
 
80
94
  DEPENDENCIES
81
- mr-sparkle (>= 0.0.2)
95
+ byebug
96
+ capybara (~> 2.0)
97
+ minitest (~> 5.0)
98
+ minitest-reporters
99
+ mr-sparkle
82
100
  nesta!
83
- rack-test (= 0.6.1)
84
- rspec (~> 2.14.0)
85
- test-unit (= 1.2.3)
86
- webrat (~> 0.7.3)
101
+ rake
102
+
103
+ BUNDLED WITH
104
+ 2.3.14
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2014 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,20 +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. Update the versions of Ruby used in `.travis.yml` and
14
- `smoke-test.sh`. If not, commit and push. Verify that all relevant
15
- versions of Ruby have been installed locally, with `chruby`.
16
+ 4. Commit these changes with a commit message of 'Bump version to <version>'
16
17
 
17
- 4. Run `smoke-test.sh`.
18
+ 5. Generate a new site with the `nesta` command, install the demo content,
19
+ check that it runs okay locally.
18
20
 
19
- 5. Once you're confident the freshly generated sites work okay in the
20
- previous step, run `rake release`.
21
+ 6. If everything seems fine, run `rake release`.
21
22
 
22
- 6. Publish an announcement blog post and email the list.
23
+ 7. Publish an announcement blog post and email the list.
data/Rakefile CHANGED
@@ -5,7 +5,24 @@ Bundler.require(:default, :test)
5
5
 
6
6
  Bundler::GemHelper.install_tasks
7
7
 
8
- require 'rspec/core/rake_task'
9
- RSpec::Core::RakeTask.new(:spec)
8
+ namespace :test do
9
+ task :set_load_path do
10
+ $LOAD_PATH.unshift File.expand_path('test')
11
+ end
10
12
 
11
- task :default => :spec
13
+ def load_tests(directory)
14
+ Rake::FileList["test/#{directory}/*_test.rb"].each { |f| require_relative f }
15
+ end
16
+
17
+ task units: :set_load_path do
18
+ load_tests('unit/**')
19
+ end
20
+
21
+ task integrations: :set_load_path do
22
+ load_tests('integration/**')
23
+ end
24
+ end
25
+
26
+ task test: 'test:set_load_path' do
27
+ load_tests('**')
28
+ end
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
data/lib/nesta/app.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'sinatra/base'
2
2
  require 'haml'
3
- require 'sass'
3
+ require 'sassc'
4
4
 
5
5
  require File.expand_path('../nesta', File.dirname(__FILE__))
6
6
  require File.expand_path('env', File.dirname(__FILE__))
@@ -55,13 +55,9 @@ module Nesta
55
55
  stylesheet(params[:sheet].to_sym)
56
56
  end
57
57
 
58
- get %r{/attachments/([\w/.@-]+)} do |file|
59
- file = File.join(Nesta::Config.attachment_path, params[:captures].first)
60
- if file =~ /\.\.\//
61
- not_found
62
- else
63
- send_file(file, disposition: nil)
64
- end
58
+ get '/attachments/*' do |path|
59
+ filename = File.join(Nesta::Config.attachment_path, path)
60
+ send_file(filename, disposition: nil)
65
61
  end
66
62
 
67
63
  get '/articles.xml' do
@@ -1,36 +1,52 @@
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
7
+ @demo_repository = 'https://github.com/gma/nesta-demo-content.git'
8
+ class << self
9
+ attr_accessor :demo_repository
10
+ end
8
11
 
9
12
  def initialize(*args)
10
13
  @dir = 'content-demo'
11
14
  end
12
15
 
13
- def clone_or_update_repository
14
- repository = 'git://github.com/gma/nesta-demo-content.git'
16
+ def clone_or_update_repository(process)
15
17
  path = Nesta::Path.local(@dir)
16
18
  if File.exist?(path)
17
- FileUtils.cd(path) { run_process('git', 'pull', 'origin', 'master') }
19
+ FileUtils.cd(path) { process.run('git', 'pull', 'origin', 'master') }
18
20
  else
19
- run_process('git', 'clone', repository, path)
21
+ process.run('git', 'clone', self.class.demo_repository, path)
20
22
  end
21
23
  end
22
24
 
25
+ def exclude_path
26
+ Nesta::Path.local('.git/info/exclude')
27
+ end
28
+
29
+ def in_git_repo?
30
+ File.directory?(Nesta::Path.local('.git'))
31
+ end
32
+
33
+ def demo_repo_ignored?
34
+ File.read(exclude_path).split.any? { |line| line == @dir }
35
+ rescue Errno::ENOENT
36
+ false
37
+ end
38
+
23
39
  def configure_git_to_ignore_repo
24
- excludes = Nesta::Path.local('.git/info/exclude')
25
- if File.exist?(excludes) && File.read(excludes).scan(@dir).empty?
26
- File.open(excludes, 'a') { |file| file.puts @dir }
40
+ if in_git_repo? && ! demo_repo_ignored?
41
+ FileUtils.mkdir_p(File.dirname(exclude_path))
42
+ File.open(exclude_path, 'a') { |file| file.puts @dir }
27
43
  end
28
44
  end
29
45
 
30
- def execute
31
- clone_or_update_repository
46
+ def execute(process)
47
+ clone_or_update_repository(process)
32
48
  configure_git_to_ignore_repo
33
- update_config_yaml(/^\s*#?\s*content:.*/, "content: #{@dir}")
49
+ Nesta::ConfigFile.new.set_value('content', @dir)
34
50
  end
35
51
  end
36
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