ember-gen 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3100691f6e954d0bb4b98b9cb9ef4c4c082a53e
4
+ data.tar.gz: 51bd3c11c2e948f0d88e214f86069153be43bed5
5
+ SHA512:
6
+ metadata.gz: c074443641dec5c00477c5f51732a6e276d262fe84b6c61fdfaf813c18f1127b1c5f589b33d81a02ced72c5bdf06d9ca23b3aecb457da845a7f326d9c63cfa74
7
+ data.tar.gz: 57f6cd687148f73e5b367ef27ded9006620d06d77aedc76e5bcd3337c8109452c3240736da5e5b98597943fa83c5c4f851c4becb07fdbda8d86bb10b5111977b
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ember-rails-generator.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sean McCleary
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ ember-gen
2
+ =========
3
+
4
+ Right now, this has:
5
+ * a very simple bin wrapper for ember-rails rake tasks.
6
+ * rake tasks to help install newer versions of ember and jquery
7
+
8
+ I'll write more documentation soon. It is just late, and I'm sleepy.
9
+
10
+ Future Goals
11
+ ============
12
+
13
+ I would like to add the functionality so that it could generate all javascript files and their associated tests. The templates should be able to js or coffeescript. Also, generated files should support the major dependency management libs like (common.js, AMD, ES6).
14
+
15
+ ## Usage
16
+
17
+ TODO: Write usage instructions here
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ require 'ember-gen/generate'
4
+
5
+ # generator = EmberGen::Generate.new(:model)
6
+ # generator.print_template
7
+
8
+ AVAILABLE_GENERATORS = %w[component controller model resource route template view]
9
+ unless AVAILABLE_GENERATORS.include?(ARGV[0])
10
+ puts "available generators are: #{AVAILABLE_GENERATORS.join(', ')}"
11
+ exit 1
12
+ end
13
+
14
+ unless ARGV[1] =~ /[a-z\-0-9]+/i
15
+ puts "Please see the documentation for what the second argument should look like"
16
+ puts `rails generate ember:#{ARGV[0]} --help`
17
+ exit 1
18
+ end
19
+
20
+ gen = ARGV.shift
21
+ name = ARGV.shift
22
+ puts `rails generate ember:#{gen} #{name} #{ARGV.join(' ')}`
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ember-gen/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ember-gen"
8
+ spec.version = EmberGen::VERSION
9
+ spec.authors = ["Sean McCleary"]
10
+ spec.email = ["seanmcc@gmail.com"]
11
+ spec.description = %q{generators for ember.js development}
12
+ spec.summary = %q{a better summary to come.}
13
+ spec.homepage = "https://github.com/mrinterweb/ember-gen"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "ember-rails"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,9 @@
1
+ require "ember-gen/version"
2
+
3
+ module EmberGen
4
+ end
5
+
6
+ require 'ember-gen/railtie' if defined?(Rails)
7
+
8
+
9
+
@@ -0,0 +1,30 @@
1
+
2
+ module EmberGen
3
+ class Generate
4
+
5
+ # todo - need to figure out a way to read users preferences for
6
+ # javascript engine and dependency management (AMD, common.js, ES6 module, global)
7
+ # then the correct template can be loaded.
8
+ # There are two likely places I can think that it would be good to load these files.
9
+ # 1. config/environments/development.rb
10
+ # 2. from an ember-gen specific configuration file
11
+ # I don't really like this approach, as much be it is more agnostic
12
+ TEMPLATE_PATH = File.join(File.dirname(__FILE__), 'templates')
13
+
14
+ def initialize(type)
15
+ @type = type
16
+ load_template
17
+ end
18
+
19
+ def print_template
20
+ puts @template_file
21
+ end
22
+
23
+ private
24
+
25
+ def load_template
26
+ @template_file = File.read File.join(TEMPLATE_PATH, "#{@type}_test.coffee.erb")
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+
2
+ module EmberGen
3
+ class Railtie < Rails::Railtie
4
+ rake_tasks do
5
+ Dir[File.join(File.dirname(__FILE__), 'tasks/*.rake')].each { |f| load f }
6
+ end
7
+ end
8
+ end
9
+
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'config')
2
+ require File.join(File.dirname(__FILE__), 'support', 'file_support')
3
+
4
+ module EmberGen
5
+ module Support
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require 'yaml'
2
+
3
+ module EmberGen
4
+ module Support
5
+ class Config
6
+ CONFIG_DIR = File.join(File.dirname(__FILE__), 'configs')
7
+ VENDOR_MAP = File.join(CONFIG_DIR, 'vendor_map.yml')
8
+
9
+ attr_reader :hash
10
+
11
+ def initialize(config)
12
+ case config
13
+ when :vendor_map
14
+ @hash = load_yaml(VENDOR_MAP)
15
+ else
16
+ raise "Config mapping undefined for: #{config}"
17
+ end
18
+ end
19
+
20
+ def load_yaml(file)
21
+ YAML.load_file(file)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ # http://code.jquery.com/jquery/
2
+ jquery:
3
+ generic:
4
+ uncompressed: http://code.jquery.com/jquery-<version>.js
5
+ minified: http://code.jquery.com/jquery-<version>.min.js
6
+ 2x:
7
+ uncompressed: http://code.jquery.com/jquery-2.0.3.js
8
+ minified: http://code.jquery.com/jquery-2.0.3.min.js
9
+ 1x:
10
+ uncompressed: http://code.jquery.com/jquery-1.10.2.js
11
+ minified: http://code.jquery.com/jquery-1.10.2.min.js
@@ -0,0 +1,42 @@
1
+
2
+ module EmberGen
3
+ module Support
4
+ module FileSupport
5
+ require 'json'
6
+ require 'open-uri'
7
+
8
+ def parse_name(path)
9
+ path.match(%r~.*[/](?<name>.+)$~)[:name]
10
+ end
11
+
12
+ def grab_json(url)
13
+ begin
14
+ JSON.parse(download(url).read)
15
+ rescue
16
+ puts "There was a problem fetching y'r JSON"
17
+ end
18
+ end
19
+
20
+ def download(url)
21
+ begin
22
+ puts "Downloading: #{url}"
23
+ tmp_file = open(url)
24
+ puts "downloaded #{tmp_file.size / 1024}KB"
25
+ tmp_file
26
+ rescue OpenURI::HTTPError
27
+ puts "Download failed: #{url}"
28
+ end
29
+ end
30
+
31
+ def download_and_move(url, destination)
32
+ tmp_file = download(url)
33
+ File.rename tmp_file, destination
34
+ end
35
+
36
+ def github_url_to_raw(url)
37
+ url.sub("https://", "https://raw2.").sub('blob/', '')
38
+ end
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1 @@
1
+ This is cool
@@ -0,0 +1,3 @@
1
+ module EmberGen
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,69 @@
1
+ require 'pry'
2
+ require 'ember-gen/support'
3
+
4
+ namespace :embergen do
5
+ namespace :update do
6
+ include EmberGen::Support::FileSupport
7
+
8
+ desc "upgrade ember.js and ember-data.js files takes optional argument of release, stable, canary"
9
+ task :upgrade_ember, :version do |t, args|
10
+ release = args[:version] || 'release'
11
+ detect_version = ->(file) { File.readlines(file).detect { |l| l =~ /@version/ } }
12
+
13
+ ember_path = './vendor/scripts/ember.js'
14
+
15
+ if File.exists?(ember_path)
16
+ puts "Existing ember version: #{detect_version.call(File.open(ember_path, 'r'))}"
17
+ end
18
+
19
+ %w[ember.js ember.min.js ember.prod.js ember-data.js ember-data.prod.js ember-data.min.js].each do |file_name|
20
+ url = "http://builds.emberjs.com/#{release}/#{file_name}"
21
+ download_and_move(url, "./vendor/scripts/#{file_name}")
22
+ if file_name == 'ember.js'
23
+ ember_file = File.open("./vendor/scripts/#{file_name}", 'r')
24
+ puts "Downloaded version: #{detect_version.call(ember_file)}"
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ namespace :install do
32
+ include EmberGen::Support
33
+
34
+ desc "install latest jquery 1.x"
35
+ task "jquery_1x", :option do |t, args|
36
+ task('install:jquery').invoke('1x', args[:option])
37
+ end
38
+
39
+ desc "install latest jquery 2.x"
40
+ task "jquery_2x", :option do |t, args|
41
+ puts 'jquery_2x task called'
42
+ task('install:jquery').invoke('2x', args[:option])
43
+ end
44
+
45
+ desc "install specific version of jquery"
46
+ task :jquery, :version, :option do |t, args|
47
+ puts 'jquery task called'
48
+ puts args.inspect
49
+ version = args[:version]
50
+ option = args[:option]
51
+ option = 'uncompressed' unless %w[uncompressed minified].include?(option)
52
+
53
+ conf = EmberGen::Support::Config.new(:vendor_map)
54
+
55
+ begin
56
+ url = conf.hash['jquery'][version][option]
57
+ rescue
58
+ begin
59
+ url = conf.hash['jquery']['generic'][option]
60
+ url.sub!('<version>', version)
61
+ rescue NoMethodError
62
+ raise "unable to find jquery with: version -> #{version}, option -> #{option}"
63
+ end
64
+ end
65
+ download_and_move(url, "./vendor/assets/javascripts/jquery.js")
66
+ end
67
+ end
68
+
69
+ end # embergen namespace
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ember-gen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sean McCleary
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ember-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: generators for ember.js development
56
+ email:
57
+ - seanmcc@gmail.com
58
+ executables:
59
+ - embergen
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/embergen
69
+ - ember-gen.gemspec
70
+ - lib/ember-gen.rb
71
+ - lib/ember-gen/generate.rb
72
+ - lib/ember-gen/railtie.rb
73
+ - lib/ember-gen/support.rb
74
+ - lib/ember-gen/support/config.rb
75
+ - lib/ember-gen/support/configs/vendor_map.yml
76
+ - lib/ember-gen/support/file_support.rb
77
+ - lib/ember-gen/templates/model_test.coffee.erb
78
+ - lib/ember-gen/version.rb
79
+ - lib/tasks/dependencies.rake
80
+ homepage: https://github.com/mrinterweb/ember-gen
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.2.2
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: a better summary to come.
104
+ test_files: []
105
+ has_rdoc: