wired 0.0.2
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 +21 -0
- data/README.md +9 -0
- data/bin/wired +11 -0
- data/lib/wired/actions.rb +125 -0
- data/lib/wired/app_builder.rb +22 -0
- data/lib/wired/generators/app_generator.rb +52 -0
- data/lib/wired/version.rb +3 -0
- data/templates/Gemfile_clean +24 -0
- data/wired.gemspec +28 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjNlNzEzNDUzNGJmODVlNDAwYTc4YzVjMDE4NWI4MTc3ZDk4MDgyNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDM0ODRiYTBiN2JhMzBhMGJhYTc5MDc1NzMzYzEyOWIwMjVlMGUyOA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NmViMWNjMzk3OGE2NjE2ZjBiNzJmNDc1ZDdjNDcyNGFhNmMxMjNkNDBkMDUw
|
10
|
+
MTVmYzVkNWQyZjhlNThiM2Y0OTE4YzdkMjM5N2I4OWI1ZWIwNjc1MDZjN2Q1
|
11
|
+
MzhhOThmZGM5OWMxMmVkNTk2YmY5MWJhYTNkZmYyMGM0OGZlZGY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Y2MxNGNjZTFhNzUwYTNmZmQ2MzRlZjQxNmU4YmIwYWVjMDE3NjgwOGQ4ODc4
|
14
|
+
NTZlOTI0NjBiZDU1YjNhODU2NjA1ZmVjMTI4M2IyMGM1MWJiMzc0YmQwY2Yz
|
15
|
+
MDY2NWUyMTA0ODBhM2FkZWQwYmE2OTI0MDhjODEyMDc1NjQzYjE=
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2013 Wirelab Creative
|
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,9 @@
|
|
1
|
+
# Wired
|
2
|
+
|
3
|
+
About
|
4
|
+
---
|
5
|
+
This gem is for internal use and heavily based on (you might even say mostly copy-pasted from) Suspenders, if you found this gem you will probably want to check them out: [Suspenders by Thoughtbot](http://github.com/thoughtbot/suspenders).
|
6
|
+
|
7
|
+
Installation
|
8
|
+
---
|
9
|
+
gem install wired
|
data/bin/wired
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join('..', 'lib', 'wired', 'generators', 'app_generator'), File.dirname(__FILE__))
|
4
|
+
require File.expand_path(File.join('..', 'lib', 'wired', 'actions'), File.dirname(__FILE__))
|
5
|
+
require File.expand_path(File.join('..', 'lib', 'wired', 'app_builder'), File.dirname(__FILE__))
|
6
|
+
|
7
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
8
|
+
Wired::AppGenerator.source_root templates_root
|
9
|
+
Wired::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
10
|
+
|
11
|
+
Wired::AppGenerator.start
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module Wired
|
2
|
+
module Actions
|
3
|
+
# exact copy of https://github.com/thoughtbot/suspenders/blob/master/lib/suspenders/actions.rb
|
4
|
+
def concat_file(source, destination)
|
5
|
+
contents = IO.read(find_in_source_paths(source))
|
6
|
+
append_file destination, contents
|
7
|
+
end
|
8
|
+
|
9
|
+
def replace_in_file(relative_path, find, replace)
|
10
|
+
path = File.join(destination_root, relative_path)
|
11
|
+
contents = IO.read(path)
|
12
|
+
unless contents.gsub!(find, replace)
|
13
|
+
raise "#{find.inspect} not found in #{relative_path}"
|
14
|
+
end
|
15
|
+
File.open(path, "w") { |file| file.write(contents) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def action_mailer_host(rails_env, host)
|
19
|
+
inject_into_file(
|
20
|
+
"config/environments/#{rails_env}.rb",
|
21
|
+
"\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
|
22
|
+
:before => "\nend"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def download_file(uri_string, destination)
|
27
|
+
uri = URI.parse(uri_string)
|
28
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
29
|
+
http.use_ssl = true if uri_string =~ /^https/
|
30
|
+
request = Net::HTTP::Get.new(uri.path)
|
31
|
+
contents = http.request(request).body
|
32
|
+
path = File.join(destination_root, destination)
|
33
|
+
File.open(path, "w") { |file| file.write(contents) }
|
34
|
+
end
|
35
|
+
|
36
|
+
#stuff copied from https://github.com/ffmike/BigOldRailsTemplate/blob/master/template_framework.rb
|
37
|
+
|
38
|
+
# Heroku management
|
39
|
+
# Run a command with the Heroku gem.
|
40
|
+
#
|
41
|
+
# ==== Examples
|
42
|
+
#
|
43
|
+
# heroku :create
|
44
|
+
# heroku :rake => "db:migrate"
|
45
|
+
#
|
46
|
+
def heroku(command = {})
|
47
|
+
in_root do
|
48
|
+
if command.is_a?(Symbol)
|
49
|
+
log 'running', "heroku #{command}"
|
50
|
+
run "heroku #{command}"
|
51
|
+
else
|
52
|
+
command.each do |command, options|
|
53
|
+
log 'running', "heroku #{command} #{options}"
|
54
|
+
run("heroku #{command} #{options}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# File Management
|
61
|
+
def download(from, to = from.split("/").last)
|
62
|
+
#run "curl -s -L #{from} > #{to}"
|
63
|
+
file to, open(from).read
|
64
|
+
rescue
|
65
|
+
puts "Can't get #{from} - Internet down?"
|
66
|
+
exit!
|
67
|
+
end
|
68
|
+
|
69
|
+
# grab an arbitrary file from github
|
70
|
+
def file_from_repo(github_user, repo, sha, filename, to = filename)
|
71
|
+
download("http://github.com/#{github_user}/#{repo}/raw/#{sha}/#{filename}", to)
|
72
|
+
end
|
73
|
+
|
74
|
+
def load_from_file_in_template(file_name, parent_binding = nil, file_group = 'default', file_type = :pattern)
|
75
|
+
base_name = file_name.gsub(/^\./, '')
|
76
|
+
begin
|
77
|
+
if file_type == :config
|
78
|
+
contents = {}
|
79
|
+
else
|
80
|
+
contents = ''
|
81
|
+
end
|
82
|
+
paths = template_paths
|
83
|
+
|
84
|
+
paths.each do |template_path|
|
85
|
+
full_file_name = File.join(template_path, file_type.to_s.pluralize, file_group, base_name)
|
86
|
+
debug_log "Searching for #{full_file_name} ... "
|
87
|
+
|
88
|
+
next unless File.exists? full_file_name
|
89
|
+
debug_log "Found!"
|
90
|
+
|
91
|
+
if file_type == :config
|
92
|
+
contents = open(full_file_name) { |f| YAML.load(f) }
|
93
|
+
else
|
94
|
+
contents = open(full_file_name) { |f| f.read }
|
95
|
+
end
|
96
|
+
if contents && parent_binding
|
97
|
+
contents = eval("\"" + contents.gsub('"','\\"') + "\"", parent_binding)
|
98
|
+
end
|
99
|
+
# file loaded, stop searching
|
100
|
+
break if contents
|
101
|
+
|
102
|
+
end
|
103
|
+
contents
|
104
|
+
rescue => ex
|
105
|
+
debug_log "Error in load_from_file_in_template #{file_name}"
|
106
|
+
debug_log ex.message
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Load a snippet from a file
|
111
|
+
def load_snippet(snippet_name, snippet_group = "default", parent_binding = nil)
|
112
|
+
load_from_file_in_template(snippet_name, parent_binding, snippet_group, :snippet)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Load a pattern from a file, potentially with string interpolation
|
116
|
+
def load_pattern(pattern_name, pattern_group = "default", parent_binding = nil)
|
117
|
+
load_from_file_in_template(pattern_name, parent_binding, pattern_group, :pattern)
|
118
|
+
end
|
119
|
+
|
120
|
+
# YAML.load a configuration from a file
|
121
|
+
def load_template_config_file(config_file_name, config_file_group = template_identifier)
|
122
|
+
load_from_file_in_template(config_file_name, nil, config_file_group, :config )
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Wired
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include Wired::Actions
|
4
|
+
def remove_public_index
|
5
|
+
remove_file 'public/index.html'
|
6
|
+
end
|
7
|
+
|
8
|
+
def remove_rails_logo_image
|
9
|
+
remove_file 'app/assets/images/rails.png'
|
10
|
+
end
|
11
|
+
|
12
|
+
def replace_gemfile
|
13
|
+
remove_file 'Gemfile'
|
14
|
+
copy_file 'Gemfile_clean', 'Gemfile'
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_ruby_to_version_being_used
|
18
|
+
inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
|
19
|
+
after: /source 'https:\/\/rubygems.org'/
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
|
4
|
+
module Wired
|
5
|
+
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
+
class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql',
|
7
|
+
:desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
8
|
+
|
9
|
+
class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
|
10
|
+
:desc => 'Skip Test::Unit files'
|
11
|
+
|
12
|
+
def finish_template
|
13
|
+
invoke :wired_customization
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def wired_customization
|
18
|
+
invoke :remove_files_we_dont_need
|
19
|
+
invoke :customize_gemfile
|
20
|
+
invoke :outro
|
21
|
+
end
|
22
|
+
|
23
|
+
def remove_files_we_dont_need
|
24
|
+
build :remove_public_index
|
25
|
+
build :remove_rails_logo_image
|
26
|
+
end
|
27
|
+
|
28
|
+
def customize_gemfile
|
29
|
+
build :replace_gemfile
|
30
|
+
build :set_ruby_to_version_being_used
|
31
|
+
bundle_command 'install --binstubs=bin/stubs'
|
32
|
+
end
|
33
|
+
|
34
|
+
def outro
|
35
|
+
say 'Wired up!'
|
36
|
+
end
|
37
|
+
|
38
|
+
def run_bundle
|
39
|
+
# Let's not: We'll bundle manually at the right spot
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def get_builder_class
|
45
|
+
Wired::AppBuilder
|
46
|
+
end
|
47
|
+
|
48
|
+
def using_active_record?
|
49
|
+
!options[:skip_active_record]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.2.12'
|
4
|
+
|
5
|
+
gem 'pg'
|
6
|
+
gem 'jquery-rails'
|
7
|
+
gem 'thin'
|
8
|
+
|
9
|
+
group :assets do
|
10
|
+
gem 'coffee-rails'
|
11
|
+
gem 'sass-rails'
|
12
|
+
gem 'uglifier'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'foreman'
|
17
|
+
gem 'better_errors'
|
18
|
+
gem 'binding_of_caller'
|
19
|
+
gem 'letter_opener'
|
20
|
+
end
|
21
|
+
|
22
|
+
gem 'asset_sync'
|
23
|
+
gem 'mobylette'
|
24
|
+
gem 'simple_form'
|
data/wired.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'wired/version'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'wired'
|
8
|
+
s.version = Wired::VERSION
|
9
|
+
s.date = Date.today.strftime('%Y-%m-%d')
|
10
|
+
s.summary = 'Wirelab Generator'
|
11
|
+
s.description = 'A Wirelab application generator'
|
12
|
+
s.authors = ['Wirelab Creative']
|
13
|
+
s.email = 'bart@wirelab.nl'
|
14
|
+
s.homepage = 'https://github.com/Wirelab/wired'
|
15
|
+
s.files = `git ls-files`.split("\n").
|
16
|
+
reject { |file| file =~ /^\./ }.
|
17
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
23
|
+
s.extra_rdoc_files = %w[README.md]
|
24
|
+
|
25
|
+
s.add_dependency 'rails', '3.2.13'
|
26
|
+
s.add_dependency 'bundler', '>= 1.1'
|
27
|
+
s.add_dependency 'hub', '~> 1.10.5'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wired
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wirelab Creative
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.13
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.13
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hub
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.10.5
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.10.5
|
55
|
+
description: A Wirelab application generator
|
56
|
+
email: bart@wirelab.nl
|
57
|
+
executables:
|
58
|
+
- wired
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files:
|
61
|
+
- README.md
|
62
|
+
files:
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- bin/wired
|
66
|
+
- lib/wired/actions.rb
|
67
|
+
- lib/wired/app_builder.rb
|
68
|
+
- lib/wired/generators/app_generator.rb
|
69
|
+
- lib/wired/version.rb
|
70
|
+
- templates/Gemfile_clean
|
71
|
+
- wired.gemspec
|
72
|
+
homepage: https://github.com/Wirelab/wired
|
73
|
+
licenses: []
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --charset=UTF-8
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.0.0
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Wirelab Generator
|
96
|
+
test_files: []
|
97
|
+
has_rdoc:
|