From 8b939ce5f56d9e842bf80d74a1f403c1a7758d45 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 10 Dec 2012 17:53:55 +0800 Subject: [PATCH] Change autogen as a ruby gem, then we can use `nsrails g ~/railsapp` to generate files in anywhere. --- .gitignore | 6 +++--- autogen/{generate => bin/nsrails} | 11 ++++++----- autogen/nsrails.gemspec | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) rename autogen/{generate => bin/nsrails} (97%) create mode 100644 autogen/nsrails.gemspec diff --git a/.gitignore b/.gitignore index bad0ef6..2d0376a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,7 @@ project.xcworkspace # Ignore folders made with autogen -*.gen/ - +Models/ # Ignore RubyMotion noise @@ -19,4 +18,5 @@ build-iPhoneOS build-iPhoneSimulator build *.bridgesupport -.* \ No newline at end of file +.* +*.gem diff --git a/autogen/generate b/autogen/bin/nsrails similarity index 97% rename from autogen/generate rename to autogen/bin/nsrails index 9f694b1..08b2ab1 100755 --- a/autogen/generate +++ b/autogen/bin/nsrails @@ -443,11 +443,10 @@ class Runner end def self.print_help - this_file = File.expand_path(File.dirname(__FILE__))+"/generate" pwd = Dir.pwd puts "Usage:" - puts " #{this_file[pwd.length+1..this_file.length]} [options] APP_PATH" + puts " nsrails g [options] RAILS_APP_PATH" puts "" puts "Options for property translation:" puts " --ruby Generate Ruby classes for MacRuby and RubyMotion" @@ -468,15 +467,17 @@ begin $options = Runner.parse_options(ARGV) if ($options[:help]) print_help - else + elsif ($options[:g]) $options[:project] ||= $options[:path].split("/").last $options[:company] ||= $options[:author] || ENV["USER"] || ENV["USERNAME"] - $options[:author] ||= "NSRails autogen" + $options[:author] ||= "NSRails Generator" - output = File.expand_path(File.dirname(__FILE__))+"/"+$options[:project]+".gen" + output = Dir.pwd + "/" + "Models" Runner.class_variable_set(:@@output_path, output) Runner.run + else + print_help end rescue => e puts "Error! #{e}\nUse --help or -h for help." diff --git a/autogen/nsrails.gemspec b/autogen/nsrails.gemspec new file mode 100644 index 0000000..3c23483 --- /dev/null +++ b/autogen/nsrails.gemspec @@ -0,0 +1,18 @@ +# coding: utf-8 +Gem::Specification.new do |s| + s.name = %q{nsrails} + s.version = "0.0.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Dan Hassin", "Jason Lee"] + s.email = %q{huacnlee@gmail.com} + s.files = Dir['readme.md', 'bin/**/*', 'lib/**/{*,.[a-z]*}'] + s.bindir = 'bin' + s.executables = ['nsrails'] + s.homepage = %q{https://github.com/huacnlee/rails-settings-cached} + s.require_paths = ["lib"] + s.summary = %q{NSRails is a light-weight Objective-C framework that provides your classes with a high-level, ActiveResource-like API. This means CRUD and other operations on your corresponding Rails objects can be called natively via Objective-C methods.} + + s.add_dependency 'activesupport', "> 3.0.0" +end +