pindah 0.1.2 → 0.1.3
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.
- checksums.yaml +7 -0
- data/History.txt +21 -12
- data/Manifest.txt +19 -19
- data/README.md +192 -118
- data/Rakefile +11 -20
- data/bin/pindah +9 -9
- data/lib/pindah.rb +196 -100
- data/lib/pindah_cli.rb +77 -77
- data/templates/.gitignore +2 -2
- data/templates/AndroidManifest.xml +19 -19
- data/templates/Rakefile +7 -7
- data/templates/build.xml +47 -32
- data/templates/initial_activity.mirah +10 -10
- data/templates/main.xml +13 -13
- data/templates/strings.xml +4 -4
- data/test/fixtures/HelloWorld.mirah +10 -10
- data/test/pindah_cli_test.rb +85 -85
- metadata +85 -89
- data/.gemtest +0 -0
data/lib/pindah_cli.rb
CHANGED
@@ -1,77 +1,77 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'erb'
|
3
|
-
|
4
|
-
module PindahCLI
|
5
|
-
DEFAULT_TARGET_VERSION = '2.
|
6
|
-
|
7
|
-
def self.create(package, location=nil, activity_name=nil)
|
8
|
-
segments = package.split('.')
|
9
|
-
location ||= segments.last
|
10
|
-
src_dir = File.join(location, 'src', *segments)
|
11
|
-
|
12
|
-
mkdir location, File.join('src', *segments)
|
13
|
-
mkdir location, 'bin'
|
14
|
-
mkdir location, 'libs'
|
15
|
-
mkdir location, 'res'
|
16
|
-
mkdir location, 'res/drawable-hdpi'
|
17
|
-
mkdir location, 'res/drawable-ldpi'
|
18
|
-
mkdir location, 'res/drawable-mdpi'
|
19
|
-
mkdir location, 'res/layout'
|
20
|
-
mkdir location, 'res/values'
|
21
|
-
|
22
|
-
name =
|
23
|
-
app_name = name.split(/[-_]/).map{ |w| w.capitalize }.join(" ")
|
24
|
-
|
25
|
-
FileUtils.mkdir_p src_dir
|
26
|
-
|
27
|
-
create_templated("Rakefile", location, binding)
|
28
|
-
create_templated("AndroidManifest.xml", location, binding)
|
29
|
-
create_templated("main.xml", File.join(location, 'res', 'layout'), binding)
|
30
|
-
create_templated("strings.xml", File.join(location, 'res', 'values'), binding)
|
31
|
-
create_templated(".gitignore", location, binding)
|
32
|
-
|
33
|
-
# Default icons of various sizes
|
34
|
-
["hdpi", "mdpi", "ldpi"].each do |s|
|
35
|
-
FileUtils.cp(File.join(File.dirname(__FILE__), '..', 'templates', "res",
|
36
|
-
"drawable-#{s}", "ic_launcher.png"),
|
37
|
-
File.join(location, "res", "drawable-#{s}", "ic_launcher.png"))
|
38
|
-
end
|
39
|
-
|
40
|
-
log "Created project in #{location}."
|
41
|
-
|
42
|
-
if activity_name
|
43
|
-
activity_location = File.join(src_dir, "#{activity_name}.mirah")
|
44
|
-
activity_template = File.read(File.join(File.dirname(__FILE__),
|
45
|
-
'..', 'templates',
|
46
|
-
'initial_activity.mirah'))
|
47
|
-
|
48
|
-
File.open(activity_location, 'w') do |f|
|
49
|
-
template_with_classname = activity_template.gsub(/INITIAL_ACTIVITY/, activity_name)
|
50
|
-
f.puts ERB.new(template_with_classname).result(binding)
|
51
|
-
end
|
52
|
-
log "Created Activity '#{activity_name}' in '#{activity_location}'."
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def self.log(msg)
|
59
|
-
STDERR.puts msg
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.create_templated(name, project_location, scope)
|
63
|
-
location = File.join(project_location, name)
|
64
|
-
template = File.read(File.join(File.dirname(__FILE__),
|
65
|
-
'..', 'templates', name))
|
66
|
-
|
67
|
-
File.open(location, 'w') do |f|
|
68
|
-
f.puts ERB.new(template).result(scope)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.mkdir(base, directory)
|
73
|
-
location = File.join(base, directory)
|
74
|
-
FileUtils.mkdir_p location
|
75
|
-
log "Created '#{location}'."
|
76
|
-
end
|
77
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module PindahCLI
|
5
|
+
DEFAULT_TARGET_VERSION = '2.3.3'
|
6
|
+
|
7
|
+
def self.create(package, location=nil, activity_name=nil)
|
8
|
+
segments = package.split('.')
|
9
|
+
location ||= segments.last
|
10
|
+
src_dir = File.join(location, 'src', *segments)
|
11
|
+
|
12
|
+
mkdir location, File.join('src', *segments)
|
13
|
+
mkdir location, 'bin'
|
14
|
+
mkdir location, 'libs'
|
15
|
+
mkdir location, 'res'
|
16
|
+
mkdir location, 'res/drawable-hdpi'
|
17
|
+
mkdir location, 'res/drawable-ldpi'
|
18
|
+
mkdir location, 'res/drawable-mdpi'
|
19
|
+
mkdir location, 'res/layout'
|
20
|
+
mkdir location, 'res/values'
|
21
|
+
|
22
|
+
name = File.basename(location)
|
23
|
+
app_name = name.split(/[-_]/).map{ |w| w.capitalize }.join(" ")
|
24
|
+
|
25
|
+
FileUtils.mkdir_p src_dir
|
26
|
+
|
27
|
+
create_templated("Rakefile", location, binding)
|
28
|
+
create_templated("AndroidManifest.xml", location, binding)
|
29
|
+
create_templated("main.xml", File.join(location, 'res', 'layout'), binding)
|
30
|
+
create_templated("strings.xml", File.join(location, 'res', 'values'), binding)
|
31
|
+
create_templated(".gitignore", location, binding)
|
32
|
+
|
33
|
+
# Default icons of various sizes
|
34
|
+
["hdpi", "mdpi", "ldpi"].each do |s|
|
35
|
+
FileUtils.cp(File.join(File.dirname(__FILE__), '..', 'templates', "res",
|
36
|
+
"drawable-#{s}", "ic_launcher.png"),
|
37
|
+
File.join(location, "res", "drawable-#{s}", "ic_launcher.png"))
|
38
|
+
end
|
39
|
+
|
40
|
+
log "Created project in #{location}."
|
41
|
+
|
42
|
+
if activity_name
|
43
|
+
activity_location = File.join(src_dir, "#{activity_name}.mirah")
|
44
|
+
activity_template = File.read(File.join(File.dirname(__FILE__),
|
45
|
+
'..', 'templates',
|
46
|
+
'initial_activity.mirah'))
|
47
|
+
|
48
|
+
File.open(activity_location, 'w') do |f|
|
49
|
+
template_with_classname = activity_template.gsub(/INITIAL_ACTIVITY/, activity_name)
|
50
|
+
f.puts ERB.new(template_with_classname).result(binding)
|
51
|
+
end
|
52
|
+
log "Created Activity '#{activity_name}' in '#{activity_location}'."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def self.log(msg)
|
59
|
+
STDERR.puts msg
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.create_templated(name, project_location, scope)
|
63
|
+
location = File.join(project_location, name)
|
64
|
+
template = File.read(File.join(File.dirname(__FILE__),
|
65
|
+
'..', 'templates', name))
|
66
|
+
|
67
|
+
File.open(location, 'w') do |f|
|
68
|
+
f.puts ERB.new(template).result(scope)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.mkdir(base, directory)
|
73
|
+
location = File.join(base, directory)
|
74
|
+
FileUtils.mkdir_p location
|
75
|
+
log "Created '#{location}'."
|
76
|
+
end
|
77
|
+
end
|
data/templates/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
bin
|
2
|
-
gen
|
1
|
+
bin/
|
2
|
+
gen/
|
@@ -1,19 +1,19 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
-
package="<%= package %>"
|
4
|
-
android:versionCode="1"
|
5
|
-
android:versionName="1.0">
|
6
|
-
<application android:label="@string/app_name"
|
7
|
-
android:debuggable="true"
|
8
|
-
android:icon="@drawable/ic_launcher">
|
9
|
-
|
10
|
-
<activity android:name="<%= activity_name %>"
|
11
|
-
android:label="@string/app_name">
|
12
|
-
<intent-filter>
|
13
|
-
<action android:name="android.intent.action.MAIN" />
|
14
|
-
<category android:name="android.intent.category.LAUNCHER" />
|
15
|
-
</intent-filter>
|
16
|
-
</activity>
|
17
|
-
|
18
|
-
</application>
|
19
|
-
</manifest>
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
package="<%= package %>"
|
4
|
+
android:versionCode="1"
|
5
|
+
android:versionName="1.0">
|
6
|
+
<application android:label="@string/app_name"
|
7
|
+
android:debuggable="true"
|
8
|
+
android:icon="@drawable/ic_launcher">
|
9
|
+
<% if activity_name %>
|
10
|
+
<activity android:name="<%= activity_name %>"
|
11
|
+
android:label="@string/app_name">
|
12
|
+
<intent-filter>
|
13
|
+
<action android:name="android.intent.action.MAIN" />
|
14
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
15
|
+
</intent-filter>
|
16
|
+
</activity>
|
17
|
+
<% end %>
|
18
|
+
</application>
|
19
|
+
</manifest>
|
data/templates/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "pindah"
|
3
|
-
|
4
|
-
Pindah.spec = {
|
5
|
-
:name => "<%= name %>",
|
6
|
-
:target_version => "<%= DEFAULT_TARGET_VERSION %>"
|
7
|
-
}
|
1
|
+
require "rubygems"
|
2
|
+
require "pindah"
|
3
|
+
|
4
|
+
Pindah.spec = {
|
5
|
+
:name => "<%= name %>",
|
6
|
+
:target_version => "<%= DEFAULT_TARGET_VERSION %>"
|
7
|
+
}
|
data/templates/build.xml
CHANGED
@@ -1,32 +1,47 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project name="<%= @spec[:name] %>">
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
<target name="
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project name="<%= @spec[:name] %>">
|
3
|
+
<property file="local.properties" />
|
4
|
+
|
5
|
+
<property environment="env" />
|
6
|
+
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
|
7
|
+
<isset property="env.ANDROID_HOME" />
|
8
|
+
</condition>
|
9
|
+
|
10
|
+
<property file="project.properties" />
|
11
|
+
|
12
|
+
<!-- quick check on sdk.dir -->
|
13
|
+
<fail message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
|
14
|
+
unless="sdk.dir" />
|
15
|
+
|
16
|
+
<path id="java.classpath">
|
17
|
+
<pathelement location="${classpath}" />
|
18
|
+
<pathelement location="${out.classes.absolute.dir}" />
|
19
|
+
</path>
|
20
|
+
|
21
|
+
<taskdef name="mirahc" classname="org.mirah.ant.Compile" />
|
22
|
+
|
23
|
+
<!-- TODO: better support for mixed-source builds -->
|
24
|
+
<target name="javac" description="Compiles R.java and other gen/ files.">
|
25
|
+
<javac srcdir="${gen.absolute.dir}"
|
26
|
+
destdir="${out.classes.absolute.dir}"
|
27
|
+
source="1.6"
|
28
|
+
target="1.6"
|
29
|
+
includeantruntime="false"
|
30
|
+
failonerror="true" />
|
31
|
+
</target>
|
32
|
+
|
33
|
+
<target name="compile" depends="-compile" />
|
34
|
+
|
35
|
+
<target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile, javac">
|
36
|
+
<mirahc dir="src" destdir="bin/classes" jvmversion="1.6">
|
37
|
+
<classpath refid="java.classpath" />
|
38
|
+
</mirahc>
|
39
|
+
</target>
|
40
|
+
|
41
|
+
<!-- version-tag: 1 -->
|
42
|
+
<import file="${sdk.dir}/tools/ant/build.xml" />
|
43
|
+
|
44
|
+
<% if @spec[:extra_ant_xml] %>
|
45
|
+
<import file="<%= File.expand_path @spec[:extra_ant_xml] %>" />
|
46
|
+
<% end %>
|
47
|
+
</project>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
package <%= package %>
|
2
|
-
|
3
|
-
import android.app.Activity
|
4
|
-
|
5
|
-
class INITIAL_ACTIVITY < Activity
|
6
|
-
def onCreate(state)
|
7
|
-
super state
|
8
|
-
setContentView R.layout.main
|
9
|
-
end
|
10
|
-
end
|
1
|
+
package <%= package %>
|
2
|
+
|
3
|
+
import android.app.Activity
|
4
|
+
|
5
|
+
class INITIAL_ACTIVITY < Activity
|
6
|
+
def onCreate(state)
|
7
|
+
super state
|
8
|
+
setContentView R.layout.main
|
9
|
+
end
|
10
|
+
end
|
data/templates/main.xml
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
-
android:orientation="vertical"
|
4
|
-
android:layout_width="fill_parent"
|
5
|
-
android:layout_height="fill_parent"
|
6
|
-
>
|
7
|
-
<TextView
|
8
|
-
android:layout_width="fill_parent"
|
9
|
-
android:layout_height="wrap_content"
|
10
|
-
android:text="Hello World, <%= name %>"
|
11
|
-
/>
|
12
|
-
</LinearLayout>
|
13
|
-
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
android:orientation="vertical"
|
4
|
+
android:layout_width="fill_parent"
|
5
|
+
android:layout_height="fill_parent"
|
6
|
+
>
|
7
|
+
<TextView
|
8
|
+
android:layout_width="fill_parent"
|
9
|
+
android:layout_height="wrap_content"
|
10
|
+
android:text="Hello World, <%= name %>"
|
11
|
+
/>
|
12
|
+
</LinearLayout>
|
13
|
+
|
data/templates/strings.xml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<resources>
|
3
|
-
<string name="app_name"><%= app_name %></string>
|
4
|
-
</resources>
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<resources>
|
3
|
+
<string name="app_name"><%= app_name %></string>
|
4
|
+
</resources>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
package tld.pindah.testapp
|
2
|
-
|
3
|
-
import android.app.Activity
|
4
|
-
|
5
|
-
class HelloWorld < Activity
|
6
|
-
def onCreate(state)
|
7
|
-
super state
|
8
|
-
setContentView R.layout.main
|
9
|
-
end
|
10
|
-
end
|
1
|
+
package tld.pindah.testapp
|
2
|
+
|
3
|
+
import android.app.Activity
|
4
|
+
|
5
|
+
class HelloWorld < Activity
|
6
|
+
def onCreate(state)
|
7
|
+
super state
|
8
|
+
setContentView R.layout.main
|
9
|
+
end
|
10
|
+
end
|
data/test/pindah_cli_test.rb
CHANGED
@@ -1,85 +1,85 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'tmpdir'
|
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
|
-
PWD = File.expand_path(File.dirname(__FILE__))
|
9
|
-
|
10
|
-
def fixture(name)
|
11
|
-
File.read(File.join(PWD, 'fixtures', name))
|
12
|
-
end
|
13
|
-
|
14
|
-
def setup
|
15
|
-
@temp = Dir.mktmpdir("pindah-")
|
16
|
-
@project_path = "#{@temp}/testapp"
|
17
|
-
FileUtils.mkdir_p File.dirname(@temp)
|
18
|
-
Dir.chdir File.dirname(@temp)
|
19
|
-
PindahCLI.create('tld.pindah.testapp', @project_path, 'HelloWorld')
|
20
|
-
end
|
21
|
-
|
22
|
-
def teardown
|
23
|
-
FileUtils.rm_rf @temp
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_create_should_create_basic_project_structure
|
27
|
-
PindahCLI.create('tld.pindah.testapp', '.')
|
28
|
-
assert File.directory?(File.join(@project_path, 'src', 'tld', 'pindah', 'testapp'))
|
29
|
-
|
30
|
-
directories = %w{ src/tld/pindah/testapp bin libs res
|
31
|
-
res/drawable-hdpi res/drawable-ldpi
|
32
|
-
res/drawable-mdpi res/layout res/values }
|
33
|
-
|
34
|
-
directories.each do |d|
|
35
|
-
expected = File.join(@project_path, d)
|
36
|
-
assert File.directory?(expected), "Expected #{expected.inspect} to be a directory."
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_create_should_create_rakefile
|
41
|
-
rake_path = File.join(@project_path, 'Rakefile')
|
42
|
-
|
43
|
-
assert File.exists?(rake_path)
|
44
|
-
assert_equal fixture("Rakefile"), File.read(rake_path)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_create_should_create_an_activity_if_desired
|
48
|
-
actual = File.read(File.join(@project_path, 'src',
|
49
|
-
'tld', 'pindah',
|
50
|
-
'testapp', 'HelloWorld.mirah'))
|
51
|
-
assert_equal fixture('HelloWorld.mirah'), actual
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_create_should_create_manifest
|
55
|
-
manifest_path = File.join(@project_path, 'AndroidManifest.xml')
|
56
|
-
|
57
|
-
assert File.exists?(manifest_path)
|
58
|
-
assert_equal fixture("AndroidManifest.xml").gsub(/\s+/, ' '), File.read(manifest_path).gsub(/\s+/, ' ')
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_create_should_create_manifest_without_activity
|
62
|
-
@temp = Dir.mktmpdir("pindah-")
|
63
|
-
@project_path = "#{@temp}/testapp"
|
64
|
-
FileUtils.mkdir_p File.dirname(@temp)
|
65
|
-
Dir.chdir File.dirname(@temp)
|
66
|
-
PindahCLI.create('tld.pindah.testapp', @project_path)
|
67
|
-
|
68
|
-
manifest_path = File.join(@project_path, 'AndroidManifest.xml')
|
69
|
-
|
70
|
-
assert File.exists?(manifest_path)
|
71
|
-
assert_equal fixture("AndroidManifest.xml.no-activity").gsub(/\s+/, ' '), File.read(manifest_path).gsub(/\s+/, ' ')
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_create_should_create_strings
|
75
|
-
path = File.join(@project_path, 'res', 'values', 'strings.xml')
|
76
|
-
assert File.exists?(path)
|
77
|
-
assert_equal fixture("strings.xml").strip, File.read(path).strip
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_create_should_create_layout
|
81
|
-
path = File.join(@project_path, 'res', 'layout', 'main.xml')
|
82
|
-
assert File.exists?(path)
|
83
|
-
assert_equal fixture("main.xml").strip, File.read(path).strip
|
84
|
-
end
|
85
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require 'tmpdir'
|
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
|
+
PWD = File.expand_path(File.dirname(__FILE__))
|
9
|
+
|
10
|
+
def fixture(name)
|
11
|
+
File.read(File.join(PWD, 'fixtures', name))
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@temp = Dir.mktmpdir("pindah-")
|
16
|
+
@project_path = "#{@temp}/testapp"
|
17
|
+
FileUtils.mkdir_p File.dirname(@temp)
|
18
|
+
Dir.chdir File.dirname(@temp)
|
19
|
+
PindahCLI.create('tld.pindah.testapp', @project_path, 'HelloWorld')
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
FileUtils.rm_rf @temp
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_should_create_basic_project_structure
|
27
|
+
PindahCLI.create('tld.pindah.testapp', '.')
|
28
|
+
assert File.directory?(File.join(@project_path, 'src', 'tld', 'pindah', 'testapp'))
|
29
|
+
|
30
|
+
directories = %w{ src/tld/pindah/testapp bin libs res
|
31
|
+
res/drawable-hdpi res/drawable-ldpi
|
32
|
+
res/drawable-mdpi res/layout res/values }
|
33
|
+
|
34
|
+
directories.each do |d|
|
35
|
+
expected = File.join(@project_path, d)
|
36
|
+
assert File.directory?(expected), "Expected #{expected.inspect} to be a directory."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_create_should_create_rakefile
|
41
|
+
rake_path = File.join(@project_path, 'Rakefile')
|
42
|
+
|
43
|
+
assert File.exists?(rake_path)
|
44
|
+
assert_equal fixture("Rakefile"), File.read(rake_path)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_create_should_create_an_activity_if_desired
|
48
|
+
actual = File.read(File.join(@project_path, 'src',
|
49
|
+
'tld', 'pindah',
|
50
|
+
'testapp', 'HelloWorld.mirah'))
|
51
|
+
assert_equal fixture('HelloWorld.mirah'), actual
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_create_should_create_manifest
|
55
|
+
manifest_path = File.join(@project_path, 'AndroidManifest.xml')
|
56
|
+
|
57
|
+
assert File.exists?(manifest_path)
|
58
|
+
assert_equal fixture("AndroidManifest.xml").gsub(/\s+/, ' '), File.read(manifest_path).gsub(/\s+/, ' ')
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_create_should_create_manifest_without_activity
|
62
|
+
@temp = Dir.mktmpdir("pindah-")
|
63
|
+
@project_path = "#{@temp}/testapp"
|
64
|
+
FileUtils.mkdir_p File.dirname(@temp)
|
65
|
+
Dir.chdir File.dirname(@temp)
|
66
|
+
PindahCLI.create('tld.pindah.testapp', @project_path)
|
67
|
+
|
68
|
+
manifest_path = File.join(@project_path, 'AndroidManifest.xml')
|
69
|
+
|
70
|
+
assert File.exists?(manifest_path)
|
71
|
+
assert_equal fixture("AndroidManifest.xml.no-activity").gsub(/\s+/, ' '), File.read(manifest_path).gsub(/\s+/, ' ')
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_create_should_create_strings
|
75
|
+
path = File.join(@project_path, 'res', 'values', 'strings.xml')
|
76
|
+
assert File.exists?(path)
|
77
|
+
assert_equal fixture("strings.xml").strip, File.read(path).strip
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_create_should_create_layout
|
81
|
+
path = File.join(@project_path, 'res', 'layout', 'main.xml')
|
82
|
+
assert File.exists?(path)
|
83
|
+
assert_equal fixture("main.xml").strip, File.read(path).strip
|
84
|
+
end
|
85
|
+
end
|