oynx 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01f96219f4b75c451795ea20d8a761a4f155403c
4
- data.tar.gz: ef1f337b2ab14233a23a56fbb8e12399bfdcfdaf
3
+ metadata.gz: 5f282b4c55f8cee6860ee69601166485b5ab60b3
4
+ data.tar.gz: 3f74108caea61e1e4e55b3c293f1f6290898daa9
5
5
  SHA512:
6
- metadata.gz: c5f74bb0eea60d6ca5d924e3aa7525f1e8c3208f808857a8fbf1e42d58a3d8e32d30bb7bd1d439efb6fcea07752b36ce8b037af41351f6bd9a3c173b5956f973
7
- data.tar.gz: d61d02062dd805b13f7f5cd0b96bff7169d40983d3bff1ce59d89f5910adaa09584c93baaff4864c57f203423159e407d964315a7059ee026318aec120660f3c
6
+ metadata.gz: a0f916fd7976b5c6baa77f1e9f7d8077338fa2b654b2e1d1d53caae91c4dd7a6343772e84abe9d2b858d3cf804064f646779bea3d160140b60fb256c1d158a46
7
+ data.tar.gz: 030de219ec9d04a1547d1f79f1e526bf31cec30aa41515d00ed6470974e0c2887ae32294720df1c75fa9a413f6d0d3b46eaf3a7fd2562098b33187e75358b435
data/lib/oynx/config.rb CHANGED
@@ -1,4 +1,8 @@
1
+ # Web_Config is just a wrapper for a Hash with some custom keys
2
+ # instantiated for Oynx use.
3
+
1
4
  class Web_Config < Hash
5
+ # Set our custom keys to default values
2
6
  def initialize()
3
7
  self["name"] = "new_site"
4
8
  self["charset"] = "utf-8"
@@ -7,6 +11,7 @@ class Web_Config < Hash
7
11
  self["img"] = true
8
12
  end
9
13
 
14
+ # Our Web_Config as a String
10
15
  def to_s()
11
16
  ret = ""
12
17
  self.each_pair do |key, val|
@@ -1,33 +1,63 @@
1
+ require "rubygems"
2
+ require "zip"
3
+
1
4
  require_relative './config'
2
5
 
3
6
  class Oynx_Back
4
- attr_writer :config
7
+ attr_writer :config, :root
5
8
 
9
+ # Set our configuration to either a blank configuration or one
10
+ # supplied by the application. @root is the root folder of the
11
+ # site
6
12
  def initialize(config = Web_Config.new)
7
13
  @config = config
8
14
  @root = nil
9
15
  end
10
16
 
17
+ # Call the various methods to create the website
11
18
  def create_site()
12
19
  create_root()
13
20
  create_inner_folders()
14
21
  create_file_stubs()
15
22
  end
16
23
 
24
+ # Compress the site if specified, then upload it using `scp`
25
+ # This is a class method due to quirks with Thor
26
+ def Oynx_Back.upload(options, site_name, dir)
27
+ user = options[:user]
28
+ dir = options[:dir]
29
+ server = options[:server]
30
+ port = options[:port]
31
+ compress = options[:compress] if not options[:compress] else true
32
+ if options[:compress] then
33
+ Oynx_Back.compress_site(site_name)
34
+ system "scp -P #{port} #{site_name}.zip #{user}@#{server}:#{dir}/#{site_name}.zip"
35
+ else
36
+ system "scp -P #{port} -r #{site_name} #{user}@#{server}:#{dir}/#{site_name}"
37
+ end
38
+ end
39
+
17
40
  private
18
41
 
42
+ ##################
43
+ # Creating methods
44
+ ##################
45
+
46
+ # Create the root folder for our site
19
47
  def create_root()
20
48
  tmp = File.join(Dir.pwd, @config["name"])
21
49
  Dir.mkdir(tmp)
22
- @root = Dir.new(tmp)
50
+ @root = tmp
23
51
  end
