jdt 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +2 -0
  3. data/CHANGELOG.md +1 -0
  4. data/Gemfile +9 -0
  5. data/Gemfile.lock +64 -0
  6. data/LICENSE +7 -0
  7. data/README.md +101 -0
  8. data/Rakefile +2 -0
  9. data/bin/jdt +16 -0
  10. data/features/build.feature +0 -0
  11. data/features/manifest.feature +25 -0
  12. data/features/new.feature +97 -0
  13. data/features/release.feature +47 -0
  14. data/features/status.feature +22 -0
  15. data/features/step_definitions/my_steps.rb +37 -0
  16. data/features/support/env.rb +7 -0
  17. data/features/support/setup.rb +2 -0
  18. data/features/validate.feature +0 -0
  19. data/features/version.feature +9 -0
  20. data/jdt.gemspec +25 -0
  21. data/lib/jdt/cli.rb +34 -0
  22. data/lib/jdt/commands/build.rb +28 -0
  23. data/lib/jdt/commands/bump.rb +37 -0
  24. data/lib/jdt/commands/install.rb +20 -0
  25. data/lib/jdt/commands/new.rb +31 -0
  26. data/lib/jdt/commands/pretty_print.rb +16 -0
  27. data/lib/jdt/commands/secure.rb +19 -0
  28. data/lib/jdt/commands/status.rb +21 -0
  29. data/lib/jdt/commands/validate.rb +35 -0
  30. data/lib/jdt/commands/version.rb +18 -0
  31. data/lib/jdt/generator/generator.rb +262 -0
  32. data/lib/jdt/generator/templates/access.xml.erb +10 -0
  33. data/lib/jdt/generator/templates/component/admin/access.xml.erb +0 -0
  34. data/lib/jdt/generator/templates/component/admin/com_name.erb +0 -0
  35. data/lib/jdt/generator/templates/component/admin/config.xml.erb +0 -0
  36. data/lib/jdt/generator/templates/component/admin/controller.erb +0 -0
  37. data/lib/jdt/generator/templates/component/admin/views/view_name/tmpl/default.erb +0 -0
  38. data/lib/jdt/generator/templates/component/admin/views/view_name/view.html.erb +0 -0
  39. data/lib/jdt/generator/templates/component/index.html.erb +1 -0
  40. data/lib/jdt/generator/templates/component/manifest.xml.erb +46 -0
  41. data/lib/jdt/generator/templates/component/script.php.erb +66 -0
  42. data/lib/jdt/generator/templates/component/site/com_name.php.erb +15 -0
  43. data/lib/jdt/generator/templates/component/site/controller.php.erb +14 -0
  44. data/lib/jdt/generator/templates/component/site/models/com_model_name.erb +0 -0
  45. data/lib/jdt/generator/templates/component/site/views/view_name/tmpl/default.php.erb +0 -0
  46. data/lib/jdt/generator/templates/component/site/views/view_name/tmpl/default.xml.erb +0 -0
  47. data/lib/jdt/generator/templates/component/site/views/view_name/view.html.erb +0 -0
  48. data/lib/jdt/generator/templates/config.xml.erb +6 -0
  49. data/lib/jdt/generator/templates/controller.php.erb +13 -0
  50. data/lib/jdt/generator/templates/dummy_html.erb +1 -0
  51. data/lib/jdt/generator/templates/entry.erb +15 -0
  52. data/lib/jdt/generator/templates/manifest.xml.erb +59 -0
  53. data/lib/jdt/generator/templates/module/helper.php.erb +14 -0
  54. data/lib/jdt/generator/templates/module/manifest.xml.erb +16 -0
  55. data/lib/jdt/generator/templates/module/mod_name.php.erb +10 -0
  56. data/lib/jdt/generator/templates/module/tmpl/default.php.erb +3 -0
  57. data/lib/jdt/generator/templates/plugin/main.php.erb +0 -0
  58. data/lib/jdt/generator/templates/plugin/manifest.xml.erb +16 -0
  59. data/lib/jdt/generator/templates/script.php.erb +66 -0
  60. data/lib/jdt/generator.rb +1 -0
  61. data/lib/jdt/manifest/attributes.rb +77 -0
  62. data/lib/jdt/manifest/build.rb +106 -0
  63. data/lib/jdt/manifest/bump.rb +40 -0
  64. data/lib/jdt/manifest/find.rb +58 -0
  65. data/lib/jdt/manifest/library_manifest.rb +19 -0
  66. data/lib/jdt/manifest/manifest.rb +29 -0
  67. data/lib/jdt/manifest/referenced.rb +96 -0
  68. data/lib/jdt/manifest/schemas/library.xsd +80 -0
  69. data/lib/jdt/manifest/schemas/manifest.xsd +32 -0
  70. data/lib/jdt/manifest/secure.rb +39 -0
  71. data/lib/jdt/manifest/validation.rb +121 -0
  72. data/lib/jdt/manifest/xslts/pretty_print.xsl +46 -0
  73. data/lib/jdt/manifest.rb +9 -0
  74. data/lib/jdt/version.rb +3 -0
  75. data/lib/jdt.rb +0 -0
  76. data/lib/not_yet_added/deploy.rb +54 -0
  77. data/lib/not_yet_added/xampp.rb +82 -0
  78. data/spec/jdt/generator/generator_spec.rb +55 -0
  79. data/spec/jdt/manifest/data/example_library/.gitignore +1 -0
  80. data/spec/jdt/manifest/data/example_library/ActiveRecord.php +3 -0
  81. data/spec/jdt/manifest/data/example_library/JoomlaActiveRecord.php +56 -0
  82. data/spec/jdt/manifest/data/example_library/JoomlaConfig.php +42 -0
  83. data/spec/jdt/manifest/data/example_library/README.md +51 -0
  84. data/spec/jdt/manifest/data/example_library/dist/asdf.txt +0 -0
  85. data/spec/jdt/manifest/data/example_library/manifest.xml +22 -0
  86. data/spec/jdt/manifest/data/library.xml +33 -0
  87. data/spec/jdt/manifest/data/library_error.xml +23 -0
  88. data/spec/jdt/manifest/data/library_minimum.xml +11 -0
  89. data/spec/jdt/manifest/data/manifest.xml +4 -0
  90. data/spec/jdt/manifest/example_library_spec.rb +27 -0
  91. data/spec/jdt/manifest/finder_spec.rb +58 -0
  92. data/spec/jdt/manifest/library_manifest_spec.rb +17 -0
  93. data/spec/jdt/manifest/manifest_spec.rb +68 -0
  94. data/spec/jdt/manifest/referenced_spec.rb +28 -0
  95. data/spec/jdt/manifest/secure_spec.rb +42 -0
  96. data/spec/jdt/manifest/validation_spec.rb +45 -0
  97. data/spec/jdt/version_spec.rb +9 -0
  98. metadata +211 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .idea
