shop 0.1.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.
- checksums.yaml +15 -0
- data/LICENSE.md +21 -0
- data/README.md +65 -0
- data/bin/shop +8 -0
- data/lib/shop/color.rb +54 -0
- data/lib/shop/command.rb +122 -0
- data/lib/shop.rb +12 -0
- data/shop.gemspec +72 -0
- metadata +54 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
YzFkYzk1N2M1YzI3Nzg5YjU4NmQxOTQ2M2RlMWM5N2Y3MmQ2ZGExNQ==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
YTY3ZTcwNWM2ZmYzNmM2YzA5ZWRjOTQ0ZWQ1ZjI4MjNiOTU0MWE5OA==
|
|
7
|
+
!binary "U0hBNTEy":
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MjdlMjRlYjM4MjFhN2QxMGI2NjRkZTliMzdmYjRmMTQwZDk0NzUxNWQ2Yzky
|
|
10
|
+
N2QzOWQ3NGU3ZDE1OTllM2ZlMTU1MDY0OWZiZjIzOWZhMjgyOGIzYTRmNzQ1
|
|
11
|
+
NTJjZjEzYTIxZjdmNGU3NTczYzgxZTMzMjI5MzYyYTJjMmQ2Nzc=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
Y2YxYjZmNmUxZjgzZTYxMjlhNTgzNTdkZGY3MDYxMmJhNDUwZTFjYjQ4Y2Zh
|
|
14
|
+
MDI1MzE5ZDMwNjQyYjFjYTc4MzUyMjJlNjA1ZDUxZTE4NWY0N2M1NWQ3MWUz
|
|
15
|
+
N2Y2YWY4ZjQ0MzAzNGM1ODM1Yjc1Nzk0MmMxMzcxZmFlOWMwNmY=
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Romain Berger romain@romainberger.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Shop
|
|
2
|
+
|
|
3
|
+
CLI for easier Prestashop development. Actually it's just for the lazy people.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
$ gem install shop
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
### Initialization
|
|
12
|
+
|
|
13
|
+
For some of the task, Shop will need to know the name of the theme you're using. To do that you need to init the project with:
|
|
14
|
+
|
|
15
|
+
$ shop init <theme-name>
|
|
16
|
+
|
|
17
|
+
### Overrides
|
|
18
|
+
|
|
19
|
+
Creates overrides files for controllers and classes.
|
|
20
|
+
|
|
21
|
+
Usage: `$ shop override controller|class Name [admin]
|
|
22
|
+
|
|
23
|
+
$ shop override controller|class Name
|
|
24
|
+
# Generates an override for a controller or a class
|
|
25
|
+
# example:
|
|
26
|
+
$ shop override controller Product
|
|
27
|
+
# or
|
|
28
|
+
$ shop override class Product
|
|
29
|
+
|
|
30
|
+
# by default the controller will be placed in override/controllers/admin. To create an override in
|
|
31
|
+
# override/controllers/admin add the `admin` argument:
|
|
32
|
+
$ shop override controller AdminProducts
|
|
33
|
+
|
|
34
|
+
### Modules
|
|
35
|
+
|
|
36
|
+
Create a module or modules' templates files.
|
|
37
|
+
|
|
38
|
+
$ shop module <name>
|
|
39
|
+
# Generates a boilerplate for a new module
|
|
40
|
+
# example:
|
|
41
|
+
$ shop module dinozaure
|
|
42
|
+
|
|
43
|
+
$ shop module template <module-name> <hook-name>
|
|
44
|
+
# example:
|
|
45
|
+
$ shop module blockcategories blockcategories
|
|
46
|
+
|
|
47
|
+
### Cache
|
|
48
|
+
|
|
49
|
+
$ shop clean cache
|
|
50
|
+
# cleans the cache and compile and stuffs
|
|
51
|
+
|
|
52
|
+
$ shop clean class
|
|
53
|
+
# clean the class index - automatically done when generating a new controller or class
|
|
54
|
+
|
|
55
|
+
### Help
|
|
56
|
+
|
|
57
|
+
You can get a list of the available commands with the help:
|
|
58
|
+
|
|
59
|
+
$ shop help
|
|
60
|
+
|
|
61
|
+
# Who
|
|
62
|
+
|
|
63
|
+
By [Romain Berger](http://romainberger.com).
|
|
64
|
+
Ping me at [@romain__berger](http://twitter.com/romain__berger) if you're having issues or create an issue.
|
|
65
|
+
If you become billionaire with a shop made with the help of Shop you must buy me a beer.
|
data/bin/shop
ADDED
data/lib/shop/color.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Shamelessly stolen from https://github.com/holman/boom
|
|
2
|
+
|
|
3
|
+
module Shop
|
|
4
|
+
# Color collects some methods for colorizing terminal output.
|
|
5
|
+
module Color
|
|
6
|
+
extend self
|
|
7
|
+
|
|
8
|
+
CODES = {
|
|
9
|
+
:reset => "\e[0m",
|
|
10
|
+
|
|
11
|
+
:cyan => "\e[36m",
|
|
12
|
+
:magenta => "\e[35m",
|
|
13
|
+
:red => "\e[31m",
|
|
14
|
+
:yellow => "\e[33m"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# Tries to enable Windows support if on that platform.
|
|
18
|
+
#
|
|
19
|
+
# Returns nothing.
|
|
20
|
+
def self.included(other)
|
|
21
|
+
if RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw32/
|
|
22
|
+
require 'Win32/Console/ANSI'
|
|
23
|
+
end
|
|
24
|
+
rescue LoadError
|
|
25
|
+
# Oh well, we tried.
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Wraps the given string in ANSI color codes
|
|
29
|
+
#
|
|
30
|
+
# string - The String to wrap.
|
|
31
|
+
# color_code - The String representing he ANSI color code
|
|
32
|
+
#
|
|
33
|
+
# Examples
|
|
34
|
+
#
|
|
35
|
+
# colorize("Boom!", :magenta)
|
|
36
|
+
# # => "\e[35mBoom!\e[0m"
|
|
37
|
+
#
|
|
38
|
+
# Returns the wrapped String unless the the platform is windows and
|
|
39
|
+
# does not have Win32::Console, in which case, returns the String.
|
|
40
|
+
def colorize(string, color_code)
|
|
41
|
+
if !defined?(Win32::Console) && !!(RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw32/)
|
|
42
|
+
# looks like this person doesn't have Win32::Console and is on windows
|
|
43
|
+
# just return the uncolorized string
|
|
44
|
+
return string
|
|
45
|
+
end
|
|
46
|
+
"#{CODES[color_code] || color_code}#{string}#{CODES[:reset]}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Set up shortcut methods to all the codes define in CODES.
|
|
50
|
+
self.class_eval(CODES.keys.reject {|color| color == :reset }.map do |color|
|
|
51
|
+
"def #{color}(string); colorize(string, :#{color}); end"
|
|
52
|
+
end.join("\n"))
|
|
53
|
+
end
|
|
54
|
+
end
|
data/lib/shop/command.rb
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module Shop
|
|
4
|
+
class Command
|
|
5
|
+
class << self
|
|
6
|
+
|
|
7
|
+
def execute(*args)
|
|
8
|
+
command = args.shift
|
|
9
|
+
major = args.shift
|
|
10
|
+
minor = args.shift
|
|
11
|
+
extra = args.empty? ? nil : args.join(' ')
|
|
12
|
+
|
|
13
|
+
return help unless command
|
|
14
|
+
dispatch(command, major, minor, extra)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def dispatch(command, major, minor, extra)
|
|
18
|
+
return init(major) if command == 'init'
|
|
19
|
+
return shopModule(major, minor, extra) if command == 'module'
|
|
20
|
+
return override(major, minor, extra) if command == 'override'
|
|
21
|
+
return clean(major) if command == 'clean'
|
|
22
|
+
return version if command == "-v"
|
|
23
|
+
return version if command == "--version"
|
|
24
|
+
return help if command == 'help'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Init the project
|
|
28
|
+
def init(name)
|
|
29
|
+
if name.nil?
|
|
30
|
+
return puts "Error: Please specify the name of the theme"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
File.open('.shop', 'w') do |f|
|
|
34
|
+
f.write(name)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
done
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Creates a module or a module template
|
|
41
|
+
# prefixed with shop for obvious reasons
|
|
42
|
+
def shopModule(major, minor, extra)
|
|
43
|
+
if major == 'template'
|
|
44
|
+
# template
|
|
45
|
+
puts 'create module template'
|
|
46
|
+
else
|
|
47
|
+
# create a module
|
|
48
|
+
if File.directory?("modules/#{major}")
|
|
49
|
+
return puts "Module #{major} already exists"
|
|
50
|
+
else
|
|
51
|
+
FileUtils.mkpath("modules/#{major}")
|
|
52
|
+
File.open("modules/#{major}/#{major}.php", 'w') do |f|
|
|
53
|
+
name = major.capitalize
|
|
54
|
+
content = "<?php\n\nclass #{name} extends Module {\n\n}\n"
|
|
55
|
+
f.write(content)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
done
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Creates an override for controllers and classes
|
|
64
|
+
def override(major, minor, extra)
|
|
65
|
+
name = minor.capitalize
|
|
66
|
+
if major == 'controller'
|
|
67
|
+
# controller
|
|
68
|
+
if !extra.nil? && extra == 'admin'
|
|
69
|
+
side = 'admin'
|
|
70
|
+
else
|
|
71
|
+
side = 'front'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
name = "#{name}Controller"
|
|
75
|
+
filename = "#{name}.php"
|
|
76
|
+
path = "override/controllers/#{side}/#{filename}"
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
elsif major == 'class'
|
|
80
|
+
# class
|
|
81
|
+
filename = "#{name}.php"
|
|
82
|
+
path = "override/classes/#{filename}"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
content = "<?php\n\nclass #{name} extends #{name}Core {\n\n}\n"
|
|
86
|
+
|
|
87
|
+
if !File.directory?('override')
|
|
88
|
+
return puts "You need to be at the root of your Prestashop site"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
File.open(path, 'w') do |f|
|
|
92
|
+
f.write(content)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
done
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Clean cache or class index
|
|
99
|
+
def clean(major)
|
|
100
|
+
if major == 'cache'
|
|
101
|
+
# cache
|
|
102
|
+
puts 'clean cache'
|
|
103
|
+
elsif major == 'index'
|
|
104
|
+
# index
|
|
105
|
+
puts 'clean index'
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def done
|
|
110
|
+
puts "✔ Done"
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def version
|
|
114
|
+
puts "Shop #{Shop::VERSION}"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def help
|
|
118
|
+
puts "Output help"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
data/lib/shop.rb
ADDED
data/shop.gemspec
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
## This is the rakegem gemspec template. Make sure you read and understand
|
|
2
|
+
## all of the comments. Some sections require modification, and others can
|
|
3
|
+
## be deleted if you don't need them. Once you understand the contents of
|
|
4
|
+
## this file, feel free to delete any comments that begin with two hash marks.
|
|
5
|
+
## You can find comprehensive Gem::Specification documentation, at
|
|
6
|
+
## http://docs.rubygems.org/read/chapter/20
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
10
|
+
s.rubygems_version = '2.0.3'
|
|
11
|
+
|
|
12
|
+
## Leave these as is they will be modified for you by the rake gemspec task.
|
|
13
|
+
## If your rubyforge_project name is different, then edit it and comment out
|
|
14
|
+
## the sub! line in the Rakefile
|
|
15
|
+
s.name = 'shop'
|
|
16
|
+
s.version = '0.1.0'
|
|
17
|
+
s.date = '2013-03-12'
|
|
18
|
+
s.rubyforge_project = 'shop'
|
|
19
|
+
|
|
20
|
+
## Make sure your summary is short. The description may be as long
|
|
21
|
+
## as you like.
|
|
22
|
+
s.summary = "Command line interface for easy Prestashop development"
|
|
23
|
+
s.description = "Because I'm too lazy to create files and type code"
|
|
24
|
+
|
|
25
|
+
## List the primary authors. If there are a bunch of authors, it's probably
|
|
26
|
+
## better to set the email to an email list or something. If you don't have
|
|
27
|
+
## a custom homepage, consider using your GitHub URL or the like.
|
|
28
|
+
s.authors = ["Romain Berger"]
|
|
29
|
+
s.email = 'romain@romainberger.com'
|
|
30
|
+
s.homepage = 'https://github.com/romainberger/shop'
|
|
31
|
+
|
|
32
|
+
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
|
33
|
+
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
|
34
|
+
s.require_paths = %w[lib]
|
|
35
|
+
|
|
36
|
+
## This sections is only necessary if you have C extensions.
|
|
37
|
+
#s.require_paths << 'ext'
|
|
38
|
+
#s.extensions = %w[ext/extconf.rb]
|
|
39
|
+
|
|
40
|
+
## If your gem includes any executables, list them here.
|
|
41
|
+
s.executables = ["shop"]
|
|
42
|
+
s.default_executable = 'shop'
|
|
43
|
+
|
|
44
|
+
## Specify any RDoc options here. You'll want to add your README and
|
|
45
|
+
## LICENSE files to the extra_rdoc_files list.
|
|
46
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
47
|
+
s.extra_rdoc_files = %w[README.md LICENSE.md]
|
|
48
|
+
s.license = 'MIT'
|
|
49
|
+
|
|
50
|
+
## List your runtime dependencies here. Runtime dependencies are those
|
|
51
|
+
## that are needed for an end user to actually USE your code.
|
|
52
|
+
|
|
53
|
+
## List your development dependencies here. Development dependencies are
|
|
54
|
+
## those that are only needed during development
|
|
55
|
+
|
|
56
|
+
## Leave this section as-is. It will be automatically generated from the
|
|
57
|
+
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
|
58
|
+
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
|
59
|
+
# = MANIFEST =
|
|
60
|
+
s.files = %w[
|
|
61
|
+
bin/shop
|
|
62
|
+
shop.gemspec
|
|
63
|
+
lib/shop.rb
|
|
64
|
+
lib/shop/command.rb
|
|
65
|
+
lib/shop/color.rb
|
|
66
|
+
]
|
|
67
|
+
# = MANIFEST =
|
|
68
|
+
|
|
69
|
+
## Test files will be grabbed from the file list. Make sure the path glob
|
|
70
|
+
## matches what you actually use.
|
|
71
|
+
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
|
72
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: shop
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Romain Berger
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Because I'm too lazy to create files and type code
|
|
14
|
+
email: romain@romainberger.com
|
|
15
|
+
executables:
|
|
16
|
+
- shop
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files:
|
|
19
|
+
- README.md
|
|
20
|
+
- LICENSE.md
|
|
21
|
+
files:
|
|
22
|
+
- bin/shop
|
|
23
|
+
- shop.gemspec
|
|
24
|
+
- lib/shop.rb
|
|
25
|
+
- lib/shop/command.rb
|
|
26
|
+
- lib/shop/color.rb
|
|
27
|
+
- README.md
|
|
28
|
+
- LICENSE.md
|
|
29
|
+
homepage: https://github.com/romainberger/shop
|
|
30
|
+
licenses:
|
|
31
|
+
- MIT
|
|
32
|
+
metadata: {}
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options:
|
|
35
|
+
- --charset=UTF-8
|
|
36
|
+
require_paths:
|
|
37
|
+
- lib
|
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ! '>='
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ! '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
requirements: []
|
|
49
|
+
rubyforge_project: shop
|
|
50
|
+
rubygems_version: 2.0.3
|
|
51
|
+
signing_key:
|
|
52
|
+
specification_version: 2
|
|
53
|
+
summary: Command line interface for easy Prestashop development
|
|
54
|
+
test_files: []
|