24
52
 
53
+ # Call the various methods to create our folders
25
54
  def create_inner_folders()
26
55
  create_css_folder()
27
56
  create_img_folder()
28
57
  create_js_folder()
29
58
  end
30
59
 
60
+ # Create a CSS folder if specified
31
61
  def create_css_folder()
32
62
  if @config["css"]
33
63
  css = File.join(@root, "css")
@@ -35,6 +65,7 @@ class Oynx_Back
35
65
  end
36
66
  end
37
67
 
68
+ # Create an image folder if specified
38
69
  def create_img_folder()
39
70
  if @config["img"]
40
71
  img = File.join(@root, "img")
@@ -42,6 +73,7 @@ class Oynx_Back
42
73
  end
43
74
  end
44
75
 
76
+ # Create a JS folder if specified
45
77
  def create_js_folder()
46
78
  if @config["js"]
47
79
  js = File.join(@root, "js")
@@ -49,6 +81,8 @@ class Oynx_Back
49
81
  end
50
82
  end
51
83
 
84
+ # First create our index.html template, then call the methods
85
+ # to create css and js stubs
52
86
  def create_file_stubs()
53
87
  index_text = "<!DOCTYPE HTML>
54
88
  <html>
@@ -72,6 +106,7 @@ class Oynx_Back
72
106
  create_js_file_stubs()
73
107
  end
74
108
 
109
+ # Creates a css stub file if specified
75
110
  def create_css_file_stubs()
76
111
  if @config["css"] then
77
112
  css_file = File.join(@root, "css/styles.css")
@@ -79,10 +114,29 @@ class Oynx_Back
79
114
  end
80
115
  end
81
116
 
117
+ # Creates a js stub file if specified
82
118
  def create_js_file_stubs()
83
119
  if @config["js"] then
84
120
  js_file = File.join(@root, "js/scripts.js")
85
121
  File.open(js_file, "a")
86
122
  end
87
123
  end
124
+
125
+ ###################
126
+ # Uploading methods
127
+ ###################
128
+
129
+ # Compresses the site
130
+ def Oynx_Back.compress_site(name)
131
+ archive = File.join(Dir.pwd, "#{name}.zip")
132
+ arch_dir = File.join(Dir.pwd, "#{name}")
133
+ files = Dir[File.join(arch_dir, "**", "**")]
134
+
135
+ Zip::File.open(archive, Zip::File::CREATE) do |zipfile|
136
+ files.each do |file|
137
+ filename = "#{arch_dir}/#{file}"
138
+ zipfile.add(file.sub("#{arch_dir}/", ""), file)
139
+ end
140
+ end
141
+ end
88
142
  end
data/lib/oynx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oynx
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/oynx.rb CHANGED
@@ -2,9 +2,12 @@ require "thor"
2
2
 
3
3
  require "oynx/version"
4
4
  require "oynx/oynx_back"
5
+ require "oynx/config"
5
6
 
6
7
  module Oynx
7
8
  class Oynx_CLI < Thor
9
+ attr_accessor :site
10
+
8
11
  desc "new", "create a new website"
9
12
  long_desc <<-LONGDESC
10
13
  `oynx new` will create a new website in the current directory.
@@ -12,9 +15,9 @@ module Oynx
12
15
  Optional Parameters
13
16
  \x5-------------------
14
17
 
15
- --default - Create a site with default information.
18
+ --default, -d - Create a site with default information.
16
19
 
17
- --name "NAME" - Specify the site's name.
20
+ --name "NAME" - Specify the site's name.
18
21
  \x5--charset "CHST" - Specify the charset to use.
19
22
  \x5--no-css - Don't create a CSS folder or stubs.
20
23
  \x5--no-img - Don't create an image folder.
@@ -28,18 +31,45 @@ module Oynx
28
31
  option :img, :type => :boolean
29
32
  def new
30
33
  if options[:default] then