2
+ # ignore this
3
+ /pkg/
4
+ *.gem
5
+ /tmp/
6
+ .bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format nested
2
+ --color
data/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # Here come the changes that were made by specific versions
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jdt.gemspec
4
+ gemspec
5
+
6
+ gem "thor"
7
+ gem "rspec"
8
+ gem "nokogiri"
9
+ gem "rake"
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jdt (0.0.2)
5
+ nokogiri
6
+ rubyzip
7
+ thor
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ aruba (0.4.6)
13
+ bcat (>= 0.6.1)
14
+ childprocess (>= 0.2.0)
15
+ cucumber (>= 1.0.2)
16
+ rspec (>= 2.6.0)
17
+ bcat (0.6.1)
18
+ rack (~> 1.0)
19
+ builder (3.0.0)
20
+ childprocess (0.2.2)
21
+ ffi (~> 1.0.6)
22
+ cucumber (1.0.2)
23
+ builder (>= 2.1.2)
24
+ diff-lcs (>= 1.1.2)
25
+ gherkin (~> 2.4.5)
26
+ json (>= 1.4.6)
27
+ term-ansicolor (>= 1.0.5)
28
+ diff-lcs (1.1.3)
29
+ ffi (1.0.9-java)
30
+ ffi (1.0.9-x86-mingw32)
31
+ gherkin (2.4.18-java)
32
+ json (>= 1.4.6)
33
+ gherkin (2.4.18-x86-mingw32)
34
+ json (>= 1.4.6)
35
+ json (1.5.4)
36
+ json (1.5.4-java)
37
+ nokogiri (1.5.0-java)
38
+ nokogiri (1.5.0-x86-mingw32)
39
+ rack (1.3.2)
40
+ rake (0.9.2)
41
+ rspec (2.6.0)
42
+ rspec-core (~> 2.6.0)
43
+ rspec-expectations (~> 2.6.0)
44
+ rspec-mocks (~> 2.6.0)
45
+ rspec-core (2.6.4)
46
+ rspec-expectations (2.6.0)
47
+ diff-lcs (~> 1.1.2)
48
+ rspec-mocks (2.6.0)
49
+ rubyzip (0.9.4)
50
+ term-ansicolor (1.0.6)
51
+ thor (0.14.6)
52
+
53
+ PLATFORMS
54
+ java
55
+ x86-mingw32
56
+
57
+ DEPENDENCIES
58
+ aruba
59
+ cucumber
60
+ jdt!
61
+ nokogiri
62
+ rake
63
+ rspec
64
+ thor
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2011 Feki.de e.V.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # Abstract
2
+ The **Joomla Development Tool** (short: **jdt**) is a command line tool to easen the development of extensions for [Joomla! CMS](http://www.joomla.org/). It tries to bring the command line facilities of other famous web frameworks like [Rails](http://rubyonrails.org/) to [Joomla!](http://www.joomla.org/).
3
+
4
+ # Features
5
+
6
+ - `status` (shows the current extension type, name, version, author, etc.)
7
+ - `new TYPE NAME` (bootstraps a Joomla! extension, e.g. a component)
8
+ - `version` (version of the JDT)
9
+ - `build` (creates zip file for deployment, with timestamp)
10
+ - `release` (creates zip file for deployment)
11
+ - `bump` (increments either --patch, --minor or --major version, --patch is default)
12
+
13
+ (NOT YET IMPLEMENTED)
14
+
15
+ - `clean` (removes the `/zip` and the `/.jdt` directories)
16
+ - `install` (installs the extension at a Joomla! instance)
17
+ - `uninstall` (uninstalls the extension from a Joomla! instance)
18
+ - `install-jdump` (installs JDump at a Joomla! instance)
19
+ - `uninstall-jdump` (uninstall JDump from a Joomla! instance)
20
+ - `sync` (copy the files to a local Joomla! installation, once or continously)
21
+ - `scaffold` (create models, controllers, views with default data)
22
+ - `test` (executes unit and integration tests)
23
+ - `xampp` (starts and stops xampp, open Joomla in browser)
24
+ - `open` (open the Extension in Browser)
25
+
26
+ # Are additional files being created within my extension?
27
+
28
+ Yes.
29
+
30
+ * `/zip` stores your deployable zip files of your extension
31
+ * `/.jdt` caches deployment information (NOT YET IMPLEMENTED)
32
+
33
+ However, these can be deleted by issuing the `jdt clean` command. (NOT YET IMPLEMENTED)
34
+
35
+ # Can I use it for Joomla 1.5 development?
36
+ No, only Joomla 1.6 development is supported. This is due to the change of the manifest structure.
37
+
38
+ # Installation Instructions
39
+
40
+ (NOT YET IMPLEMENTED)
41
+
42
+ The installation is pretty simple. You need either [JRuby](http://www.jruby.org) oder [Ruby](http://www.ruby-lang.org). After that, you can easily install the JDT using the following command:
43
+
44
+ 1. `gem install jdt`
45
+
46
+ The tool is then useable in the command line using `$> jdt`
47
+
48
+ # Development Instructions
49
+
50
+ Make sure that you have [RubyGems](https://rubygems.org/) 1.8.9 installed (gem update --system 1.8.9).
51
+
52
+ 1. clone the repository
53
+
54
+ `git clone https://www.github.com/simonharrer/joomlatools.git`
55
+
56
+ 2. install the following gems: [ZenTest](https://github.com/seattlerb/zentest), [gem-release](https://github.com/svenfuchs/gem-release), [bundler](http://gembundler.com/)
57
+
58
+ * `gem install ZenTest`
59
+ * `gem install gem-release`
60
+ * `gem install bundle`
61
+
62
+ 3. `bundle` (installs all required gems defined by the gem specification)
63
+ 4. `autotest` (to execute the tests, continously)
64
+
65
+ ## Testing
66
+ Testing is done using cucumber with aruba for testing the command line interface.
67
+
68
+ ### Acceptance and Integration Tests
69
+ The acceptance and integration tests are specified using the [`gherkin`](https://github.com/cucumber/cucumber/wiki/Gherkin) language and executed using [`cucumber`](https://github.com/cucumber/cucumber).
70
+ They are located within the `features` folder and can be executed using `cucumber features` from within the root directory of the JDT.
71
+
72
+ The tests are written to only work in specific cases:
73
+
74
+ * the gem has to be installed locally using `rake install` from within the JDT directory
75
+ * the tests only work using Windows. If you have a posix system, it would work if you simply replace all jdt.bat with jdt. TODO implement logic in cucumber using before and after to ensure that the command is correct
76
+
77
+ ### Unit Tests
78
+ The unit tests are implemented using [`rspec`](https://github.com/rspec/rspec).
79
+ They are located within the `spec` folder and can be executed using `rspec spec` from within the root directory of the JDT.
80
+
81
+
82
+ ## Technical Runtime Details
83
+
84
+ It is written with Ruby 1.8.7 ontop of several libraries:
85
+
86
+ * [`thor`](https://github.com/wycats/thor) to provide the command line commands
87
+ * [`nokogiri`](http://nokogiri.org/) to read the manifest xml file per Joomla! extension
88
+ * [`rubyzip`](http://rubyzip.sourceforge.net/) to create zip files as deployable artifacts
89
+
90
+ ## Releasing
91
+
92
+ * make sure that everything is commited
93
+ * `gem bump` this increases the version number
94
+ * `gem release` this creates the gem and pushes it to [RubyGems](https://rubygems.org/)
95
+
96
+ ## Installing locally
97
+
98
+ Make sure you have the gem `rake` and `gem-release` installed. Then execute `rake install` to install it locally. This automatically builds the gem and installs it over the current local installation of the gem.
99
+
100
+ # Joomla Versions
101
+ This tool solely supports **Joomla! 1.7**, as older versions do have much more ambiquity within their manifest.xml files.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/jdt ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'jdt' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('jdt', 'jdt')
File without changes
@@ -0,0 +1,25 @@
1
+ Feature: Manifest
2
+
3
+ Scenario: Not within an extension
4
+ Given the current directory is no extension directory
5
+ When I run `jdt.bat manifest`
6
+ Then the output should contain exactly "No manifest found\n"
7
+
8
+ Scenario: Success
9
+ Given a file named "manifest.xml" with:
10
+ """
11
+ <?xml version="1.0" encoding="UTF-8"?>
12
+ <extension type="library" version="1.7.0" method="upgrade">
13
+ <name>activerecord</name>
14
+ <version>1.0.0</version>
15
+ </extension>
16
+ """
17
+ When I run `jdt.bat manifest`
18
+ Then the output should contain exactly:
19
+ """
20
+ <?xml version="1.0" encoding="UTF-8"?>
21
+ <extension method="upgrade" type="library" version="1.7.0">
22
+ <name>activerecord</name>
23
+ <version>1.0.0</version>
24
+ </extension>
25
+ """
@@ -0,0 +1,97 @@
1
+ Feature: new
2
+
3
+ Scenario: Create library
4
+ When I run `jdt new library test`
5
+ Then a directory named "lib_test" should exist
6
+ And a file named "test/manifest.xml" with:
7
+ """
8
+ <?xml version="1.0" encoding="UTF-8"?>
9
+ <extension method="upgrade" type="library" version="1.7.0">
10
+ <name>test</name>
11
+ <version>0.0.1</version>
12
+ <libraryname>test</libraryname>
13
+
14
+ </extension>
15
+ """
16
+ And a file named "test/test.php" with:
17
+ """
18
+
19
+ """
20
+
21
+ Scenario: Create plugin
22
+ When I run `jdt new plugin test`
23
+ Then a directory named "plg_test" should exist
24
+ And a file named "test/manifest.xml" with:
25
+ """
26
+ <?xml version="1.0" encoding="UTF-8"?>
27
+ <extension method="upgrade" type="library" version="1.7.0">
28
+ <name>test</name>
29
+ <version>0.0.1</version>
30
+ <libraryname>test</libraryname>
31
+
32
+ </extension>
33
+ """
34
+ And a file named "test/test.php" with:
35
+ """
36
+
37
+ """
38
+
39
+ Scenario: Create template
40
+ When I run `jdt new template test`
41
+ Then a directory named "tpl_test" should exist
42
+ And a file named "tpl_test/manifest.xml" with:
43
+ """
44
+ <?xml version="1.0" encoding="UTF-8"?>
45
+ <extension method="upgrade" type="template" version="1.7.0">
46
+ <name>test</name>
47
+ <version>0.0.1</version>
48
+ </extension>
49
+ """
50
+
51
+ Scenario: Create language
52
+ When I run `jdt new language test`
53
+ Then a directory named "lang_test" should exist
54
+ And a file named "lang_test/manifest.xml" with:
55
+ """
56
+ <?xml version="1.0" encoding="UTF-8"?>
57
+ <extension method="upgrade" type="language" version="1.7.0">
58
+ <name>test</name>
59
+ <version>0.0.1</version>
60
+ </extension>
61
+ """
62
+
63
+ Scenario: Create module
64
+ When I run `jdt new module test`
65
+ Then a directory named "mod_test" should exist
66
+ And a file named "mod_test/manifest.xml" with:
67
+ """
68
+ <?xml version="1.0" encoding="UTF-8"?>
69
+ <extension method="upgrade" type="module" version="1.7.0">
70
+ <name>test</name>
71
+ <version>0.0.1</version>
72
+ </extension>
73
+ """
74
+
75
+ Scenario: Create component
76
+ When I run `jdt new component test`
77
+ Then a directory named "com_test" should exist
78
+ And a file named "com_test/manifest.xml" with:
79
+ """
80
+ <?xml version="1.0" encoding="UTF-8"?>
81
+ <extension method="upgrade" type="module" version="1.7.0">
82
+ <name>test</name>
83
+ <version>0.0.1</version>
84
+ </extension>
85
+ """
86
+
87
+ Scenario: Create package
88
+ When I run `jdt new package test`
89
+ Then a directory named "pkg_test" should exist
90
+ And a file named "pkg_test/manifest.xml" with:
91
+ """
92
+ <?xml version="1.0" encoding="UTF-8"?>
93
+ <extension method="upgrade" type="package" version="1.7.0">
94
+ <name>test</name>
95
+ <version>0.0.1</version>
96
+ </extension>
97
+ """
@@ -0,0 +1,47 @@
1
+ Feature: release
2
+
3
+ In order to obtain a deployable zip file of the extension
4
+ I as a CLI
5
+
6
+
7
+ Scenario: Not within an extension
8
+ Given the current directory is no extension directory
9
+ When I run `jdt.bat release`
10
+ Then the output should contain exactly "No manifest found\n"
11
+
12
+
13
+ Scenario: Success
14
+ Given a file named "manifest.xml" with:
15
+ """
16
+ <?xml version="1.0" encoding="UTF-8"?>
17
+ <extension type="library" version="1.7.0" method="upgrade">
18
+
19
+ <name>activerecord</name>
20
+ <version>0.0.1</version>
21
+
22
+ <files>
23
+ <filename>README</filename>
24
+ <folder>lib</folder>
25
+ </files>
26
+
27
+ </extension>
28
+ """
29
+ And a file named "README" with:
30
+ """
31
+ test
32
+ """
33
+ And an empty file named "CHANGELOG"
34
+ And a directory named "lib"
35
+ And an empty file named "lib/test.php"
36
+ And a directory named "zip" should not exist
37
+
38
+ When I run `jdt.bat release`
39
+
40
+ Then a directory named "zip" should exist
41
+ And a file named "zip/lib_activerecord-v0.0.1.zip" should exist
42
+ And a file named "README" should exist within a zip file "zip/lib_activerecord-v0.0.1.zip" with:
43
+ """
44
+ test
45
+ """
46
+ And a file named "CHANGELOG" should not exist within a zip file "zip/lib_activerecord-v0.0.1.zip"
47
+ And a file named "lib/test.php" should exist within a zip file "zip/lib_activerecord-v0.0.1.zip"
@@ -0,0 +1,22 @@
1
+ Feature: Status
2
+
3
+ In order to know which extension with what version is currently edited
4
+ As a CLI
5
+ I want to obtain the name, type and version of the extension
6
+
7
+ Scenario: Not within an extension
8
+ Given the current directory is no extension directory
9
+ When I run `jdt.bat status`
10
+ Then the output should contain exactly "No manifest found\n"
11
+
12
+ Scenario: Status success
13
+ Given a file named "manifest.xml" with:
14
+ """
15
+ <?xml version="1.0" encoding="UTF-8"?>
16
+ <extension type="library" version="1.7.0" method="upgrade">
17
+ <name>activerecord</name>
18
+ <version>1.0.0</version>
19
+ </extension>
20
+ """
21
+ When I run `jdt.bat status`
22
+ Then the output should contain exactly "Extension lib_activerecord-v1.0.0\n"
@@ -0,0 +1,37 @@
1
+ require "aruba/api"
2
+ require "zip/zipfilesystem"
3
+
4
+
5
+ Given /^the current directory is no extension directory$/ do
6
+ # do nothing, just use default directory
7
+ end
8
+
9
+ When /^a file named "([^"]*)" should exist within a zip file "([^"]*)"$/ do |file, zip|
10
+
11
+ Zip::ZipFile.open(File.join(current_dir,zip)) do |zip_file|
12
+ expect {
13
+ zip_file.get_entry(file)
14
+ }.to_not raise_error(Errno::ENOENT)
15
+ end
16
+
17
+ end
18
+
19
+ When /^a file named "([^"]*)" should not exist within a zip file "([^"]*)"$/ do |file, zip|
20
+
21
+ Zip::ZipFile.open(File.join(current_dir,zip)) do |zip_file|
22
+ expect {
23
+ zip_file.get_entry(file)
24
+ }.to raise_error(Errno::ENOENT)
25
+ end
26
+
27
+ end
28
+
29
+ When /^a file named "([^"]*)" should exist within a zip file "([^"]*)" with:$/ do |file, zip, file_content|
30
+
31
+ Zip::ZipFile.open(File.join(current_dir,zip)) do |zip_file|
32
+ expect {
33
+ zip_file.read(file).should eq(file_content)
34
+ }.to_not raise_error(Errno::ENOENT)
35
+ end
36
+
37
+ end
@@ -0,0 +1,7 @@
1
+ require "aruba"
2
+
3
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
+
5
+ Before do
6
+ @aruba_timeout_seconds = 20
7
+ end
@@ -0,0 +1,2 @@
1
+ require "aruba/cucumber"
2
+
File without changes
@@ -0,0 +1,9 @@
1
+ Feature: Version
2
+
3
+ In order to detect, which version is installed
4
+ As a CLI
5
+ I want to obtain the current version
6
+
7
+ Scenario: Display current version
8
+ When I run `jdt.bat version`
9
+ Then the output should contain exactly "0.0.2\n"
data/jdt.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jdt/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jdt"
7
+ s.version = Jdt::VERSION
8
+ s.authors = ['Simon Harrer', 'Andreas Vorndran']
9
+ s.email = ['simon.harrer@feki.de','andreas.vorndran@feki.de']
10
+ s.homepage = 'http://github.com/simonharrer/joomlatools'
11
+ s.summary = %q{A command line tool for developing Joomla Extensions}
12
+ s.description = %q{A command line tool to help developing Joomla Extensions. }
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency "nokogiri"
20
+ s.add_dependency "thor"
21
+ s.add_dependency "rubyzip"
22
+ s.add_development_dependency "rspec"
23
+ s.add_development_dependency "cucumber"
24
+ s.add_development_dependency "aruba"
25
+ end
data/lib/jdt/cli.rb ADDED
@@ -0,0 +1,34 @@
1
+ require "thor"
2
+
3
+ require "jdt/commands/build"
4
+ require "jdt/commands/bump"
5
+ require "jdt/commands/install"
6
+ require "jdt/commands/new"
7
+ require "jdt/commands/pretty_print"
8
+ #require "jdt/commands/secure"
9
+ require "jdt/commands/status"
10
+ require "jdt/commands/validate"
11
+ require "jdt/commands/version"
12
+
13
+ require "jdt/manifest"
14
+ require "jdt/generator"
15
+
16
+ module Jdt
17
+
18
+ class CLI < Thor
19
+
20
+ no_tasks {
21
+ def handle_errors(&block)
22
+ begin
23
+ yield
24
+ rescue NoManifestException
25
+ say "No manifest found"
26
+ end
27
+ end
28
+ }
29
+
30
+ end
31
+
32
+
33
+
34
+ end
@@ -0,0 +1,28 @@
1
+ require 'thor'
2
+
3
+ module Jdt
4
+
5
+ class CLI < Thor
6
+ include Thor::Actions
7
+
8
+ desc "build", "creates a zip stored under /zip with a timestamp"
9
+ method_options :location => "."
10
+
11
+ def build
12
+ handle_errors do
13
+ say "Build created at: #{Manifest.find(options[:location]).build}"
14
+ end
15
+ end
16
+
17
+ desc "release", "creates a zip stored under /zip"
18
+ method_options :location => "."
19
+
20
+ def release
21
+ handle_errors do
22
+ say "Release created at: #{Manifest.find(options[:location]).release}"
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,37 @@
1
+ require "thor"
2
+
3
+ module Jdt
4
+
5
+ class CLI < Thor
6
+ include Thor::Actions
7
+
8
+ desc "bump", "bumps version incrementing the patch version counter (major.minor.patch)"
9
+ method_options :major => false
10
+ method_options :minor => false
11
+ method_options :location => "."
12
+
13
+ def bump
14
+ handle_errors do
15
+ # find manifest
16
+ manifest = Manifest.find(options[:location])
17
+
18
+ # determine what is to be bumped
19
+ if (options.major?)
20
+ bump_option = :major
21
+ elsif (options.minor?)
22
+ bump_option = :minor
23
+ else
24
+ bump_option = :patch
25
+ end
26
+
27
+ # bump
28
+ manifest.bump!(bump_option)
29
+
30
+ # inform user
31
+ say "Bumped version to #{manifest.version} (bumped #{bump_option.to_s})"
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,20 @@
1
+ require "thor"
2
+
3
+ module Jdt
4
+
5
+ class CLI < Thor
6
+ include Thor::Actions
7
+
8
+ desc "install", "installs the extension at an active Joomla! system"
9
+ method_options :location => "."
10
+
11
+ def install
12
+ handle_errors do
13
+ manifest = Manifest.find(options[:location])
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,31 @@
1
+ require 'thor'
2
+ require 'nokogiri'
3
+
4
+ module Jdt
5
+
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ desc "new TYPE NAME", "creates a stub of TYPE with NAME"
10
+ method_options :location => "."
11
+
12
+ def new(type, name)
13
+
14
+ handle_errors do
15
+
16
+ begin
17
+ generator = Generator.find(type.to_sym, name)
18
+ generator.location = options[:location]
19
+ generator.generate
20
+ rescue Jdt::ExtensionTypeNotFoundError
21
+ say("Given type is no Joomla extension type. Chose one of the available Joomla extension types:")
22
+ say("Extension types: #{Generator::GENERATORS.join(" ")}")
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end