pindah 0.1.0.alpha

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,6 @@
1
+ === 0.1.0 / ??
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,11 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ bin/pindah
6
+ lib/pindah.rb
7
+ lib/pindah_cli.rb
8
+ templates/initial_activity.mirah
9
+ templates/build.xml
10
+ test/fixtures/HelloWorld.mirah
11
+ test/pindah_cli_test.rb
@@ -0,0 +1,61 @@
1
+ # pindah
2
+
3
+ A tool for writing Android applications in [Mirah](http://mirah.org).
4
+
5
+ ## Requirements
6
+
7
+ You must have the [Android SDK](http://d.android.com/sdk/) installed
8
+ with the <tt>tools/</tt> directory placed on your $PATH. Inside
9
+ <tt>tools/</tt>, the <tt>android</tt> program will allow you to
10
+ download "platform" packages corresponding with Android versions you
11
+ wish to develop against. You'll need to install "Android SDK Platform
12
+ tools" and at least one platform revision to get started. At the time
13
+ of this writing, Android 2.1 (revision 7)
14
+ [covers most of the market](http://developer.android.com/resources/dashboard/platform-versions.html)
15
+ and is a reasonable target for new applications. Once the platform
16
+ tools are installed, place the SDK's <tt>platform-tools/</tt>
17
+ directory on your $PATH as well.
18
+
19
+ You'll also need [JRuby](http://jruby.org) installed with bin/ on your
20
+ $PATH. If your gem and rake are not from from JRuby, prefix the gem
21
+ and rake commands with jruby -S:
22
+
23
+ $ gem install pindah
24
+
25
+ ## Usage
26
+
27
+ See [Garrett](http://github.com/technomancy/Garrett) for an example of
28
+ basic usage.
29
+
30
+ TODO: project template creation is not complete
31
+
32
+ $ pindah hello.world hello_world [HelloActivity]
33
+
34
+ $ cd hello_world && tree
35
+
36
+ [TODO: project skeleton listing]
37
+
38
+ $ rake -T
39
+
40
+ rake clean # Removes output files created by other targets.
41
+ rake compile # Compiles project's .mirah files into .class files
42
+ rake debug # Builds the application and signs it with a debug key.
43
+ rake install # Installs/reinstalls the debug package onto a running ...
44
+ rake javac # Compiles R.java and other gen/ files.
45
+ rake logcat # Tail logs from a device or a device or emulator
46
+ rake release # Builds the application.
47
+ rake spec # Print the project spec
48
+ rake uninstall # Uninstalls the application from a running emulator or dev...
49
+
50
+ ## See Also
51
+
52
+ If Mirah is just too low-level and you need something more dynamic,
53
+ you can try [Ruboto](https://github.com/ruboto/ruboto-core/), though
54
+ be warned there is a very significant overhead it brings with it from
55
+ JRuby's runtime.
56
+
57
+ ## License
58
+
59
+ Released under the Apache 2.0 license.
60
+
61
+ Copyright (c) 2011 Phil Hagelberg, Nick Plante, J.D. Huntington
@@ -0,0 +1,20 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.spec 'pindah' do |h|
7
+ developer('Phil Hagelberg', 'technomancy@gmail.com')
8
+ h.url = "http://github.com/mirah/pindah"
9
+ h.readme_file = "README.md"
10
+ h.summary = "A tool for writing Android applications in Mirah"
11
+ extra_deps << ["mirah", ">= 0.0.5"]
12
+ end
13
+
14
+ # vim: syntax=ruby
15
+
16
+ Rake::TestTask.new do |t|
17
+ t.libs << "test"
18
+ t.test_files = FileList['test/**/*.rb']
19
+ t.verbose = true
20
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'pindah_cli'))
4
+ begin
5
+ PindahCLI.create *ARGV
6
+ rescue ArgumentError
7
+ puts "Usage: #{File.basename(__FILE__)} org.mirah.HelloWorld ~/hello_world [HelloActivity]"
8
+ end
9
+
10
+ abort "TODO: create project skeleton: rakefile, manifest, resources"
@@ -0,0 +1,90 @@
1
+ require "rake"
2
+ require "fileutils"
3
+ require "pp"
4
+ require "erb"
5
+
6
+ begin
7
+ require 'ant'
8
+ rescue LoadError
9
+ abort 'This Rakefile requires JRuby. Please use jruby -S rake.'
10
+ end
11
+
12
+ require "mirah"
13
+
14
+ module Pindah
15
+ VERSION = '0.1.0.alpha'
16
+
17
+ def self.infer_sdk_location(path)
18
+ tools = path.split(":").detect {|p| File.exists? "#{p}/android" }
19
+ File.expand_path("#{tools}/..")
20
+ end
21
+
22
+ DEFAULTS = { :output => File.expand_path("bin"),
23
+ :src => File.expand_path("src"),
24
+ :classpath => Dir["jars/*jar"],
25
+ :sdk => Pindah.infer_sdk_location(ENV["PATH"])
26
+ }
27
+
28
+ ANT_TASKS = ["clean", "javac", "compile", "debug", "release",
29
+ "install", "uninstall"]
30
+
31
+ task :generate_manifest # TODO: generate from yaml?
32
+
33
+ desc "Tail logs from a device or a device or emulator"
34
+ task :logcat do
35
+ system "adb -d logcat #{@spec[:log_filter]}"
36
+ end
37
+
38
+ desc "Print the project spec"
39
+ task :spec do
40
+ pp @spec
41
+ end
42
+
43
+ task :default => [:install]
44
+
45
+ def self.spec=(spec)
46
+ abort "Must provide :target version in Pindah.spec!" if !spec[:target]
47
+ abort "Must provide :name in Pindah.spec!" if !spec[:name]
48
+
49
+ @spec = DEFAULTS.merge(spec)
50
+
51
+ @spec[:root] = File.expand_path "."
52
+ @spec[:classes] ||= "#{@spec[:output]}/classes"
53
+ @spec[:classpath] << @spec[:classes]
54
+ @spec[:classpath] << "#{@spec[:sdk]}/platforms/#{@spec[:target]}/android.jar"
55
+ @spec[:log_spec] ||= "ActivityManager:I #{@spec[:name]}:D " +
56
+ "AndroidRuntime:E *:S"
57
+
58
+ ant_setup
59
+ end
60
+
61
+ def self.ant_setup
62
+ @ant = Ant.new
63
+
64
+ # TODO: this is lame, but ant interpolation doesn't work for project name
65
+ build_template = ERB.new(File.read(File.join(File.dirname(__FILE__), '..',
66
+ 'templates', 'build.xml')))
67
+ build = "/tmp/pindah-#{Process.pid}-build.xml"
68
+ File.open(build, "w") { |f| f.puts build_template.result(binding) }
69
+ at_exit { File.delete build }
70
+
71
+ { "target" => @spec[:target],
72
+ "target-version" => @spec[:target],
73
+ "sdk.dir" => @spec[:sdk],
74
+ "classes" => @spec[:classes],
75
+ "classpath" => @spec[:classpath].join(Java::JavaLang::System::
76
+ getProperty("path.separator"))
77
+ }.each do |key, value|
78
+ @ant.project.set_user_property(key, value)
79
+ end
80
+
81
+ # TODO: compile task execs mirahc instead of running inside current JVM
82
+ Ant::ProjectHelper.configure_project(@ant.project, java.io.File.new(build))
83
+
84
+ # Turn ant tasks into rake tasks
85
+ ANT_TASKS.each do |name, description|
86
+ desc @ant.project.targets[name].description
87
+ task(name) { @ant.project.execute_target(name) }
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,42 @@
1
+ require 'fileutils'
2
+
3
+ module PindahCLI
4
+ DEFAULT_TARGET = 'android-7'
5
+ DEFAULT_VERSION = 'android-2.1'
6
+
7
+ def self.log(msg)
8
+ STDERR.puts msg
9
+ end
10
+
11
+ def self.create(namespace, location, activity_name=nil)
12
+ segments = namespace.split('.')
13
+ src_dir = File.join(location, 'src', *segments)
14
+ FileUtils.mkdir_p src_dir
15
+ log "Created '#{src_dir}'."
16
+
17
+ spec_location = File.join(location, 'Pindah.spec')
18
+ spec_template = File.read(File.join(File.dirname(__FILE__),
19
+ '..', 'templates',
20
+ 'Pindah.spec'))
21
+
22
+ File.open(spec_location, 'w') do |f|
23
+ f.puts spec_template.gsub(/PROJECT_NAME/, segments[-1]).
24
+ gsub(/API_TARGET/, DEFAULT_TARGET).
25
+ gsub(/API_VERSION/, DEFAULT_VERSION)
26
+ end
27
+ log "Created Pindah spec file in '#{spec_location}'."
28
+
29
+
30
+ if activity_name
31
+ activity_location = File.join(src_dir, "#{activity_name}.mirah")
32
+ activity_template = File.read(File.join(File.dirname(__FILE__),
33
+ '..', 'templates',
34
+ 'initial_activity.mirah'))
35
+
36
+ File.open(activity_location, 'w') do |f|
37
+ f.puts activity_template.gsub(/INITIAL_ACTIVITY/, activity_name)
38
+ end
39
+ log "Created Activity '#{activity_name}' in '#{activity_location}'."
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project name="<%= @spec[:name] %>">
3
+ <path id="android.antlibs">
4
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
5
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
6
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
7
+ </path>
8
+
9
+ <taskdef name="setup"
10
+ classname="com.android.ant.SetupTask"
11
+ classpathref="android.antlibs" />
12
+
13
+ <target name="javac" description="Compiles R.java and other gen/ files.">
14
+ <javac srcdir="gen" destdir="${classes}" includeantruntime="false" />
15
+ </target>
16
+
17
+ <target name="compile" depends="-resource-src, -aidl, javac"
18
+ description="Compiles project's .mirah files into .class files">
19
+ <exec executable="mirahc" dir="src">
20
+ <arg line="-c ${classpath}" />
21
+ <arg line="-d ${classes}" />
22
+ <arg value="." />
23
+ </exec>
24
+ </target>
25
+
26
+ <setup />
27
+ </project>
@@ -0,0 +1,7 @@
1
+ import android.app.Activity
2
+
3
+ class INITIAL_ACTIVITY < Activity
4
+ def onCreate(state)
5
+ super state
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ import android.app.Activity
2
+
3
+ class HelloWorld < Activity
4
+ def onCreate(state)
5
+ super state
6
+ end
7
+ end
@@ -0,0 +1,50 @@
1
+ require 'test/unit'
2
+ require 'tempfile'
3
+ require 'fileutils'
4
+ require 'rubygems'
5
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'pindah_cli'))
6
+
7
+ class PindahCLITest < Test::Unit::TestCase
8
+ def setup
9
+ $local_pwd ||= File.expand_path(File.dirname(__FILE__))
10
+ @project_path = File.expand_path(Tempfile.new('pindah').path + ".d")
11
+ FileUtils.mkdir_p @project_path
12
+ Dir.chdir @project_path
13
+ end
14
+
15
+ def teardown
16
+ FileUtils.rm_rf @project_path
17
+ end
18
+
19
+ def test_create_should_create_basic_project_structure
20
+ PindahCLI.create('tld.pindah.testapp', '.')
21
+ assert File.directory?(File.join(@project_path, 'src', 'tld', 'pindah', 'testapp'))
22
+ end
23
+
24
+ def test_create_should_create_pindah_spec_file
25
+ PindahCLI.create('tld.pindah.testapp', '.')
26
+ assert File.exists?(File.join(@project_path, 'Pindah.spec'))
27
+
28
+ expected = File.read(File.join($local_pwd,
29
+ 'fixtures',
30
+ 'Pindah.spec'))
31
+ actual = File.read(File.join(@project_path,
32
+ 'Pindah.spec'))
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_create_should_create_an_activity_if_desired
37
+ PindahCLI.create('tld.pindah.testapp', '.', 'HelloWorld')
38
+
39
+ expected = File.read(File.join($local_pwd,
40
+ 'fixtures',
41
+ 'HelloWorld.mirah'))
42
+ actual = File.read(File.join(@project_path,
43
+ 'src',
44
+ 'tld',
45
+ 'pindah',
46
+ 'testapp',
47
+ 'HelloWorld.mirah'))
48
+ assert_equal expected, actual
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pindah
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 6
5
+ version: 0.1.0.alpha
6
+ platform: ruby
7
+ authors:
8
+ - Phil Hagelberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-02-02 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: mirah
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.5
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: hoe
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 2.8.0
36
+ type: :development
37
+ version_requirements: *id002
38
+ description: ""
39
+ email:
40
+ - technomancy@gmail.com
41
+ executables:
42
+ - pindah
43
+ extensions: []
44
+
45
+ extra_rdoc_files:
46
+ - History.txt
47
+ - Manifest.txt
48
+ files:
49
+ - History.txt
50
+ - Manifest.txt
51
+ - README.md
52
+ - Rakefile
53
+ - bin/pindah
54
+ - lib/pindah.rb
55
+ - lib/pindah_cli.rb
56
+ - templates/initial_activity.mirah
57
+ - templates/build.xml
58
+ - test/fixtures/HelloWorld.mirah
59
+ - test/pindah_cli_test.rb
60
+ has_rdoc: true
61
+ homepage: http://github.com/mirah/pindah
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --main
67
+ - README.md
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">"
80
+ - !ruby/object:Gem::Version
81
+ version: 1.3.1
82
+ requirements: []
83
+
84
+ rubyforge_project: pindah
85
+ rubygems_version: 1.5.0
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: A tool for writing Android applications in Mirah
89
+ test_files: []
90
+