31
- Oynx_Back.new.create_site()
34
+ Oynx_Back.new.create_site()
32
35
  else
33
- config = {}
34
-
35
36
  config["name"] = options[:name] if options[:name]
36
37
  config["charset"] = options[:charset] if options[:charset]
37
38
  config["css"] = options[:css] if not options[:css]
38
39
  config["js"] = options[:js] if not options[:js]
39
40
  config["img"] = options[:img] if not options[:img]
40
41
 
41
- Oynx_Back.new(config).create_site
42
+ @site = Oynx_Back.new(config).create_site
42
43
  end
43
44
  end
45
+
46
+ desc "upload", "upload site to a server"
47
+ long_desc <<-LONGDESC
48
+ `oynx upload` will upload the site to a server.
49
+
50
+ Required Parameters
51
+ \x5-------------------
52
+
53
+ --server, -s "URL/IP" - Server URL/IP Address
54
+ \x5--port, -n "PORT" - Port to use
55
+ \x5--user, -u "USERNAME" - Username
56
+ \x5--pass, -p "PASSWORD" - Password
57
+ \x5--dir, -d "DIRECTORY" - Directory to use
58
+ \x5--compress, -c / --no-compress - Compresses the site / Doesn't compress the site
59
+ LONGDESC
60
+ option :server, :aliases => :s, :required => true
61
+ option :port, :aliases => :n, :type => :numeric, :required => true
62
+ option :user, :aliases => :u, :required => true
63
+ option :dir, :aliases => :d, :required => true
64
+ option :compress, :aliases => :c, :type => :boolean
65
+ def upload
66
+ Oynx_Back.upload(options, config["name"], File.join(Dir.pwd, config["name"]))
67
+ end
68
+
69
+ private
70
+
71
+ def config
72
+ @config ||= Web_Config.new
73
+ end
44
74
  end
45
75
  end
data/oynx.gemspec CHANGED
@@ -20,5 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency "rubyzip"
23
25
  end
24
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oynx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryce Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubyzip
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Oynx simplifies several aspects of web development
42
56
  email:
43
57
  - me@bryceadavis.com
@@ -55,9 +69,7 @@ files:
55
69
  - bin/oynx
56
70
  - lib/oynx.rb
57
71
  - lib/oynx/config.rb
58
- - lib/oynx/main.rb
59
72
  - lib/oynx/oynx_back.rb
60
- - lib/oynx/setup.rb
61
73
  - lib/oynx/version.rb
62
74
  - oynx.gemspec
63
75
  homepage: https://github.com/mahimahi42/oynx.git
data/lib/oynx/main.rb DELETED
@@ -1,4 +0,0 @@
1
- require './setup'
2
-
3
- Setup.welcome()
4
- Setup.get_site_info()
data/lib/oynx/setup.rb DELETED
@@ -1,42 +0,0 @@
1
- require_relative './config'
2
-
3
- module Setup
4
- def Setup.welcome()
5
- puts "Welcome to Oynx!"
6
- puts "This tool will simplify your life as a web guru."
7
- puts "\n\n"
8
- end
9
-
10
- def Setup.get_site_info()
11
- puts "First, let's get some info about the site."
12
- name = Setup.get_site_name()
13
- chst = Setup.set_charset()
14
- c = Setup.finish_config(name, chst)
15
- end
16
-
17
- private
18
-
19
- def Setup.get_site_name()
20
- print "Website Name: "
21
- gets.chomp!
22
- end
23
-
24
- def Setup.set_charset()
25
- charset = "utf-8"
26
- print "Charset [#{charset}]: "
27
- input = gets.chomp!
28
- case input
29
- when ""
30
- return charset
31
- else
32
- return input
33
- end
34
- end
35
-
36
- def Setup.finish_config(name, chst)
37
- config = Web_Config.new
38
- config.set_name(name)
39
- config.set_charset(chst)
40
- return config
41
- end
42
- end