nanaimo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cbb3b9ff9683a0feb685639f1eff5091040b384d
4
+ data.tar.gz: 66bbab5c9d4685f5617984bef6a2a9cc4698f4c4
5
+ SHA512:
6
+ metadata.gz: b10a6d849f8705545701a326b3613063e4d8dd50ade13abd7a79bb2932ff4565385c45bdca54cf1dc165c322e77e00f788cf54cd92aa3a4373f4c8736a45e116
7
+ data.tar.gz: f55afc7cbac079879f1e5c98078e90875da358b7ea6edc95f584f5608939bf5820750714636b9f42dec030e23ad4a7c1b2a4f059d1f755963780fe6c97e8c0c0
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,13 @@
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - 'lib/nanaimo/unicode/**/*.rb'
7
+ - 'vendor/**/*'
8
+
9
+ Lint/AssignmentInCondition:
10
+ Enabled: false
11
+
12
+ Metrics:
13
+ Enabled: false
@@ -0,0 +1,7 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-10-15 01:47:18 -0500 using RuboCop version 0.43.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
@@ -0,0 +1,13 @@
1
+ branches:
2
+ only:
3
+ - master
4
+
5
+ language: ruby
6
+ cache: bundler
7
+ rvm:
8
+ # The latest ruby version
9
+ - 2.3.1
10
+ # OS X 10.9.5-10.10.0 (2.0.0-p481)
11
+ - 2.0.0-p481
12
+ # OS X 10.9.3-10.9.4
13
+ - 2.0.0-p451
@@ -0,0 +1,8 @@
1
+ # Nanaimo Changelog
2
+
3
+ ## 0.1.0 (2016-10-21)
4
+
5
+ ##### Enhancements
6
+
7
+ * Initial implementation.
8
+ [Samuel Giddins](https://github.com/segiddins)
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at dan@tomlinson.io. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nanaimo.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'rubocop'
8
+ end
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nanaimo (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.3.0)
10
+ diff-lcs (1.2.5)
11
+ parser (2.3.1.4)
12
+ ast (~> 2.2)
13
+ powerpack (0.1.1)
14
+ rainbow (2.1.0)
15
+ rake (10.5.0)
16
+ rspec (3.5.0)
17
+ rspec-core (~> 3.5.0)
18
+ rspec-expectations (~> 3.5.0)
19
+ rspec-mocks (~> 3.5.0)
20
+ rspec-core (3.5.4)
21
+ rspec-support (~> 3.5.0)
22
+ rspec-expectations (3.5.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-mocks (3.5.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-support (3.5.0)
29
+ rubocop (0.43.0)
30
+ parser (>= 2.3.1.1, < 3.0)
31
+ powerpack (~> 0.1)
32
+ rainbow (>= 1.99.1, < 3.0)
33
+ ruby-progressbar (~> 1.7)
34
+ unicode-display_width (~> 1.0, >= 1.0.1)
35
+ ruby-progressbar (1.8.1)
36
+ unicode-display_width (1.1.1)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bundler (~> 1.12)
43
+ nanaimo!
44
+ rake (~> 10.0)
45
+ rspec (~> 3.0)
46
+ rubocop
47
+
48
+ BUNDLED WITH
49
+ 1.13.5
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Danielle Tomlinson, Samuel Giddins
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # Nanaimo
2
+
3
+ Nanaimo is a simple library that implements ASCII Plist serialization and
4
+ deserialization, entirely with native Ruby code (and zero dependencies). It
5
+ also comes with out-of-the-box support for serializing Xcode projects (complete
6
+ with annotations) and XML plists.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'nanaimo'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install nanaimo
23
+
24
+ ## Usage
25
+
26
+ ```ruby
27
+ require 'nanaimo'
28
+
29
+ # parse a native ruby object from an ascii plist file
30
+ project_hash = Nanaimo::Reader
31
+ .from_file("App.xcodeproj/project.pbxproj")
32
+ .parse!
33
+ .as_ruby
34
+
35
+ # change that object
36
+ project_hash['...'] = '...'
37
+
38
+ # re-serialize it
39
+ ascii_plist_string = Nanaimo::Writer.new(project_hash).write
40
+ ```
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nanaimo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
51
+
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,72 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: [:spec, :rubocop]
9
+
10
+ task :generate_nextstep_mappings do
11
+ require 'net/http'
12
+ url = 'http://ftp.unicode.org/Public/MAPPINGS/VENDORS/NEXT/NEXTSTEP.TXT'
13
+ mappings = Net::HTTP.get(URI(url))
14
+ .lines
15
+ .grep(/^[^#$]/)
16
+ .map { |l| l.split("\t", 3) }
17
+ .reduce('') do |f, (ns, uc, cm)|
18
+ f << " #{ns} => #{uc}, #{cm}"
19
+ end
20
+ map = <<-RUBY
21
+ # frozen-string-literal: true
22
+ module Nanaimo
23
+ module Unicode
24
+ # Taken from #{url}
25
+ NEXT_STEP_MAPPING = {
26
+ #{mappings} }.freeze
27
+ end
28
+ end
29
+ RUBY
30
+ File.open('lib/nanaimo/unicode/next_step_mapping.rb', 'w') { |f| f << map }
31
+ end
32
+
33
+ task :generate_quote_maps do
34
+ quote_map = {
35
+ "\a" => '\\a',
36
+ "\b" => '\\b',
37
+ "\f" => '\\f',
38
+ "\r" => '\\r',
39
+ "\t" => '\\t',
40
+ "\v" => '\\v',
41
+ "\n" => '\\n',
42
+ %(') => "\\'",
43
+ %(") => '\\"'
44
+ }
45
+
46
+ unquote_map = quote_map.each_with_object("\n" => "\n") do |(value, escaped), map|
47
+ map[escaped[1..-1]] = value
48
+ map
49
+ end
50
+
51
+ 0.upto(31) { |i| quote_map[[i].pack('U')] ||= format('\\U%04x', i) }
52
+ quote_regexp = Regexp.union(quote_map.keys)
53
+
54
+ dump_hash = proc do |hash, indent = 4|
55
+ hash.reduce("{\n") { |dumped, (k, v)| dumped << "#{' ' * (indent + 2)}#{k.dump} => #{v.dump},\n" } << ' ' * indent << '}.freeze'
56
+ end
57
+
58
+ map = <<-RUBY
59
+ # frozen-string-literal: true
60
+ module Nanaimo
61
+ module Unicode
62
+ QUOTE_MAP = #{dump_hash[quote_map]}
63
+
64
+ UNQUOTE_MAP = #{dump_hash[unquote_map]}
65
+
66
+ QUOTE_REGEXP = #{quote_regexp.inspect}
67
+ end
68
+ end
69
+ RUBY
70
+
71
+ File.open('lib/nanaimo/unicode/quote_maps.rb', 'w') { |f| f << map }
72
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'nanaimo'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,21 @@
1
+ require 'nanaimo/version'
2
+
3
+ # A native Ruby implementation of ASCII plist parsing and serialization.
4
+ #
5
+ module Nanaimo
6
+ class Error < StandardError; end
7
+
8
+ DEBUG = !ENV['NANAIMO_DEBUG'].nil?
9
+ private_constant :DEBUG
10
+ def self.debug
11
+ return unless DEBUG
12
+ warn yield
13
+ end
14
+
15
+ require 'nanaimo/object'
16
+ require 'nanaimo/plist'
17
+ require 'nanaimo/reader'
18
+ require 'nanaimo/unicode'
19
+ require 'nanaimo/writer'
20
+ require 'nanaimo/xcode_project_writer'
21
+ end
@@ -0,0 +1,100 @@
1
+ module Nanaimo
2
+ # An object that belongs to a plist.
3
+ #
4
+ class Object
5
+ # @return The underlying native Ruby value
6
+ #
7
+ attr_accessor :value
8
+
9
+ # @return [String] The annotation comment
10
+ #
11
+ attr_accessor :annotation
12
+
13
+ def initialize(value, annotation)
14
+ self.value = value
15
+ self.annotation = annotation
16
+
17
+ raise 'Item cannot be initialize with a nil value' if value.nil?
18
+ end
19
+
20
+ def ==(other)
21
+ return unless other
22
+ if other.is_a?(self.class)
23
+ other.value == value && annotation == other.annotation
24
+ elsif other.is_a?(value.class)
25
+ other == value
26
+ end
27
+ end
28
+ alias eql? ==
29
+
30
+ def hash
31
+ value.hash
32
+ end
33
+
34
+ def <=>(other)
35
+ other_value = if other.is_a?(Object)
36
+ other.value
37
+ elsif other.is_a?(value.class)
38
+ other
39
+ end
40
+ return unless other_value
41
+
42
+ value <=> other_value
43
+ end
44
+
45
+ def to_s
46
+ format('<%s %s>', self.class, value)
47
+ end
48
+
49
+ # @return A native Ruby object representation
50
+ #
51
+ def as_ruby
52
+ raise 'unimplemented'
53
+ end
54
+ end
55
+
56
+ # A string object in a Plist.
57
+ #
58
+ class String < Object
59
+ def as_ruby
60
+ value
61
+ end
62
+ end
63
+
64
+ # A string object surrounded by quotes in a Plist.
65
+ #
66
+ class QuotedString < Object
67
+ def as_ruby
68
+ value
69
+ end
70
+ end
71
+
72
+ # A data object in a Plist, represented by a binary-encoded string.
73
+ #
74
+ class Data < Object
75
+ def initialize(value, annotation)
76
+ value &&= value.force_encoding(Encoding::BINARY)
77
+ super(value, annotation)
78
+ end
79
+
80
+ def as_ruby
81
+ value
82
+ end
83
+ end
84
+
85
+ # An array object in a Plist.
86
+ #
87
+ class Array < Object
88
+ def as_ruby
89
+ value.map(&:as_ruby)
90
+ end
91
+ end
92
+
93
+ # A dictionary object in a Plist.
94
+ #
95
+ class Dictionary < Object
96
+ def as_ruby
97
+ Hash[value.map { |k, v| [k.as_ruby, v.as_ruby] }]
98
+ end
99
+ end
100
+ end