motion-gem 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a76f6fe8900fe266344cfaaa4a1e143a9971f81a
4
+ data.tar.gz: 04604f36a3ce8b31fcd02f43f89e980f07503953
5
+ SHA512:
6
+ metadata.gz: bacb1492ec506d4114121970a0783cf72e02b32f3d19efa94eed5b2034c31f3fb9741a06b45893557815bd42341ded650581e020fa28203bf78183872ff40752
7
+ data.tar.gz: 4a421cac7d1881861b6b9715a68ea95c6728efc41d31784096893168ebb6b9937bc66dc60f74cb75c8a39bddefe6af425b29b96cccd0d2aba6c613bfe8ddcd82
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ /.config
3
+ /coverage/
4
+ /InstalledFiles
5
+ /pkg/
6
+ /spec/reports/
7
+ /test/tmp/
8
+ /test/version_tmp/
9
+ /tmp/
10
+ /.yardoc/
11
+ /_yardoc/
12
+ /doc/
13
+ /rdoc/
14
+ /.bundle/
15
+ /lib/bundler/man/
16
+ .rvmrc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ motion-gem (0.0.1)
5
+ thor
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ rake (10.1.0)
11
+ thor (0.18.1)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.3)
18
+ motion-gem!
19
+ rake
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Erran Carey <me@errancarey.com>
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.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Motion Gem
2
+ A extension to the `motion` command that allows generating RubyMotion
3
+ optimized gems. Inspired by the `bundle gem` command.
4
+
5
+ ## Installation
6
+ Add this line to your application's Gemfile:
7
+
8
+ gem 'motion-gem'
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install motion-gem
17
+
18
+ ## Usage
19
+ ```bash
20
+ # Create a RubyMotion gem
21
+ motion gem GEM
22
+
23
+ # Show usage information
24
+ motion gem -h
25
+ ```
26
+
27
+ ## Contributing
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b feature/my-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin feature/my-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/ext/extconf.rb ADDED
@@ -0,0 +1,17 @@
1
+ # Copied and minimized from https://github.com/rubymotion/Joybox
2
+ # View JoyBox at: http://joybox.io
3
+ require 'fileutils'
4
+
5
+ source_directory = File.expand_path('../../lib/motion/gem', __FILE__)
6
+ source_file = File.join(source_directory, 'gem_command.rb')
7
+ motion_directory = File.expand_path('~/Library/RubyMotion')
8
+ command_directory = File.join(motion_directory, 'command')
9
+ destination_file = File.join(command_directory, File.basename(source_file))
10
+
11
+ FileUtils.rm_f File.join(command_directory, 'gem_command.rb')
12
+ FileUtils.mkdir_p(command_directory) unless File.directory?(command_directory)
13
+ FileUtils.rm_f destination_file
14
+ FileUtils.ln_s source_file, destination_file
15
+
16
+ require 'mkmf'
17
+ create_makefile ''
data/lib/motion/gem.rb ADDED
@@ -0,0 +1,3 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise 'The "motion-gem" gem must be required within a RubyMotion project Rakefile.'
3
+ end
@@ -0,0 +1,88 @@
1
+ require 'fileutils'
2
+
3
+ module Motion
4
+ module Gem
5
+ module Command
6
+ module Template
7
+ module_function
8
+ def render(template, destination, config)
9
+ config.each do |key, value|
10
+ instance_variable_set("@#{key}", value)
11
+ end
12
+
13
+ pretty_destination = destination.sub("#{Dir.pwd}/", '')
14
+ content = ERB.new(File.read(template)).result(binding)
15
+
16
+ if File.exists?(destination) && File.read(destination).eql?(content)
17
+ Motion::Project::App.log "\e[0;34;49midentical\e[0m", pretty_destination
18
+ return
19
+ elsif File.exists?(destination)
20
+ Motion::Project::App.log "\e[0;31;49mconflict\e[0m", "#{pretty_destination} already exists"
21
+ print "Overwrite #{destination}? [Yn] "
22
+ user_input = $stdin.gets.chomp
23
+
24
+ if user_input.downcase[0].eql?('n')
25
+ Motion::Project::App.log "\e[0;33;49mskip\e[0m", pretty_destination
26
+ return
27
+ else
28
+ Motion::Project::App.log "\e[0;33;49mforce\e[0m", pretty_destination
29
+ forced = true
30
+ end
31
+ end
32
+
33
+ FileUtils.mkdir_p(File.dirname(destination))
34
+ File.open(destination, 'w') do |file|
35
+ file << content
36
+ end
37
+
38
+ unless forced
39
+ Motion::Project::App.log "\e[0;32;49mcreate\e[0m", pretty_destination
40
+ end
41
+ end
42
+
43
+ def scaffold_gem(gem_name)
44
+ gem_name = gem_name.chomp('/')
45
+ gem_path = gem_name.tr('-', '/')
46
+ destination = File.join(Dir.pwd, gem_name)
47
+
48
+ constant_name = gem_name.split('_').map(&:capitalize).join
49
+ constant_name = constant_name.split('-').map(&:capitalize).join('::') if constant_name =~ /-/
50
+ constants = constant_name.split('::')
51
+
52
+ git_user = `git config user.name`.chomp
53
+ git_email = `git config user.email`.chomp
54
+
55
+ config = {
56
+ :gem_name => gem_name,
57
+ :gem_path => gem_path,
58
+ :constant_name => constant_name,
59
+ :constants => constants,
60
+ :author => git_user,
61
+ :email => git_email
62
+ }
63
+
64
+ if Motion::Project::App.respond_to?(:template)
65
+ template_ext = Motion::Project::App.template
66
+ end
67
+ template_ext ||= 'ios'
68
+ template_root = File.join(File.expand_path('../../templates/', __FILE__), template_ext)
69
+
70
+ render File.join(template_root, 'Gemfile.erb'), File.join(destination, 'Gemfile'), config
71
+ render File.join(template_root, 'LICENSE.md.erb'), File.join(destination, 'LICENSE.md'), config
72
+ render File.join(template_root, 'README.md.erb'), File.join(destination, 'README.md'), config
73
+ render File.join(template_root, 'Rakefile.erb'), File.join(destination, 'Rakefile'), config
74
+ render File.join(template_root, 'gitignore.erb'), File.join(destination, '.gitignore'), config
75
+ render File.join(template_root, 'newgem.gemspec.erb'), File.join(destination, "#{gem_name}.gemspec"), config
76
+ render File.join(template_root, 'lib/newgem.rb.erb'), File.join(destination, "lib/#{gem_path}.rb"), config
77
+ render File.join(template_root, 'lib/newgem/version.rb.erb'), File.join(destination, "lib/#{gem_path}/version.rb"), config
78
+
79
+ puts "Initializing git repository in #{destination}"
80
+ Dir.chdir(destination) do
81
+ `git init`
82
+ `git add .`
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,60 @@
1
+ require 'optparse'
2
+ require File.expand_path('../command/template.rb', File.readlink(__FILE__))
3
+
4
+ module Motion
5
+ module Project
6
+ class GemCommand < Command
7
+ self.name = 'gem'
8
+ self.help = 'Create a new RubyMotion gem'
9
+
10
+ @@description = <<-DESCRIPTION
11
+ Creates a skeleton RubyMotion Gem.
12
+ DESCRIPTION
13
+
14
+ @@example = <<-EXAMPLE
15
+ `motion gem GEM`
16
+
17
+ This creates the following directory structure:
18
+ GEM/
19
+ ├── .gitignore
20
+ ├── Gemfile
21
+ ├── LICENSE.md
22
+ ├── README.md
23
+ ├── Rakefile
24
+ ├── lib/
25
+ │   ├── GEM/
26
+ │  │  ├── version.rb
27
+ │   └── GEM.rb
28
+ └── GEM.gemspec
29
+ EXAMPLE
30
+
31
+ def run(args)
32
+ option_parser = OptionParser.new do |opt|
33
+ opt.banner = 'Usage:'
34
+ opt.separator ' motion gem <gem-name>'
35
+ opt.separator ''
36
+ opt.separator 'Options:'
37
+ opt.on('-h', '--help', 'Shows this screen')
38
+ opt.separator ''
39
+ opt.separator 'Description:'
40
+ opt.separator @@description
41
+ opt.separator ''
42
+ opt.separator 'Example:'
43
+ opt.separator @@example
44
+ end
45
+
46
+ option_parser.parse!
47
+ if args.count > 1
48
+ puts option_parser
49
+ exit 1
50
+ elsif args.count == 0
51
+ puts option_parser
52
+ exit
53
+ end
54
+
55
+ gem_name = args.first
56
+ Motion::Gem::Command::Template.scaffold_gem(gem_name)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in <%= @gem_name %>.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <%= Time.now.year %> <%= (@author.nil? || @author.empty?) ? '[fullname]' : @author %> <<%= (@email.nil? || @author.empty?) ? 'email address' : @email %>>
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # <%= @constant_name %>
2
+ TODO: Write a gem description
3
+
4
+ ## Installation
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem '<%= @gem_name %>'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ ```bash
14
+ bundle
15
+ ```
16
+
17
+ Or install it yourself as:
18
+
19
+ ```bash
20
+ gem install <%= @gem_name %>
21
+ ```
22
+
23
+ ## Usage
24
+ TODO: Write usage instructions here
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it ( http://github.com/<my-github-username>/<%= @gem_name %>/fork )
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,41 @@
1
+ # Ruby
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Documentation cache and generated files:
14
+ /.yardoc/
15
+ /_yardoc/
16
+ /doc/
17
+ /rdoc/
18
+
19
+ ## Environment normalisation:
20
+ /.bundle/
21
+ /lib/bundler/man/
22
+
23
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
24
+ .rvmrc
25
+
26
+ # RubyMotion
27
+ .dat*
28
+ .repl_history
29
+ /build/
30
+ tags
31
+
32
+ # Editor files
33
+ .DS_Store
34
+ nbproject
35
+ .redcar
36
+ *.swp
37
+ *.swo
38
+ ~
39
+ .eprj
40
+ /vendor/Pods
41
+ *.nib
@@ -0,0 +1,12 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise 'The "<%= @gem_name %>" gem must be required within a RubyMotion project Rakefile.'
3
+ end
4
+
5
+ Motion::Project::App.setup do |app|
6
+ dir = File.dirname(__FILE__)
7
+ app.files += Dir.glob(File.join(dir, '**/*.rb'))
8
+
9
+ # app.pods do
10
+ # pod 'AFNetworking'
11
+ # end
12
+ end
@@ -0,0 +1,5 @@
1
+ require '<%= @gem_path %>/version'
2
+ <% @constants.each_with_index.map do |constant, index| %>
3
+ <%= ' ' * index %>module <%= constant %><% end %>
4
+ <%= ' ' * @constants.count %>VERSION = '0.0.1'<% (@constants.count - 1).downto(0) do |index| %>
5
+ <%= ' ' * index %>end<% end %>
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require '<%= @gem_path %>/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = '<%= @gem_name %>'
8
+ spec.version = <%= @constant_name %>::VERSION
9
+ spec.summary = %q{TODO: Write a short summary. Required.}
10
+ spec.description = %q{TODO: Write a longer description. Optional.}
11
+
12
+ spec.authors = ['<%= (@author.nil? || @author.empty?) ? 'TODO: Write your name' : @author %>']
13
+ spec.email = ['<%= (@email.nil? || @author.empty?) ? 'TODO: Write your email address' : @email %>']
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler' # , '~> 1.3'
23
+ spec.add_development_dependency 'rake'
24
+
25
+ # spec.add_runtime_dependency 'motion-cocoapods'
26
+ end
@@ -0,0 +1,5 @@
1
+ module Motion
2
+ module Gem
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -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 'motion/gem/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'motion-gem'
8
+ spec.version = Motion::Gem::VERSION
9
+ spec.description = %q{A RubyMotion gem for scaffolding other RubyMotion gems}
10
+ spec.summary = %q{`bundle gem` for RubyMotion}
11
+
12
+ spec.authors = ['Erran Carey']
13
+ spec.email = ['me@errancarey.com']
14
+ spec.homepage = 'https://github.com/ipwnstuff'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.extensions = ['ext/extconf.rb']
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Erran Carey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A RubyMotion gem for scaffolding other RubyMotion gems
42
+ email:
43
+ - me@errancarey.com
44
+ executables: []
45
+ extensions:
46
+ - ext/extconf.rb
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - .ruby-version
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.md
54
+ - README.md
55
+ - Rakefile
56
+ - ext/extconf.rb
57
+ - lib/motion/gem.rb
58
+ - lib/motion/gem/command/template.rb
59
+ - lib/motion/gem/gem_command.rb
60
+ - lib/motion/gem/templates/ios/Gemfile.erb
61
+ - lib/motion/gem/templates/ios/LICENSE.md.erb
62
+ - lib/motion/gem/templates/ios/README.md.erb
63
+ - lib/motion/gem/templates/ios/Rakefile.erb
64
+ - lib/motion/gem/templates/ios/gitignore.erb
65
+ - lib/motion/gem/templates/ios/lib/newgem.rb.erb
66
+ - lib/motion/gem/templates/ios/lib/newgem/version.rb.erb
67
+ - lib/motion/gem/templates/ios/newgem.gemspec.erb
68
+ - lib/motion/gem/version.rb
69
+ - motion-gem.gemspec
70
+ homepage: https://github.com/ipwnstuff
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.0.3
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: '`bundle gem` for RubyMotion'
94
+ test_files: []
95
+ has_rdoc: