appjam 0.1.7.1 → 0.1.8.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,5 +57,10 @@ end # Appjam
57
57
  ##
58
58
  # We add our generators to Appjam::Genererator
59
59
  #
60
- Appjam::Generators.load_paths << Dir[File.dirname(__FILE__) + '/appjam/generators/{project,model,submodule}.rb']
60
+ Appjam::Generators.load_paths << Dir[File.dirname(__FILE__) + '/appjam/generators/{project,model,submodule,gist}.rb']
61
+
62
+ ##
63
+ # We add our gists to Appjam::Genererator
64
+ #
65
+ Appjam::Generators.load_paths << Dir[File.dirname(__FILE__) + '/appjam/generators/gist/*.rb']
61
66
 
@@ -44,7 +44,7 @@ module Appjam
44
44
  else
45
45
  puts colorize("Usage: appjam [OPTIONS] [ARGS]")
46
46
  puts
47
- puts colorize("APPJAM OPTIONS", { :foreground => :blue})
47
+ puts colorize("Appjam Options")
48
48
  opt = [{ :category => "objective c (iphone)", :command => "appjam project todo", :description => "generate iphone project skeleton"},
49
49
  { :category => "objective c (iphone)", :command => "appjam model user", :description => "generate iphone project data model"},
50
50
  { :category => "objective c (iphone)", :command => "appjam submodule three20", :description => "fetch three20 subproject from github.com"},
@@ -53,6 +53,12 @@ module Appjam
53
53
  { :category => "objective c (iphone)", :command => "appjam submodule kissxml", :description => "fetch kissxml subproject from code.google.com"}
54
54
  ]
55
55
  View.render(opt, RENDER_OPTIONS)
56
+ puts
57
+ puts colorize("Gist Option")
58
+ gitopt = [
59
+ { :category => "singleton", :command => "appjam gist singleton", :description => "Simple Singleton Objective C Snippet"}
60
+ ]
61
+ View.render(gitopt, RENDER_OPTIONS)
56
62
  puts
57
63
  end
58
64
  end
@@ -0,0 +1,106 @@
1
+ require 'rubygems'
2
+ require 'fileutils'
3
+ require 'net/http'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require "open-uri"
7
+ require 'tempfile'
8
+ require File.dirname(__FILE__) + '/jam'
9
+
10
+ module Appjam
11
+ module Generators
12
+ class Gist < Jam
13
+
14
+ class << self
15
+ def self.attr_rw(*attrs)
16
+ attrs.each do |attr|
17
+ class_eval %Q{
18
+ def #{attr}(val=nil)
19
+ val.nil? ? @#{attr} : @#{attr} = val
20
+ end
21
+ }
22
+ end
23
+ end
24
+ attr_rw :gist_name, :gist_description, :gist_id, :gist_body
25
+ def preview_gist(gid)
26
+ uri = URI("https://gist.github.com/#{gid}.txt")
27
+ http = Net::HTTP.new(uri.host, uri.port)
28
+ if uri.scheme == 'https'
29
+ http.use_ssl = true
30
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
31
+ end
32
+
33
+ result = http.start {|h| h.request(Net::HTTP::Get.new(uri.path))}
34
+ tempfile = Tempfile.new('gist')
35
+ tempfile.puts(result)
36
+ tempfile.close
37
+
38
+ if system('which qlmanage')
39
+ system("qlmanage -c public.plain-text -p #{tempfile.path} >& /dev/null")
40
+ end
41
+ end
42
+
43
+ def download_gists(username, page=1)
44
+ puts "-- Downloading page #{page} of gists --"
45
+ url = URI.parse("http://gist.github.com")
46
+ res = Net::HTTP.start(url.host, url.port) do |http|
47
+ response = http.get("/#{username}?page=#{page}")
48
+ if response.code == '200'
49
+ links = get_links(response.body)
50
+ links.each do |link, gist_id|
51
+ puts "git://gist.github.com/#{gist_id}.git"
52
+ if File.directory?("Support/#{gist_id}")
53
+ `cd Support/#{gist_id} && git pull ; cd ..`
54
+ else
55
+ `git clone git://gist.github.com/#{gist_id}.git Support/#{gist_id}`
56
+ end
57
+ end
58
+ download_gists(username, page+1) unless links.empty?
59
+ end
60
+ end
61
+ end
62
+
63
+ def download_gist(gist_id)
64
+ puts "-- fetching gist --"
65
+ puts "#{gist_id}.git"
66
+ if File.directory?("Support/#{gist_id}")
67
+ `cd Support/#{gist_id} && git pull ; cd ..`
68
+ else
69
+ `git clone git://gist.github.com/#{gist_id}.git Support/#{gist_id}`
70
+ end
71
+ end
72
+ end
73
+
74
+ # Add this generator to our appjam
75
+ Appjam::Generators.add_generator(:gist, self)
76
+
77
+ # Define the source Gist root
78
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
79
+ def self.banner; "appjam gist [name]"; end
80
+
81
+ # Include related modules
82
+ include Thor::Actions
83
+ include Appjam::Generators::Actions
84
+
85
+ desc "Description:\n\n\tappjam will generates function snippet for iphone"
86
+
87
+ argument :name, :desc => "The name of your function"
88
+
89
+ class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
90
+ class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
91
+
92
+ def in_app_root?
93
+ File.exist?('Classes')
94
+ end
95
+
96
+ def create_gist
97
+
98
+ end
99
+
100
+ end # Gist
101
+ end # Generators
102
+ end # Appjam
103
+
104
+ __END__
105
+ # put your Gist command here
106
+
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../gist'
2
+
3
+ module Appjam
4
+ module Generators
5
+ class Singleton < Gist
6
+ gist_name "singleton"
7
+ gist_id "https://gist.github.com/979981"
8
+ gist_description "Singletons in Objective C"
9
+
10
+ # Add this generator to our appjam
11
+ Appjam::Generators.add_generator(:gist, self)
12
+
13
+ def create_git
14
+ if in_app_root?
15
+ valid_constant?(options[:gist] || name)
16
+ @gist_name = (options[:app] || name).gsub(/W/, "_").downcase
17
+ @class_name = (options[:app] || name).gsub(/W/, "_").capitalize
18
+ @developer = "eiffel"
19
+ @created_on = Date.today.to_s
20
+ self.destination_root = options[:root]
21
+
22
+ if @gist_name == 'singleton'
23
+ Gist::download_gist(979981)
24
+ Gist::preview_gist(979981)
25
+ eval(File.read(__FILE__) =~ /^__END__/ && $' || '')
26
+
27
+ say "================================================================="
28
+ say "Your function snippet has been generated."
29
+ say "================================================================="
30
+
31
+ end
32
+ else
33
+ puts
34
+ puts '-'*70
35
+ puts "You are not in an iphone project folder"
36
+ puts '-'*70
37
+ puts
38
+ end
39
+ end
40
+
41
+ end # Singleton
42
+ end # Generators
43
+ end # Appjam
44
+
45
+ __END__
@@ -2,8 +2,8 @@ module Appjam
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 7
6
- BUILD = '1'
5
+ PATCH = 8
6
+ BUILD = 'pre'
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').chomp('.')
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appjam
3
3
  version: !ruby/object:Gem::Version
4
- hash: 89
5
- prerelease:
4
+ hash: 961916012
5
+ prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 7
10
- - 1
11
- version: 0.1.7.1
9
+ - 8
10
+ - pre
11
+ version: 0.1.8.pre
12
12
  platform: ruby
13
13
  authors:
14
14
  - Eiffel Q
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-05-18 00:00:00 Z
19
+ date: 2011-05-20 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  type: :runtime
@@ -377,6 +377,8 @@ files:
377
377
  - lib/appjam/command.rb
378
378
  - lib/appjam/generators/actions.rb
379
379
  - lib/appjam/generators/cli.rb
380
+ - lib/appjam/generators/gist.rb
381
+ - lib/appjam/generators/gist/singleton.rb
380
382
  - lib/appjam/generators/jam.rb
381
383
  - lib/appjam/generators/model.rb
382
384
  - lib/appjam/generators/project.rb
@@ -488,12 +490,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
488
490
  required_rubygems_version: !ruby/object:Gem::Requirement
489
491
  none: false
490
492
  requirements:
491
- - - ">="
493
+ - - ">"
492
494
  - !ruby/object:Gem::Version
493
- hash: 3
495
+ hash: 25
494
496
  segments:
495
- - 0
496
- version: "0"
497
+ - 1
498
+ - 3
499
+ - 1
500
+ version: 1.3.1
497
501
  requirements: []
498
502
 
499
503
  rubyforge_project: